@skyux/core 5.0.0-beta.8 → 5.1.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.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/bundles/skyux-core-testing.umd.js +363 -234
  3. package/bundles/skyux-core-testing.umd.js.map +1 -1
  4. package/bundles/skyux-core.umd.js +3303 -2916
  5. package/bundles/skyux-core.umd.js.map +1 -1
  6. package/documentation.json +8863 -0
  7. package/esm2015/modules/adapter-service/adapter.module.js +11 -8
  8. package/esm2015/modules/adapter-service/adapter.service.js +14 -15
  9. package/esm2015/modules/adapter-service/focusable-children-options.js +2 -1
  10. package/esm2015/modules/affix/affix-auto-fit-context.js +1 -1
  11. package/esm2015/modules/affix/affix-config.js +2 -1
  12. package/esm2015/modules/affix/affix-horizontal-alignment.js +2 -1
  13. package/esm2015/modules/affix/affix-offset-change.js +2 -1
  14. package/esm2015/modules/affix/affix-offset.js +2 -1
  15. package/esm2015/modules/affix/affix-placement-change.js +2 -1
  16. package/esm2015/modules/affix/affix-placement.js +2 -1
  17. package/esm2015/modules/affix/affix-utils.js +1 -1
  18. package/esm2015/modules/affix/affix-vertical-alignment.js +2 -1
  19. package/esm2015/modules/affix/affix.directive.js +36 -49
  20. package/esm2015/modules/affix/affix.module.js +22 -17
  21. package/esm2015/modules/affix/affix.service.js +12 -15
  22. package/esm2015/modules/affix/affixer.js +1 -1
  23. package/esm2015/modules/affix/dom-utils.js +1 -1
  24. package/esm2015/modules/dock/dock-dom-adapter.service.js +23 -15
  25. package/esm2015/modules/dock/dock-insert-component-config.js +2 -1
  26. package/esm2015/modules/dock/dock-item-config.js +2 -1
  27. package/esm2015/modules/dock/dock-item-reference.js +2 -1
  28. package/esm2015/modules/dock/dock-item.js +1 -1
  29. package/esm2015/modules/dock/dock-location.js +19 -0
  30. package/esm2015/modules/dock/dock-options.js +2 -0
  31. package/esm2015/modules/dock/dock.component.js +48 -33
  32. package/esm2015/modules/dock/dock.module.js +28 -17
  33. package/esm2015/modules/dock/dock.service.js +44 -16
  34. package/esm2015/modules/dock/sort-by-stack-order.js +1 -1
  35. package/esm2015/modules/dynamic-component/dynamic-component-location.js +15 -3
  36. package/esm2015/modules/dynamic-component/dynamic-component-options.js +2 -1
  37. package/esm2015/modules/dynamic-component/dynamic-component.module.js +11 -8
  38. package/esm2015/modules/dynamic-component/dynamic-component.service.js +24 -23
  39. package/esm2015/modules/format/app-format.js +11 -11
  40. package/esm2015/modules/id/id.directive.js +14 -16
  41. package/esm2015/modules/id/id.module.js +18 -15
  42. package/esm2015/modules/log/log.module.js +11 -8
  43. package/esm2015/modules/log/log.service.js +11 -11
  44. package/esm2015/modules/media-query/media-breakpoints.js +1 -1
  45. package/esm2015/modules/media-query/media-query-listener.js +2 -1
  46. package/esm2015/modules/media-query/media-query.module.js +11 -8
  47. package/esm2015/modules/media-query/media-query.service.js +16 -20
  48. package/esm2015/modules/mutation/mutation-observer-service.js +11 -11
  49. package/esm2015/modules/numeric/numeric-symbol.js +2 -1
  50. package/esm2015/modules/numeric/numeric.module.js +30 -21
  51. package/esm2015/modules/numeric/numeric.options.js +6 -1
  52. package/esm2015/modules/numeric/numeric.pipe.js +14 -16
  53. package/esm2015/modules/numeric/numeric.service.js +15 -17
  54. package/esm2015/modules/overlay/overlay-adapter.service.js +13 -15
  55. package/esm2015/modules/overlay/overlay-config.js +2 -1
  56. package/esm2015/modules/overlay/overlay-context.js +1 -1
  57. package/esm2015/modules/overlay/overlay-instance.js +1 -1
  58. package/esm2015/modules/overlay/overlay.component.js +41 -44
  59. package/esm2015/modules/overlay/overlay.module.js +22 -17
  60. package/esm2015/modules/overlay/overlay.service.js +18 -26
  61. package/esm2015/modules/percent-pipe/percent-pipe.module.js +30 -21
  62. package/esm2015/modules/percent-pipe/percent.pipe.js +15 -15
  63. package/esm2015/modules/scrollable-host/scrollable-host.service.js +83 -0
  64. package/esm2015/modules/shared/number-format/number-format-utility.js +4 -3
  65. package/esm2015/modules/shared/sky-core-resources.module.js +41 -0
  66. package/esm2015/modules/title/set-title-args.js +2 -1
  67. package/esm2015/modules/title/title.service.js +11 -15
  68. package/esm2015/modules/ui-config/ui-config.service.js +11 -11
  69. package/esm2015/modules/viewkeeper/viewkeeper-boundary-info.js +2 -1
  70. package/esm2015/modules/viewkeeper/viewkeeper-fixed-styles.js +2 -1
  71. package/esm2015/modules/viewkeeper/viewkeeper-host-options.js +9 -8
  72. package/esm2015/modules/viewkeeper/viewkeeper-offset.js +2 -1
  73. package/esm2015/modules/viewkeeper/viewkeeper-options.js +2 -1
  74. package/esm2015/modules/viewkeeper/viewkeeper.directive.js +47 -32
  75. package/esm2015/modules/viewkeeper/viewkeeper.js +16 -11
  76. package/esm2015/modules/viewkeeper/viewkeeper.module.js +18 -15
  77. package/esm2015/modules/viewkeeper/viewkeeper.service.js +13 -16
  78. package/esm2015/modules/window/window-ref.js +11 -11
  79. package/esm2015/public-api.js +60 -0
  80. package/esm2015/skyux-core.js +2 -12
  81. package/esm2015/testing/mock-media-query.service.js +9 -8
  82. package/esm2015/testing/mock-ui-config.service.js +9 -8
  83. package/esm2015/testing/public-api.js +3 -0
  84. package/esm2015/testing/skyux-core-testing.js +2 -2
  85. package/fesm2015/skyux-core-testing.js +15 -11
  86. package/fesm2015/skyux-core-testing.js.map +1 -1
  87. package/fesm2015/skyux-core.js +828 -570
  88. package/fesm2015/skyux-core.js.map +1 -1
  89. package/modules/adapter-service/adapter.module.d.ts +4 -0
  90. package/modules/adapter-service/adapter.service.d.ts +3 -0
  91. package/modules/affix/affix.directive.d.ts +3 -0
  92. package/modules/affix/affix.module.d.ts +6 -0
  93. package/modules/affix/affix.service.d.ts +3 -0
  94. package/modules/dock/dock-dom-adapter.service.d.ts +6 -0
  95. package/modules/dock/dock-location.d.ts +17 -0
  96. package/modules/dock/dock-options.d.ts +18 -0
  97. package/modules/dock/dock.component.d.ts +8 -3
  98. package/modules/dock/dock.module.d.ts +6 -0
  99. package/modules/dock/dock.service.d.ts +14 -1
  100. package/modules/dynamic-component/dynamic-component-location.d.ts +14 -2
  101. package/modules/dynamic-component/dynamic-component-options.d.ts +4 -0
  102. package/modules/dynamic-component/dynamic-component.module.d.ts +4 -0
  103. package/modules/dynamic-component/dynamic-component.service.d.ts +3 -0
  104. package/modules/format/app-format.d.ts +3 -0
  105. package/modules/id/id.directive.d.ts +3 -0
  106. package/modules/id/id.module.d.ts +5 -0
  107. package/modules/log/log.module.d.ts +4 -0
  108. package/modules/log/log.service.d.ts +3 -0
  109. package/modules/media-query/media-query.module.d.ts +4 -0
  110. package/modules/media-query/media-query.service.d.ts +3 -0
  111. package/modules/mutation/mutation-observer-service.d.ts +3 -0
  112. package/modules/numeric/numeric.module.d.ts +7 -0
  113. package/modules/numeric/numeric.options.d.ts +5 -0
  114. package/modules/numeric/numeric.pipe.d.ts +3 -0
  115. package/modules/numeric/numeric.service.d.ts +3 -0
  116. package/modules/overlay/overlay-adapter.service.d.ts +3 -0
  117. package/modules/overlay/overlay.component.d.ts +3 -0
  118. package/modules/overlay/overlay.module.d.ts +6 -0
  119. package/modules/overlay/overlay.service.d.ts +3 -0
  120. package/modules/percent-pipe/percent-pipe.module.d.ts +7 -0
  121. package/modules/percent-pipe/percent.pipe.d.ts +3 -0
  122. package/modules/scrollable-host/scrollable-host.service.d.ts +16 -0
  123. package/modules/shared/number-format/number-format-utility.d.ts +1 -1
  124. package/modules/shared/sky-core-resources.module.d.ts +14 -0
  125. package/modules/title/title.service.d.ts +3 -0
  126. package/modules/ui-config/ui-config.service.d.ts +3 -0
  127. package/modules/viewkeeper/viewkeeper-host-options.d.ts +4 -0
  128. package/modules/viewkeeper/viewkeeper-options.d.ts +5 -0
  129. package/modules/viewkeeper/viewkeeper.d.ts +1 -0
  130. package/modules/viewkeeper/viewkeeper.directive.d.ts +7 -1
  131. package/modules/viewkeeper/viewkeeper.module.d.ts +5 -0
  132. package/modules/viewkeeper/viewkeeper.service.d.ts +3 -0
  133. package/modules/window/window-ref.d.ts +3 -0
  134. package/package.json +8 -23
  135. package/{public_api.d.ts → public-api.d.ts} +6 -0
  136. package/skyux-core.d.ts +2 -11
  137. package/testing/mock-media-query.service.d.ts +3 -0
  138. package/testing/mock-ui-config.service.d.ts +3 -0
  139. package/testing/package.json +2 -5
  140. package/testing/{public_api.d.ts → public-api.d.ts} +0 -0
  141. package/testing/skyux-core-testing.d.ts +2 -1
  142. package/CHANGELOG.md +0 -320
  143. package/bundles/skyux-core-testing.umd.min.js +0 -16
  144. package/bundles/skyux-core-testing.umd.min.js.map +0 -1
  145. package/bundles/skyux-core.umd.min.js +0 -16
  146. package/bundles/skyux-core.umd.min.js.map +0 -1
  147. package/esm2015/modules/shared/core-resources.module.js +0 -17
  148. package/esm2015/plugin-resources/core-resources-provider.js +0 -16
  149. package/esm2015/public_api.js +0 -36
  150. package/esm2015/testing/public_api.js +0 -3
  151. package/esm5/modules/adapter-service/adapter.module.js +0 -16
  152. package/esm5/modules/adapter-service/adapter.service.js +0 -221
  153. package/esm5/modules/adapter-service/focusable-children-options.js +0 -1
  154. package/esm5/modules/affix/affix-auto-fit-context.js +0 -12
  155. package/esm5/modules/affix/affix-config.js +0 -1
  156. package/esm5/modules/affix/affix-horizontal-alignment.js +0 -1
  157. package/esm5/modules/affix/affix-offset-change.js +0 -1
  158. package/esm5/modules/affix/affix-offset.js +0 -1
  159. package/esm5/modules/affix/affix-placement-change.js +0 -1
  160. package/esm5/modules/affix/affix-placement.js +0 -1
  161. package/esm5/modules/affix/affix-utils.js +0 -23
  162. package/esm5/modules/affix/affix-vertical-alignment.js +0 -1
  163. package/esm5/modules/affix/affix.directive.js +0 -113
  164. package/esm5/modules/affix/affix.module.js +0 -24
  165. package/esm5/modules/affix/affix.service.js +0 -28
  166. package/esm5/modules/affix/affixer.js +0 -368
  167. package/esm5/modules/affix/dom-utils.js +0 -79
  168. package/esm5/modules/dock/dock-dom-adapter.service.js +0 -72
  169. package/esm5/modules/dock/dock-insert-component-config.js +0 -1
  170. package/esm5/modules/dock/dock-item-config.js +0 -1
  171. package/esm5/modules/dock/dock-item-reference.js +0 -1
  172. package/esm5/modules/dock/dock-item.js +0 -35
  173. package/esm5/modules/dock/dock.component.js +0 -87
  174. package/esm5/modules/dock/dock.module.js +0 -24
  175. package/esm5/modules/dock/dock.service.js +0 -69
  176. package/esm5/modules/dock/sort-by-stack-order.js +0 -13
  177. package/esm5/modules/dynamic-component/dynamic-component-location.js +0 -15
  178. package/esm5/modules/dynamic-component/dynamic-component-options.js +0 -1
  179. package/esm5/modules/dynamic-component/dynamic-component.module.js +0 -17
  180. package/esm5/modules/dynamic-component/dynamic-component.service.js +0 -82
  181. package/esm5/modules/format/app-format.js +0 -25
  182. package/esm5/modules/id/id.directive.js +0 -41
  183. package/esm5/modules/id/id.module.js +0 -20
  184. package/esm5/modules/log/log.module.js +0 -16
  185. package/esm5/modules/log/log.service.js +0 -29
  186. package/esm5/modules/media-query/media-breakpoints.js +0 -20
  187. package/esm5/modules/media-query/media-query-listener.js +0 -1
  188. package/esm5/modules/media-query/media-query.module.js +0 -16
  189. package/esm5/modules/media-query/media-query.service.js +0 -128
  190. package/esm5/modules/mutation/mutation-observer-service.js +0 -19
  191. package/esm5/modules/numeric/numeric-symbol.js +0 -1
  192. package/esm5/modules/numeric/numeric.module.js +0 -29
  193. package/esm5/modules/numeric/numeric.options.js +0 -38
  194. package/esm5/modules/numeric/numeric.pipe.js +0 -70
  195. package/esm5/modules/numeric/numeric.service.js +0 -195
  196. package/esm5/modules/overlay/overlay-adapter.service.js +0 -44
  197. package/esm5/modules/overlay/overlay-config.js +0 -1
  198. package/esm5/modules/overlay/overlay-context.js +0 -12
  199. package/esm5/modules/overlay/overlay-instance.js +0 -66
  200. package/esm5/modules/overlay/overlay.component.js +0 -168
  201. package/esm5/modules/overlay/overlay.module.js +0 -24
  202. package/esm5/modules/overlay/overlay.service.js +0 -128
  203. package/esm5/modules/percent-pipe/percent-pipe.module.js +0 -29
  204. package/esm5/modules/percent-pipe/percent.pipe.js +0 -49
  205. package/esm5/modules/shared/core-resources.module.js +0 -20
  206. package/esm5/modules/shared/number-format/number-format-utility.js +0 -75
  207. package/esm5/modules/title/set-title-args.js +0 -1
  208. package/esm5/modules/title/title.service.js +0 -35
  209. package/esm5/modules/ui-config/ui-config.service.js +0 -24
  210. package/esm5/modules/viewkeeper/viewkeeper-boundary-info.js +0 -1
  211. package/esm5/modules/viewkeeper/viewkeeper-fixed-styles.js +0 -1
  212. package/esm5/modules/viewkeeper/viewkeeper-host-options.js +0 -12
  213. package/esm5/modules/viewkeeper/viewkeeper-offset.js +0 -1
  214. package/esm5/modules/viewkeeper/viewkeeper-options.js +0 -1
  215. package/esm5/modules/viewkeeper/viewkeeper.directive.js +0 -134
  216. package/esm5/modules/viewkeeper/viewkeeper.js +0 -219
  217. package/esm5/modules/viewkeeper/viewkeeper.module.js +0 -20
  218. package/esm5/modules/viewkeeper/viewkeeper.service.js +0 -42
  219. package/esm5/modules/window/window-ref.js +0 -37
  220. package/esm5/plugin-resources/core-resources-provider.js +0 -17
  221. package/esm5/public_api.js +0 -36
  222. package/esm5/skyux-core.js +0 -15
  223. package/esm5/testing/mock-media-query.service.js +0 -47
  224. package/esm5/testing/mock-ui-config.service.js +0 -66
  225. package/esm5/testing/public_api.js +0 -3
  226. package/esm5/testing/skyux-core-testing.js +0 -5
  227. package/fesm5/skyux-core-testing.js +0 -114
  228. package/fesm5/skyux-core-testing.js.map +0 -1
  229. package/fesm5/skyux-core.js +0 -2902
  230. package/fesm5/skyux-core.js.map +0 -1
  231. package/modules/shared/core-resources.module.d.ts +0 -2
  232. package/plugin-resources/core-resources-provider.d.ts +0 -5
  233. package/skyux-core.metadata.json +0 -1
  234. package/src/assets/locales/resources_en_US.json +0 -18
  235. package/testing/skyux-core-testing.metadata.json +0 -1
@@ -1,2902 +0,0 @@
1
- import { __decorate, __assign, __read, __param, __values, __spread } from 'tslib';
2
- import { NgModule, RendererFactory2, ɵɵdefineInjectable, ɵɵinject, Injectable, EventEmitter, ElementRef, Input, Output, Directive, Injector, ChangeDetectorRef, ComponentFactoryResolver, ViewChild, ViewContainerRef, Component, ChangeDetectionStrategy, ApplicationRef, INJECTOR, Renderer2, NgZone, Pipe, Optional } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
4
- import { Subject, fromEvent, BehaviorSubject, of } from 'rxjs';
5
- import { takeUntil, debounceTime } from 'rxjs/operators';
6
- import { getStringForLocale, SKY_LIB_RESOURCES_PROVIDERS, SkyIntlNumberFormatStyle, SkyIntlNumberFormatter, SkyLibResourcesService, SkyAppLocaleProvider, SkyI18nModule } from '@skyux/i18n';
7
- import { NavigationStart, Router } from '@angular/router';
8
- import { Title } from '@angular/platform-browser';
9
-
10
- /**
11
- * @deprecated The `SkyCoreAdapterService` no longer needs the `SkyCoreAdapterModule`.
12
- * The `SkyCoreAdapterModule` can be removed from your project.
13
- */
14
- var SkyCoreAdapterModule = /** @class */ (function () {
15
- function SkyCoreAdapterModule() {
16
- }
17
- SkyCoreAdapterModule = __decorate([
18
- NgModule({})
19
- ], SkyCoreAdapterModule);
20
- return SkyCoreAdapterModule;
21
- }());
22
-
23
- var SkyMediaBreakpoints;
24
- (function (SkyMediaBreakpoints) {
25
- /**
26
- * Indicates screen widths of 767px or less.
27
- */
28
- SkyMediaBreakpoints[SkyMediaBreakpoints["xs"] = 1] = "xs";
29
- /**
30
- * Indicates screen widths of 768px to 991px.
31
- */
32
- SkyMediaBreakpoints[SkyMediaBreakpoints["sm"] = 2] = "sm";
33
- /**
34
- * Indicates screen widths of 992px to 1199px.
35
- */
36
- SkyMediaBreakpoints[SkyMediaBreakpoints["md"] = 3] = "md";
37
- /**
38
- * Indicates screen widths of 1200px or greater.
39
- */
40
- SkyMediaBreakpoints[SkyMediaBreakpoints["lg"] = 4] = "lg";
41
- })(SkyMediaBreakpoints || (SkyMediaBreakpoints = {}));
42
-
43
- var SKY_TABBABLE_SELECTOR = [
44
- 'a[href]',
45
- 'area[href]',
46
- 'input:not([disabled])',
47
- 'button:not([disabled])',
48
- 'select:not([disabled])',
49
- 'textarea:not([disabled])',
50
- 'iframe',
51
- 'object',
52
- 'embed',
53
- '*[contenteditable=true]:not([disabled])',
54
- '*[tabindex]:not([disabled])'
55
- ].join(', ');
56
- var SkyCoreAdapterService = /** @class */ (function () {
57
- function SkyCoreAdapterService(rendererFactory) {
58
- this.rendererFactory = rendererFactory;
59
- this.renderer = this.rendererFactory.createRenderer(undefined, undefined);
60
- }
61
- /**
62
- * Set the responsive container CSS class for a given element.
63
- *
64
- * @param elementRef - The element that will recieve the new CSS class.
65
- * @param breakpoint - The SkyMediaBreakpoint will determine which class
66
- * gets set. For example a SkyMediaBreakpoint of `xs` will set a CSS class of `sky-responsive-container-xs`.
67
- */
68
- SkyCoreAdapterService.prototype.setResponsiveContainerClass = function (elementRef, breakpoint) {
69
- var nativeEl = elementRef.nativeElement;
70
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-xs');
71
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-sm');
72
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-md');
73
- this.renderer.removeClass(nativeEl, 'sky-responsive-container-lg');
74
- var newClass;
75
- switch (breakpoint) {
76
- case SkyMediaBreakpoints.xs: {
77
- newClass = 'sky-responsive-container-xs';
78
- break;
79
- }
80
- case SkyMediaBreakpoints.sm: {
81
- newClass = 'sky-responsive-container-sm';
82
- break;
83
- }
84
- case SkyMediaBreakpoints.md: {
85
- newClass = 'sky-responsive-container-md';
86
- break;
87
- }
88
- default: {
89
- newClass = 'sky-responsive-container-lg';
90
- break;
91
- }
92
- }
93
- this.renderer.addClass(nativeEl, newClass);
94
- };
95
- /**
96
- * This method temporarily enables/disables pointer events.
97
- * This is helpful to prevent iFrames from interfering with drag events.
98
- *
99
- * @param enable - Set to `true` to enable pointer events. Set to `false` to disable.
100
- */
101
- SkyCoreAdapterService.prototype.toggleIframePointerEvents = function (enable) {
102
- var iframes = document.querySelectorAll('iframe');
103
- for (var i = 0; i < iframes.length; i++) {
104
- // Setting to empty string will allow iframe to fall back to its prior CSS assignment.
105
- iframes[i].style.pointerEvents = enable ? '' : 'none';
106
- }
107
- };
108
- /**
109
- * Focuses on the first element found with an `autofocus` attribute inside the supplied `elementRef`.
110
- *
111
- * @param elementRef - The element to search within.
112
- * @return Returns `true` if a child element with autofocus is found.
113
- */
114
- SkyCoreAdapterService.prototype.applyAutoFocus = function (elementRef) {
115
- var elementWithAutoFocus = elementRef.nativeElement.querySelector('[autofocus]');
116
- // Child was found with the autofocus property. Set focus and return true.
117
- if (elementWithAutoFocus) {
118
- elementWithAutoFocus.focus();
119
- return true;
120
- }
121
- // No children were found with autofocus property. Return false.
122
- return false;
123
- };
124
- /**
125
- * Sets focus on the first focusable child of the `elementRef` parameter.
126
- * If no focusable children are found, and `focusOnContainerIfNoChildrenFound` is `true`,
127
- * focus will be set on the container element.
128
- *
129
- * @param elementRef - The element to search within.
130
- * @param containerSelector - A CSS selector indicating the container that should
131
- * recieve focus if no focusable children are found.
132
- * @param focusOnContainerIfNoChildrenFound - It set to `true`, the container will
133
- * recieve focus if no focusable children are found.
134
- */
135
- SkyCoreAdapterService.prototype.getFocusableChildrenAndApplyFocus = function (elementRef, containerSelector, focusOnContainerIfNoChildrenFound) {
136
- if (focusOnContainerIfNoChildrenFound === void 0) { focusOnContainerIfNoChildrenFound = false; }
137
- var containerElement = elementRef.nativeElement.querySelector(containerSelector);
138
- var focusableChildren = this.getFocusableChildren(containerElement);
139
- // Focus first focusable child if available. Otherwise, set focus on container.
140
- if (!this.focusFirstElement(focusableChildren) && focusOnContainerIfNoChildrenFound) {
141
- containerElement.focus();
142
- }
143
- };
144
- /**
145
- * Returns an array of all focusable children of provided `element`.
146
- *
147
- * @param element - The HTMLElement to search within.
148
- * @param options - Options for getting focusable children.
149
- */
150
- SkyCoreAdapterService.prototype.getFocusableChildren = function (element, options) {
151
- var _this = this;
152
- var elements = Array.prototype.slice.call(element.querySelectorAll(SKY_TABBABLE_SELECTOR));
153
- // Unless ignoreTabIndex = true, filter out elements with tabindex = -1.
154
- if (!options || !options.ignoreTabIndex) {
155
- elements = elements.filter(function (el) {
156
- return el.tabIndex !== -1;
157
- });
158
- }
159
- // Unless ignoreVisibility = true, filter out elements that are not visible.
160
- if (!options || !options.ignoreVisibility) {
161
- elements = elements.filter(function (el) {
162
- return _this.isVisible(el);
163
- });
164
- }
165
- return elements;
166
- };
167
- /**
168
- * Returns the clientWidth of the provided elementRef.
169
- * @param elementRef - The element to calculate width from.
170
- */
171
- SkyCoreAdapterService.prototype.getWidth = function (elementRef) {
172
- return elementRef.nativeElement.clientWidth;
173
- };
174
- /**
175
- * Checks if an event target has a higher z-index than a given element.
176
- * @param target The event target element.
177
- * @param element The element to test against. A z-index must be explicitly set for this element.
178
- */
179
- SkyCoreAdapterService.prototype.isTargetAboveElement = function (target, element) {
180
- var zIndex = getComputedStyle(element).zIndex;
181
- var el = target;
182
- while (el) {
183
- // Getting the computed style only works for elements that exist in the DOM.
184
- // In certain scenarios, an element is removed after a click event; by the time the event
185
- // bubbles up to other elements, however, the element has been removed and the computed style returns empty.
186
- // In this case, we'll need to check the z-index directly, via the style property.
187
- var targetZIndex = getComputedStyle(el).zIndex || el.style.zIndex;
188
- if (targetZIndex !== '' &&
189
- targetZIndex !== 'auto' &&
190
- +targetZIndex > +zIndex) {
191
- return true;
192
- }
193
- el = el.parentElement;
194
- }
195
- return false;
196
- };
197
- /**
198
- * Remove inline height styles from the provided elements.
199
- * @param elementRef - The element to search within.
200
- * @param selector - The CSS selector to use when finding elements for removing height.
201
- */
202
- SkyCoreAdapterService.prototype.resetHeight = function (elementRef, selector) {
203
- var children = elementRef.nativeElement.querySelectorAll(selector);
204
- if (children.length > 0) {
205
- for (var i = 0; i < children.length; i++) {
206
- // Setting style attributes with Web API requires null instead of undefined.
207
- // tslint:disable-next-line: no-null-keyword
208
- children[i].style.height = null;
209
- }
210
- }
211
- };
212
- /**
213
- * Sets all element heights to match the height of the tallest element.
214
- * @param elementRef - The element to search within.
215
- * @param selector - The CSS selector to use when finding elements for syncing height.
216
- */
217
- SkyCoreAdapterService.prototype.syncMaxHeight = function (elementRef, selector) {
218
- var children = elementRef.nativeElement.querySelectorAll(selector);
219
- if (children.length > 0) {
220
- var maxHeight = 0;
221
- for (var i = 0; i < children.length; i++) {
222
- maxHeight = Math.max(maxHeight, children[i].offsetHeight);
223
- }
224
- for (var i = 0; i < children.length; i++) {
225
- children[i].style.height = maxHeight + 'px';
226
- }
227
- }
228
- };
229
- SkyCoreAdapterService.prototype.focusFirstElement = function (list) {
230
- if (list.length > 0) {
231
- list[0].focus();
232
- return true;
233
- }
234
- return false;
235
- };
236
- SkyCoreAdapterService.prototype.isVisible = function (element) {
237
- var style = window.getComputedStyle(element);
238
- var isHidden = style.display === 'none' || style.visibility === 'hidden';
239
- if (isHidden) {
240
- return false;
241
- }
242
- var hasBounds = !!(element.offsetWidth ||
243
- element.offsetHeight ||
244
- element.getClientRects().length);
245
- return hasBounds;
246
- };
247
- SkyCoreAdapterService.ctorParameters = function () { return [
248
- { type: RendererFactory2 }
249
- ]; };
250
- SkyCoreAdapterService.ɵprov = ɵɵdefineInjectable({ factory: function SkyCoreAdapterService_Factory() { return new SkyCoreAdapterService(ɵɵinject(RendererFactory2)); }, token: SkyCoreAdapterService, providedIn: "root" });
251
- SkyCoreAdapterService = __decorate([
252
- Injectable({
253
- providedIn: 'root'
254
- })
255
- ], SkyCoreAdapterService);
256
- return SkyCoreAdapterService;
257
- }());
258
-
259
- var SkyAffixAutoFitContext;
260
- (function (SkyAffixAutoFitContext) {
261
- /**
262
- * Auto-fit functionality will respect the nearest overflow parent element's dimensions.
263
- */
264
- SkyAffixAutoFitContext[SkyAffixAutoFitContext["OverflowParent"] = 0] = "OverflowParent";
265
- /**
266
- * Auto-fit functionality will respect the browser viewport dimensions.
267
- */
268
- SkyAffixAutoFitContext[SkyAffixAutoFitContext["Viewport"] = 1] = "Viewport";
269
- })(SkyAffixAutoFitContext || (SkyAffixAutoFitContext = {}));
270
-
271
- function getNextPlacement(placement) {
272
- var placements = [
273
- 'above',
274
- 'right',
275
- 'below',
276
- 'left'
277
- ];
278
- var index = placements.indexOf(placement) + 1;
279
- if (index >= placements.length) {
280
- index = 0;
281
- }
282
- return placements[index];
283
- }
284
- function getInversePlacement(placement) {
285
- var pairings = {
286
- above: 'below',
287
- below: 'above',
288
- right: 'left',
289
- left: 'right'
290
- };
291
- return pairings[placement];
292
- }
293
-
294
- /**
295
- * Returns the offset values of a given element.
296
- * @param element The HTML element.
297
- * @param bufferOffset An optional offset to add/subtract to the element's actual offset.
298
- */
299
- function getElementOffset(element, bufferOffset) {
300
- if (bufferOffset === void 0) { bufferOffset = {}; }
301
- var bufferOffsetBottom = bufferOffset.bottom || 0;
302
- var bufferOffsetLeft = bufferOffset.left || 0;
303
- var bufferOffsetRight = bufferOffset.right || 0;
304
- var bufferOffsetTop = bufferOffset.top || 0;
305
- var top;
306
- var left;
307
- var right;
308
- var bottom;
309
- if (element === document.body) {
310
- left = 0;
311
- top = 0;
312
- right = document.documentElement.clientWidth;
313
- bottom = document.documentElement.clientHeight;
314
- }
315
- else {
316
- var clientRect = element.getBoundingClientRect();
317
- left = clientRect.left;
318
- top = clientRect.top;
319
- right = clientRect.right;
320
- bottom = clientRect.bottom;
321
- }
322
- bottom -= bufferOffsetBottom;
323
- left += bufferOffsetLeft;
324
- right -= bufferOffsetRight;
325
- top += bufferOffsetTop;
326
- return {
327
- bottom: bottom,
328
- left: left,
329
- right: right,
330
- top: top
331
- };
332
- }
333
- function getOverflowParents(child) {
334
- var bodyElement = window.document.body;
335
- var results = [bodyElement];
336
- var parentElement = child.parentNode;
337
- while (parentElement !== undefined &&
338
- parentElement !== bodyElement &&
339
- parentElement instanceof HTMLElement) {
340
- var overflowY = window
341
- .getComputedStyle(parentElement, undefined)
342
- .overflowY
343
- .toLowerCase();
344
- if (overflowY === 'auto' ||
345
- overflowY === 'hidden' ||
346
- overflowY === 'scroll') {
347
- results.push(parentElement);
348
- }
349
- parentElement = parentElement.parentNode;
350
- }
351
- return results;
352
- }
353
- /**
354
- * Confirms offset is fully visible within a parent element.
355
- * @param parent
356
- * @param offset
357
- */
358
- function isOffsetFullyVisibleWithinParent(parent, offset, bufferOffset) {
359
- var parentOffset = getElementOffset(parent, bufferOffset);
360
- return !(parentOffset.top > offset.top ||
361
- parentOffset.right < offset.right ||
362
- parentOffset.bottom < offset.bottom ||
363
- parentOffset.left > offset.left);
364
- }
365
- function isOffsetPartiallyVisibleWithinParent(parent, offset, bufferOffset) {
366
- var parentOffset = getElementOffset(parent, bufferOffset);
367
- return !(parentOffset.top >= offset.bottom ||
368
- parentOffset.right <= offset.left ||
369
- parentOffset.bottom <= offset.top ||
370
- parentOffset.left >= offset.right);
371
- }
372
-
373
- var DEFAULT_AFFIX_CONFIG = {
374
- autoFitContext: SkyAffixAutoFitContext.OverflowParent,
375
- enableAutoFit: false,
376
- horizontalAlignment: 'center',
377
- isSticky: false,
378
- placement: 'above'
379
- };
380
- var SkyAffixer = /** @class */ (function () {
381
- function SkyAffixer(affixedElement, renderer) {
382
- this.affixedElement = affixedElement;
383
- this.renderer = renderer;
384
- this._offsetChange = new Subject();
385
- this._overflowScroll = new Subject();
386
- this._placementChange = new Subject();
387
- }
388
- Object.defineProperty(SkyAffixer.prototype, "offsetChange", {
389
- /**
390
- * Fires when the affixed element's offset changes.
391
- */
392
- get: function () {
393
- return this._offsetChange.asObservable();
394
- },
395
- enumerable: true,
396
- configurable: true
397
- });
398
- Object.defineProperty(SkyAffixer.prototype, "overflowScroll", {
399
- /**
400
- * Fires when the base element's nearest overflow parent is scrolling. This is useful if you need
401
- * to perform an additional action during the scroll event but don't want to generate another
402
- * event listener.
403
- */
404
- get: function () {
405
- return this._overflowScroll.asObservable();
406
- },
407
- enumerable: true,
408
- configurable: true
409
- });
410
- Object.defineProperty(SkyAffixer.prototype, "placementChange", {
411
- /**
412
- * Fires when the placement value changes. A `null` value indicates that a suitable
413
- * placement could not be found.
414
- */
415
- get: function () {
416
- return this._placementChange.asObservable();
417
- },
418
- enumerable: true,
419
- configurable: true
420
- });
421
- Object.defineProperty(SkyAffixer.prototype, "config", {
422
- get: function () {
423
- return this._config;
424
- },
425
- set: function (value) {
426
- var merged = __assign(__assign({}, DEFAULT_AFFIX_CONFIG), value);
427
- // Make sure none of the values are undefined.
428
- Object.keys(merged).forEach(function (k) {
429
- if (merged[k] === undefined) {
430
- merged[k] = DEFAULT_AFFIX_CONFIG[k];
431
- }
432
- });
433
- this._config = merged;
434
- },
435
- enumerable: true,
436
- configurable: true
437
- });
438
- /**
439
- * Affixes an element to a base element.
440
- * @param baseElement The base element.
441
- * @param config Configuration for the affix action.
442
- */
443
- SkyAffixer.prototype.affixTo = function (baseElement, config) {
444
- this.reset();
445
- this.config = config;
446
- this.baseElement = baseElement;
447
- this.overflowParents = getOverflowParents(baseElement);
448
- this.affix();
449
- if (this.config.isSticky) {
450
- this.addScrollListeners();
451
- this.addResizeListener();
452
- }
453
- };
454
- /**
455
- * Re-runs the affix calculation.
456
- */
457
- SkyAffixer.prototype.reaffix = function () {
458
- // Reset current placement to preferred placement.
459
- this.currentPlacement = this.config.placement;
460
- this.affix();
461
- };
462
- /**
463
- * Destroys the affixer.
464
- */
465
- SkyAffixer.prototype.destroy = function () {
466
- this.reset();
467
- this._placementChange.complete();
468
- this._offsetChange.complete();
469
- this._overflowScroll.complete();
470
- this._offsetChange =
471
- this._placementChange =
472
- this._overflowScroll = undefined;
473
- };
474
- SkyAffixer.prototype.affix = function () {
475
- this.baseRect = this.baseElement.getBoundingClientRect();
476
- this.affixedRect = this.affixedElement.getBoundingClientRect();
477
- var offset = this.getOffset();
478
- if (this.isNewOffset(offset)) {
479
- this.renderer.setStyle(this.affixedElement, 'top', offset.top + "px");
480
- this.renderer.setStyle(this.affixedElement, 'left', offset.left + "px");
481
- this._offsetChange.next({ offset: offset });
482
- }
483
- };
484
- SkyAffixer.prototype.getOffset = function () {
485
- var parent = this.getAutoFitContextParent();
486
- var maxAttempts = 4;
487
- var attempts = 0;
488
- var isAffixedElementFullyVisible = false;
489
- var offset;
490
- var placement = this.config.placement;
491
- do {
492
- offset = this.getPreferredOffset(placement);
493
- isAffixedElementFullyVisible = isOffsetFullyVisibleWithinParent(parent, offset, this.config.autoFitOverflowOffset);
494
- if (!this.config.enableAutoFit) {
495
- break;
496
- }
497
- if (!isAffixedElementFullyVisible) {
498
- placement = (attempts % 2 === 0)
499
- ? getInversePlacement(placement)
500
- : getNextPlacement(placement);
501
- }
502
- attempts++;
503
- } while (!isAffixedElementFullyVisible && attempts < maxAttempts);
504
- if (isAffixedElementFullyVisible) {
505
- if (this.isBaseElementVisible()) {
506
- this.notifyPlacementChange(placement);
507
- }
508
- else {
509
- /* tslint:disable-next-line:no-null-keyword */
510
- this.notifyPlacementChange(null);
511
- }
512
- return offset;
513
- }
514
- if (this.config.enableAutoFit) {
515
- /* tslint:disable-next-line:no-null-keyword */
516
- this.notifyPlacementChange(null);
517
- }
518
- // No suitable placement was found, so revert to preferred placement.
519
- return this.getPreferredOffset(this.config.placement);
520
- };
521
- SkyAffixer.prototype.getPreferredOffset = function (placement) {
522
- var affixedRect = this.affixedRect;
523
- var baseRect = this.baseRect;
524
- var horizontalAlignment = this.config.horizontalAlignment;
525
- var verticalAlignment = this.config.verticalAlignment;
526
- var enableAutoFit = this.config.enableAutoFit;
527
- var top;
528
- var left;
529
- if (placement === 'above' || placement === 'below') {
530
- if (placement === 'above') {
531
- top = baseRect.top - affixedRect.height;
532
- switch (verticalAlignment) {
533
- case 'top':
534
- top = top + affixedRect.height;
535
- break;
536
- case 'middle':
537
- top = top + (affixedRect.height / 2);
538
- break;
539
- case 'bottom':
540
- default:
541
- break;
542
- }
543
- }
544
- else {
545
- top = baseRect.bottom;
546
- switch (verticalAlignment) {
547
- case 'top':
548
- default:
549
- break;
550
- case 'middle':
551
- top = top - (affixedRect.height / 2);
552
- break;
553
- case 'bottom':
554
- top = top - affixedRect.height;
555
- break;
556
- }
557
- }
558
- switch (horizontalAlignment) {
559
- case 'left':
560
- left = baseRect.left;
561
- break;
562
- case 'center':
563
- default:
564
- left = baseRect.left + (baseRect.width / 2) - (affixedRect.width / 2);
565
- break;
566
- case 'right':
567
- left = baseRect.right - affixedRect.width;
568
- break;
569
- }
570
- }
571
- else {
572
- if (placement === 'left') {
573
- left = baseRect.left - affixedRect.width;
574
- }
575
- else {
576
- left = baseRect.right;
577
- }
578
- switch (verticalAlignment) {
579
- case 'top':
580
- top = baseRect.top;
581
- break;
582
- case 'middle':
583
- default:
584
- top = baseRect.top + (baseRect.height / 2) - (affixedRect.height / 2);
585
- break;
586
- case 'bottom':
587
- top = baseRect.bottom - affixedRect.height;
588
- break;
589
- }
590
- }
591
- var offset = { left: left, top: top };
592
- if (enableAutoFit) {
593
- offset = this.adjustOffsetToOverflowParent(__assign({}, offset), placement);
594
- }
595
- offset.bottom = offset.top + affixedRect.height;
596
- offset.right = offset.left + affixedRect.width;
597
- return offset;
598
- };
599
- /**
600
- * Slightly adjust the offset to fit within the scroll parent's boundaries if
601
- * the affixed element would otherwise be clipped.
602
- */
603
- SkyAffixer.prototype.adjustOffsetToOverflowParent = function (offset, placement) {
604
- var parent = this.getAutoFitContextParent();
605
- var parentOffset = getElementOffset(parent, this.config.autoFitOverflowOffset);
606
- var affixedRect = this.affixedRect;
607
- var baseRect = this.baseRect;
608
- // A pixel value representing the leeway between the edge of the overflow parent and the edge
609
- // of the base element before it dissapears from view.
610
- // If the visible portion of the base element is less than this pixel value, the auto-fit
611
- // functionality attempts to find another placement.
612
- var defaultPixelTolerance = 40;
613
- var pixelTolerance;
614
- var originalOffsetTop = offset.top;
615
- var originalOffsetLeft = offset.left;
616
- /* tslint:disable-next-line:switch-default */
617
- switch (placement) {
618
- case 'above':
619
- case 'below':
620
- // Keep the affixed element within the overflow parent.
621
- if (offset.left < parentOffset.left) {
622
- offset.left = parentOffset.left;
623
- }
624
- else if (offset.left + affixedRect.width > parentOffset.right) {
625
- offset.left = parentOffset.right - affixedRect.width;
626
- }
627
- // Use a smaller pixel tolerance if the base element width is less than the default.
628
- pixelTolerance = Math.min(defaultPixelTolerance, baseRect.width);
629
- // Make sure the affixed element never detaches from the base element.
630
- if (offset.left + pixelTolerance > baseRect.right ||
631
- offset.left + affixedRect.width - pixelTolerance < baseRect.left) {
632
- offset.left = originalOffsetLeft;
633
- }
634
- break;
635
- case 'left':
636
- case 'right':
637
- // Keep the affixed element within the overflow parent.
638
- if (offset.top < parentOffset.top) {
639
- offset.top = parentOffset.top;
640
- }
641
- else if (offset.top + affixedRect.height > parentOffset.bottom) {
642
- offset.top = parentOffset.bottom - affixedRect.height;
643
- }
644
- // Use a smaller pixel tolerance if the base element height is less than the default.
645
- pixelTolerance = Math.min(defaultPixelTolerance, baseRect.height);
646
- // Make sure the affixed element never detaches from the base element.
647
- if (offset.top + pixelTolerance > baseRect.bottom ||
648
- offset.top + affixedRect.height - pixelTolerance < baseRect.top) {
649
- offset.top = originalOffsetTop;
650
- }
651
- break;
652
- }
653
- return offset;
654
- };
655
- SkyAffixer.prototype.getImmediateOverflowParent = function () {
656
- return this.overflowParents[this.overflowParents.length - 1];
657
- };
658
- SkyAffixer.prototype.getAutoFitContextParent = function () {
659
- var bodyElement = this.overflowParents[0];
660
- return (this.config.autoFitContext === SkyAffixAutoFitContext.OverflowParent)
661
- ? this.getImmediateOverflowParent()
662
- : bodyElement;
663
- };
664
- SkyAffixer.prototype.notifyPlacementChange = function (placement) {
665
- if (this.currentPlacement !== placement) {
666
- this.currentPlacement = placement;
667
- this._placementChange.next({
668
- placement: placement
669
- });
670
- }
671
- };
672
- SkyAffixer.prototype.reset = function () {
673
- this.removeScrollListeners();
674
- this.removeResizeListener();
675
- this._config =
676
- this.affixedRect =
677
- this.baseElement =
678
- this.baseRect =
679
- this.currentPlacement =
680
- this.currentOffset =
681
- this.overflowParents = undefined;
682
- };
683
- SkyAffixer.prototype.isNewOffset = function (offset) {
684
- if (this.currentOffset === undefined) {
685
- this.currentOffset = offset;
686
- return true;
687
- }
688
- if (this.currentOffset.top === offset.top &&
689
- this.currentOffset.left === offset.left) {
690
- return false;
691
- }
692
- this.currentOffset = offset;
693
- return true;
694
- };
695
- SkyAffixer.prototype.isBaseElementVisible = function () {
696
- return isOffsetPartiallyVisibleWithinParent(this.getImmediateOverflowParent(), {
697
- top: this.baseRect.top,
698
- left: this.baseRect.left,
699
- right: this.baseRect.right,
700
- bottom: this.baseRect.bottom
701
- }, this.config.autoFitOverflowOffset);
702
- };
703
- SkyAffixer.prototype.addScrollListeners = function () {
704
- var _this = this;
705
- this.scrollListeners = this.overflowParents.map(function (parentElement) {
706
- var overflow = (parentElement === document.body) ? 'window' : parentElement;
707
- return _this.renderer.listen(overflow, 'scroll', function () {
708
- _this.affix();
709
- _this._overflowScroll.next();
710
- });
711
- });
712
- };
713
- SkyAffixer.prototype.addResizeListener = function () {
714
- var _this = this;
715
- this.resizeListener = fromEvent(window, 'resize')
716
- .subscribe(function () { return _this.affix(); });
717
- };
718
- SkyAffixer.prototype.removeResizeListener = function () {
719
- if (this.resizeListener) {
720
- this.resizeListener.unsubscribe();
721
- this.resizeListener = undefined;
722
- }
723
- };
724
- SkyAffixer.prototype.removeScrollListeners = function () {
725
- if (this.scrollListeners) {
726
- // Remove renderer-generated listeners by calling the listener itself.
727
- // https://github.com/angular/angular/issues/9368#issuecomment-227199778
728
- this.scrollListeners.forEach(function (listener) { return listener(); });
729
- this.scrollListeners = undefined;
730
- }
731
- };
732
- return SkyAffixer;
733
- }());
734
-
735
- var SkyAffixService = /** @class */ (function () {
736
- function SkyAffixService(rendererFactory) {
737
- this.renderer = rendererFactory.createRenderer(undefined, undefined);
738
- }
739
- /**
740
- * Creates an instance of [[SkyAffixer]].
741
- * @param affixed The element to be affixed.
742
- */
743
- SkyAffixService.prototype.createAffixer = function (affixed) {
744
- return new SkyAffixer(affixed.nativeElement, this.renderer);
745
- };
746
- SkyAffixService.ctorParameters = function () { return [
747
- { type: RendererFactory2 }
748
- ]; };
749
- SkyAffixService.ɵprov = ɵɵdefineInjectable({ factory: function SkyAffixService_Factory() { return new SkyAffixService(ɵɵinject(RendererFactory2)); }, token: SkyAffixService, providedIn: "root" });
750
- SkyAffixService = __decorate([
751
- Injectable({
752
- providedIn: 'root'
753
- })
754
- ], SkyAffixService);
755
- return SkyAffixService;
756
- }());
757
-
758
- /**
759
- * Affixes the host element to a base element.
760
- */
761
- var SkyAffixDirective = /** @class */ (function () {
762
- function SkyAffixDirective(elementRef, affixService) {
763
- var _this = this;
764
- this.affixService = affixService;
765
- /**
766
- * Fires when the affixed element's offset changes.
767
- */
768
- this.affixOffsetChange = new EventEmitter();
769
- /**
770
- * Fires when the affixed element's overflow container is scrolled.
771
- */
772
- this.affixOverflowScroll = new EventEmitter();
773
- /**
774
- * Fires when the placement value changes.
775
- */
776
- this.affixPlacementChange = new EventEmitter();
777
- this.ngUnsubscribe = new Subject();
778
- this.affixer = this.affixService.createAffixer(elementRef);
779
- this.affixer.offsetChange
780
- .pipe(takeUntil(this.ngUnsubscribe))
781
- .subscribe(function (change) { return _this.affixOffsetChange.emit(change); });
782
- this.affixer.overflowScroll
783
- .pipe(takeUntil(this.ngUnsubscribe))
784
- .subscribe(function (change) { return _this.affixOverflowScroll.emit(change); });
785
- this.affixer.placementChange
786
- .pipe(takeUntil(this.ngUnsubscribe))
787
- .subscribe(function (change) { return _this.affixPlacementChange.emit(change); });
788
- }
789
- SkyAffixDirective.prototype.ngOnChanges = function (changes) {
790
- /* istanbul ignore else */
791
- if (changes.affixAutoFitContext ||
792
- changes.affixAutoFitOverflowOffset ||
793
- changes.affixEnableAutoFit ||
794
- changes.affixHorizontalAlignment ||
795
- changes.affixIsSticky ||
796
- changes.affixPlacement ||
797
- changes.affixVerticalAlignment) {
798
- this.updateAlignment();
799
- }
800
- };
801
- SkyAffixDirective.prototype.ngOnDestroy = function () {
802
- this.affixOffsetChange.complete();
803
- this.affixOverflowScroll.complete();
804
- this.affixPlacementChange.complete();
805
- this.ngUnsubscribe.next();
806
- this.ngUnsubscribe.complete();
807
- this.affixer.destroy();
808
- };
809
- SkyAffixDirective.prototype.updateAlignment = function () {
810
- this.affixer.affixTo(this.skyAffixTo, {
811
- autoFitContext: this.affixAutoFitContext,
812
- autoFitOverflowOffset: this.affixAutoFitOverflowOffset,
813
- enableAutoFit: this.affixEnableAutoFit,
814
- horizontalAlignment: this.affixHorizontalAlignment,
815
- isSticky: this.affixIsSticky,
816
- placement: this.affixPlacement,
817
- verticalAlignment: this.affixVerticalAlignment
818
- });
819
- };
820
- SkyAffixDirective.ctorParameters = function () { return [
821
- { type: ElementRef },
822
- { type: SkyAffixService }
823
- ]; };
824
- __decorate([
825
- Input()
826
- ], SkyAffixDirective.prototype, "skyAffixTo", void 0);
827
- __decorate([
828
- Input()
829
- ], SkyAffixDirective.prototype, "affixAutoFitContext", void 0);
830
- __decorate([
831
- Input()
832
- ], SkyAffixDirective.prototype, "affixAutoFitOverflowOffset", void 0);
833
- __decorate([
834
- Input()
835
- ], SkyAffixDirective.prototype, "affixEnableAutoFit", void 0);
836
- __decorate([
837
- Input()
838
- ], SkyAffixDirective.prototype, "affixHorizontalAlignment", void 0);
839
- __decorate([
840
- Input()
841
- ], SkyAffixDirective.prototype, "affixIsSticky", void 0);
842
- __decorate([
843
- Input()
844
- ], SkyAffixDirective.prototype, "affixPlacement", void 0);
845
- __decorate([
846
- Input()
847
- ], SkyAffixDirective.prototype, "affixVerticalAlignment", void 0);
848
- __decorate([
849
- Output()
850
- ], SkyAffixDirective.prototype, "affixOffsetChange", void 0);
851
- __decorate([
852
- Output()
853
- ], SkyAffixDirective.prototype, "affixOverflowScroll", void 0);
854
- __decorate([
855
- Output()
856
- ], SkyAffixDirective.prototype, "affixPlacementChange", void 0);
857
- SkyAffixDirective = __decorate([
858
- Directive({
859
- selector: '[skyAffixTo]'
860
- })
861
- ], SkyAffixDirective);
862
- return SkyAffixDirective;
863
- }());
864
-
865
- var SkyAffixModule = /** @class */ (function () {
866
- function SkyAffixModule() {
867
- }
868
- SkyAffixModule = __decorate([
869
- NgModule({
870
- imports: [
871
- CommonModule
872
- ],
873
- exports: [
874
- SkyAffixDirective
875
- ],
876
- declarations: [
877
- SkyAffixDirective
878
- ]
879
- })
880
- ], SkyAffixModule);
881
- return SkyAffixModule;
882
- }());
883
-
884
- /**
885
- * Represents a single item added to the dock.
886
- */
887
- var SkyDockItem = /** @class */ (function () {
888
- /**
889
- * @param componentInstance The item's component instance.
890
- * @param stackOrder The assigned stack order of the docked item.
891
- */
892
- function SkyDockItem(componentInstance, stackOrder) {
893
- this.componentInstance = componentInstance;
894
- this.stackOrder = stackOrder;
895
- this._destroyed = new Subject();
896
- }
897
- Object.defineProperty(SkyDockItem.prototype, "destroyed", {
898
- /**
899
- * An event that emits when the item is removed from the dock.
900
- */
901
- get: function () {
902
- return this._destroyed.asObservable();
903
- },
904
- enumerable: true,
905
- configurable: true
906
- });
907
- /**
908
- * Removes the item from the dock.
909
- */
910
- SkyDockItem.prototype.destroy = function () {
911
- this._destroyed.next();
912
- this._destroyed.complete();
913
- };
914
- return SkyDockItem;
915
- }());
916
-
917
- var MutationObserverService = /** @class */ (function () {
918
- function MutationObserverService() {
919
- }
920
- MutationObserverService.prototype.create = function (callback) {
921
- return new MutationObserver(callback);
922
- };
923
- MutationObserverService.ɵprov = ɵɵdefineInjectable({ factory: function MutationObserverService_Factory() { return new MutationObserverService(); }, token: MutationObserverService, providedIn: "root" });
924
- MutationObserverService = __decorate([
925
- Injectable({
926
- providedIn: 'root'
927
- })
928
- ], MutationObserverService);
929
- return MutationObserverService;
930
- }());
931
-
932
- /**
933
- * @internal
934
- */
935
- var SkyDockDomAdapterService = /** @class */ (function () {
936
- function SkyDockDomAdapterService(mutationService, rendererFactory) {
937
- this.mutationService = mutationService;
938
- this.ngUnsubscribe = new Subject();
939
- this.renderer = rendererFactory.createRenderer(undefined, undefined);
940
- }
941
- SkyDockDomAdapterService.prototype.ngOnDestroy = function () {
942
- this.observer.disconnect();
943
- this.ngUnsubscribe.next();
944
- if (this.styleElement) {
945
- this.destroyStyleElement();
946
- }
947
- this.currentDockHeight =
948
- this.ngUnsubscribe =
949
- this.observer =
950
- this.styleElement = undefined;
951
- };
952
- SkyDockDomAdapterService.prototype.watchDomChanges = function (elementRef) {
953
- var _this = this;
954
- this.observer = this.mutationService.create(function () {
955
- _this.adjustBodyStyles(elementRef);
956
- });
957
- this.observer.observe(elementRef.nativeElement, {
958
- attributes: true,
959
- childList: true,
960
- characterData: true,
961
- subtree: true
962
- });
963
- fromEvent(window, 'resize')
964
- .pipe(debounceTime(250), takeUntil(this.ngUnsubscribe))
965
- .subscribe(function () { return _this.adjustBodyStyles(elementRef); });
966
- };
967
- SkyDockDomAdapterService.prototype.adjustBodyStyles = function (elementRef) {
968
- var dockHeight = elementRef.nativeElement.getBoundingClientRect().height;
969
- if (dockHeight === this.currentDockHeight) {
970
- return;
971
- }
972
- // Create a style element to avoid overwriting any existing inline body styles.
973
- var styleElement = this.renderer.createElement('style');
974
- var textNode = this.renderer.createText("body { margin-bottom: " + dockHeight + "px; }");
975
- // Apply a `data-` attribute to make unit testing easier.
976
- this.renderer.setAttribute(styleElement, 'data-test-selector', 'sky-layout-dock-bottom-styles');
977
- this.renderer.appendChild(styleElement, textNode);
978
- this.renderer.appendChild(document.head, styleElement);
979
- if (this.styleElement) {
980
- this.destroyStyleElement();
981
- }
982
- this.currentDockHeight = dockHeight;
983
- this.styleElement = styleElement;
984
- };
985
- SkyDockDomAdapterService.prototype.destroyStyleElement = function () {
986
- this.renderer.removeChild(document.head, this.styleElement);
987
- };
988
- SkyDockDomAdapterService.ctorParameters = function () { return [
989
- { type: MutationObserverService },
990
- { type: RendererFactory2 }
991
- ]; };
992
- SkyDockDomAdapterService = __decorate([
993
- Injectable()
994
- ], SkyDockDomAdapterService);
995
- return SkyDockDomAdapterService;
996
- }());
997
-
998
- /**
999
- * @internal
1000
- */
1001
- function sortByStackOrder(a, b) {
1002
- if (a.stackOrder > b.stackOrder) {
1003
- return -1;
1004
- }
1005
- if (a.stackOrder < b.stackOrder) {
1006
- return 1;
1007
- }
1008
- return 0;
1009
- }
1010
-
1011
- /**
1012
- * @internal
1013
- */
1014
- var SkyDockComponent = /** @class */ (function () {
1015
- function SkyDockComponent(changeDetector, resolver, elementRef, injector, domAdapter) {
1016
- this.changeDetector = changeDetector;
1017
- this.resolver = resolver;
1018
- this.elementRef = elementRef;
1019
- this.injector = injector;
1020
- this.domAdapter = domAdapter;
1021
- this.itemRefs = [];
1022
- }
1023
- SkyDockComponent.prototype.ngOnInit = function () {
1024
- this.domAdapter.watchDomChanges(this.elementRef);
1025
- };
1026
- SkyDockComponent.prototype.insertComponent = function (component, config) {
1027
- if (config === void 0) { config = {}; }
1028
- var factory = this.resolver.resolveComponentFactory(component);
1029
- var injector = Injector.create({
1030
- providers: config.providers || [],
1031
- parent: this.injector
1032
- });
1033
- var componentRef = this.target.createComponent(factory, undefined, injector);
1034
- var stackOrder = (config.stackOrder !== null && config.stackOrder !== undefined)
1035
- ? config.stackOrder
1036
- : this.getHighestStackOrder();
1037
- this.itemRefs.push({
1038
- componentRef: componentRef,
1039
- stackOrder: stackOrder
1040
- });
1041
- this.sortItemsByStackOrder();
1042
- this.changeDetector.markForCheck();
1043
- return {
1044
- componentRef: componentRef,
1045
- stackOrder: stackOrder
1046
- };
1047
- };
1048
- SkyDockComponent.prototype.removeItem = function (item) {
1049
- var viewRef = item.componentRef.hostView;
1050
- this.target.remove(this.target.indexOf(viewRef));
1051
- var found = this.itemRefs.find(function (i) { return i.componentRef.hostView === viewRef; });
1052
- this.itemRefs.splice(this.itemRefs.indexOf(found), 1);
1053
- };
1054
- SkyDockComponent.prototype.sortItemsByStackOrder = function () {
1055
- var _this = this;
1056
- this.itemRefs.sort(sortByStackOrder);
1057
- // Reassign the correct index for each view.
1058
- this.itemRefs.forEach(function (item, i) { return _this.target.move(item.componentRef.hostView, i); });
1059
- };
1060
- SkyDockComponent.prototype.getHighestStackOrder = function () {
1061
- if (this.itemRefs.length === 0) {
1062
- return 0;
1063
- }
1064
- return this.itemRefs[0].stackOrder + 1;
1065
- };
1066
- SkyDockComponent.ctorParameters = function () { return [
1067
- { type: ChangeDetectorRef },
1068
- { type: ComponentFactoryResolver },
1069
- { type: ElementRef },
1070
- { type: Injector },
1071
- { type: SkyDockDomAdapterService }
1072
- ]; };
1073
- __decorate([
1074
- ViewChild('target', {
1075
- read: ViewContainerRef,
1076
- static: true
1077
- })
1078
- ], SkyDockComponent.prototype, "target", void 0);
1079
- SkyDockComponent = __decorate([
1080
- Component({
1081
- selector: 'sky-dock',
1082
- template: "<ng-container\n #target\n></ng-container>",
1083
- providers: [
1084
- SkyDockDomAdapterService
1085
- ],
1086
- changeDetection: ChangeDetectionStrategy.OnPush,
1087
- styles: [":host{position:fixed;left:0;bottom:0;right:0;display:flex;flex-direction:column;width:100%}"]
1088
- })
1089
- ], SkyDockComponent);
1090
- return SkyDockComponent;
1091
- }());
1092
-
1093
- var SkyDockModule = /** @class */ (function () {
1094
- function SkyDockModule() {
1095
- }
1096
- SkyDockModule = __decorate([
1097
- NgModule({
1098
- imports: [
1099
- CommonModule
1100
- ],
1101
- declarations: [
1102
- SkyDockComponent
1103
- ],
1104
- entryComponents: [
1105
- SkyDockComponent
1106
- ]
1107
- })
1108
- ], SkyDockModule);
1109
- return SkyDockModule;
1110
- }());
1111
-
1112
- /**
1113
- * @internal
1114
- */
1115
- function getWindow() {
1116
- return window;
1117
- }
1118
- /**
1119
- * The application window reference service references the global window variable.
1120
- * After users inject SkyAppWindowRef into a component, they can use the service to interact with
1121
- * window properties and event handlers by referencing its nativeWindow property.
1122
- */
1123
- var SkyAppWindowRef = /** @class */ (function () {
1124
- function SkyAppWindowRef() {
1125
- }
1126
- Object.defineProperty(SkyAppWindowRef.prototype, "nativeWindow", {
1127
- /**
1128
- * References the global `window` variable.
1129
- */
1130
- get: function () {
1131
- return getWindow();
1132
- },
1133
- enumerable: true,
1134
- configurable: true
1135
- });
1136
- SkyAppWindowRef.ɵprov = ɵɵdefineInjectable({ factory: function SkyAppWindowRef_Factory() { return new SkyAppWindowRef(); }, token: SkyAppWindowRef, providedIn: "root" });
1137
- SkyAppWindowRef = __decorate([
1138
- Injectable({
1139
- providedIn: 'root'
1140
- })
1141
- ], SkyAppWindowRef);
1142
- return SkyAppWindowRef;
1143
- }());
1144
-
1145
- /**
1146
- * The location on the page where the dynamic component should be rendered.
1147
- */
1148
- var SkyDynamicComponentLocation;
1149
- (function (SkyDynamicComponentLocation) {
1150
- /**
1151
- * Renders the dynamic component as the last element inside the BODY element.
1152
- */
1153
- SkyDynamicComponentLocation[SkyDynamicComponentLocation["BodyBottom"] = 0] = "BodyBottom";
1154
- /**
1155
- * Renders the dynamic component as the first element inside the BODY element.
1156
- */
1157
- SkyDynamicComponentLocation[SkyDynamicComponentLocation["BodyTop"] = 1] = "BodyTop";
1158
- })(SkyDynamicComponentLocation || (SkyDynamicComponentLocation = {}));
1159
-
1160
- /**
1161
- * Angular service for creating and rendering a dynamic component.
1162
- */
1163
- var SkyDynamicComponentService = /** @class */ (function () {
1164
- function SkyDynamicComponentService(componentFactoryResolver, applicationRef, injector, windowRef, rendererFactory) {
1165
- this.componentFactoryResolver = componentFactoryResolver;
1166
- this.applicationRef = applicationRef;
1167
- this.injector = injector;
1168
- this.windowRef = windowRef;
1169
- // Based on suggestions from https://github.com/angular/angular/issues/17824
1170
- // for accessing an instance of Renderer2 in a service since Renderer2 can't
1171
- // be injected into a service. Passing undefined for both parameters results
1172
- // in the default renderer which is what we want here.
1173
- this.renderer = rendererFactory.createRenderer(undefined, undefined);
1174
- }
1175
- /**
1176
- * Creates an instance of the specified component and adds it to the specified location
1177
- * on the page.
1178
- * @param options Options for creating the dynamic component.
1179
- */
1180
- SkyDynamicComponentService.prototype.createComponent = function (componentType, options) {
1181
- options = options || {
1182
- location: SkyDynamicComponentLocation.BodyBottom
1183
- };
1184
- var componentRef = this.componentFactoryResolver
1185
- .resolveComponentFactory(componentType)
1186
- .create(this.injector);
1187
- this.applicationRef.attachView(componentRef.hostView);
1188
- var el = this.getRootNode(componentRef);
1189
- var bodyEl = this.windowRef.nativeWindow.document.body;
1190
- switch (options.location) {
1191
- case SkyDynamicComponentLocation.BodyTop:
1192
- this.renderer.insertBefore(bodyEl, el, bodyEl.firstChild);
1193
- break;
1194
- default:
1195
- this.renderer.appendChild(bodyEl, el);
1196
- break;
1197
- }
1198
- return componentRef;
1199
- };
1200
- /**
1201
- * Removes a component ref from the page
1202
- * @param componentRef Component ref for the component being removed
1203
- */
1204
- SkyDynamicComponentService.prototype.removeComponent = function (componentRef) {
1205
- if (!componentRef) {
1206
- return;
1207
- }
1208
- this.applicationRef.detachView(componentRef.hostView);
1209
- componentRef.destroy();
1210
- };
1211
- SkyDynamicComponentService.prototype.getRootNode = function (componentRef) {
1212
- // Technique for retrieving the component's root node taken from here:
1213
- // https://malcoded.com/posts/angular-dynamic-components
1214
- return componentRef.hostView.rootNodes[0];
1215
- };
1216
- SkyDynamicComponentService.ctorParameters = function () { return [
1217
- { type: ComponentFactoryResolver },
1218
- { type: ApplicationRef },
1219
- { type: Injector },
1220
- { type: SkyAppWindowRef },
1221
- { type: RendererFactory2 }
1222
- ]; };
1223
- SkyDynamicComponentService.ɵprov = ɵɵdefineInjectable({ factory: function SkyDynamicComponentService_Factory() { return new SkyDynamicComponentService(ɵɵinject(ComponentFactoryResolver), ɵɵinject(ApplicationRef), ɵɵinject(INJECTOR), ɵɵinject(SkyAppWindowRef), ɵɵinject(RendererFactory2)); }, token: SkyDynamicComponentService, providedIn: "any" });
1224
- SkyDynamicComponentService = __decorate([
1225
- Injectable({
1226
- // Must be 'any' so that the component is created in the context of its module's injector.
1227
- // If set to 'root', the component's dependency injections would only be derived from the root
1228
- // injector and may loose context if the component is created within a lazy-loaded module.
1229
- providedIn: 'any'
1230
- })
1231
- ], SkyDynamicComponentService);
1232
- return SkyDynamicComponentService;
1233
- }());
1234
-
1235
- /**
1236
- * This service docks components to specific areas on the page.
1237
- */
1238
- var SkyDockService = /** @class */ (function () {
1239
- function SkyDockService(dynamicComponentService) {
1240
- this.dynamicComponentService = dynamicComponentService;
1241
- this._items = [];
1242
- }
1243
- Object.defineProperty(SkyDockService.prototype, "items", {
1244
- /**
1245
- * Returns all docked items.
1246
- */
1247
- get: function () {
1248
- return this._items;
1249
- },
1250
- enumerable: true,
1251
- configurable: true
1252
- });
1253
- /**
1254
- * Docks a component to the bottom of the page.
1255
- * @param component The component to dock.
1256
- * @param config Options that affect the docking action.
1257
- */
1258
- SkyDockService.prototype.insertComponent = function (component, config) {
1259
- var _this = this;
1260
- if (!this.dockRef) {
1261
- this.createDock();
1262
- }
1263
- var itemRef = this.dockRef.instance.insertComponent(component, config);
1264
- var item = new SkyDockItem(itemRef.componentRef.instance, itemRef.stackOrder);
1265
- item.destroyed.subscribe(function () {
1266
- _this.dockRef.instance.removeItem(itemRef);
1267
- _this._items.splice(_this._items.indexOf(item), 1);
1268
- if (_this._items.length === 0) {
1269
- _this.destroyDock();
1270
- }
1271
- });
1272
- this._items.push(item);
1273
- this._items.sort(sortByStackOrder);
1274
- return item;
1275
- };
1276
- SkyDockService.prototype.createDock = function () {
1277
- this.dockRef = this.dynamicComponentService.createComponent(SkyDockComponent);
1278
- };
1279
- SkyDockService.prototype.destroyDock = function () {
1280
- this.dynamicComponentService.removeComponent(this.dockRef);
1281
- this.dockRef = undefined;
1282
- };
1283
- SkyDockService.ctorParameters = function () { return [
1284
- { type: SkyDynamicComponentService }
1285
- ]; };
1286
- SkyDockService.ɵprov = ɵɵdefineInjectable({ factory: function SkyDockService_Factory() { return new SkyDockService(ɵɵinject(SkyDynamicComponentService)); }, token: SkyDockService, providedIn: "root" });
1287
- SkyDockService = __decorate([
1288
- Injectable({
1289
- providedIn: 'root'
1290
- })
1291
- ], SkyDockService);
1292
- return SkyDockService;
1293
- }());
1294
-
1295
- /**
1296
- * Provides services required to create dynamic components on the page.
1297
- * @deprecated The `SkyDynamicComponentService` no longer needs the `SkyDynamicComponentModule`.
1298
- * The `SkyDynamicComponentModule` can be removed from your project.
1299
- */
1300
- var SkyDynamicComponentModule = /** @class */ (function () {
1301
- function SkyDynamicComponentModule() {
1302
- }
1303
- SkyDynamicComponentModule = __decorate([
1304
- NgModule({})
1305
- ], SkyDynamicComponentModule);
1306
- return SkyDynamicComponentModule;
1307
- }());
1308
-
1309
- var SkyAppFormat = /** @class */ (function () {
1310
- function SkyAppFormat() {
1311
- }
1312
- SkyAppFormat.prototype.formatText = function (format) {
1313
- var args = [];
1314
- for (var _i = 1; _i < arguments.length; _i++) {
1315
- args[_i - 1] = arguments[_i];
1316
- }
1317
- return String(format).replace(/\{(\d+)\}/g, function (match, capture) {
1318
- return args[parseInt(capture, 10)];
1319
- });
1320
- };
1321
- SkyAppFormat.ɵprov = ɵɵdefineInjectable({ factory: function SkyAppFormat_Factory() { return new SkyAppFormat(); }, token: SkyAppFormat, providedIn: "root" });
1322
- SkyAppFormat = __decorate([
1323
- Injectable({
1324
- providedIn: 'root'
1325
- })
1326
- ], SkyAppFormat);
1327
- return SkyAppFormat;
1328
- }());
1329
-
1330
- var idIndex = 0;
1331
- function generateId() {
1332
- idIndex++;
1333
- return "sky-id-gen__" + idIndex;
1334
- }
1335
- /**
1336
- * Sets the element's `id` attribute to a unique ID. To reference this unique ID on other elements,
1337
- * such as in a `label` element's `for` attribute, assign this directive to a template reference
1338
- * variable, then use its `id` property.
1339
- */
1340
- var SkyIdDirective = /** @class */ (function () {
1341
- function SkyIdDirective(elRef, renderer) {
1342
- // Generate and apply the ID before the template is rendered
1343
- // to avoid a changed-after-checked error.
1344
- var id = generateId();
1345
- renderer.setAttribute(elRef.nativeElement, 'id', id);
1346
- this._id = id;
1347
- }
1348
- Object.defineProperty(SkyIdDirective.prototype, "id", {
1349
- get: function () {
1350
- return this._id;
1351
- },
1352
- enumerable: true,
1353
- configurable: true
1354
- });
1355
- SkyIdDirective.ctorParameters = function () { return [
1356
- { type: ElementRef },
1357
- { type: Renderer2 }
1358
- ]; };
1359
- SkyIdDirective = __decorate([
1360
- Directive({
1361
- selector: '[skyId]',
1362
- exportAs: 'skyId'
1363
- })
1364
- ], SkyIdDirective);
1365
- return SkyIdDirective;
1366
- }());
1367
-
1368
- var SkyIdModule = /** @class */ (function () {
1369
- function SkyIdModule() {
1370
- }
1371
- SkyIdModule = __decorate([
1372
- NgModule({
1373
- declarations: [
1374
- SkyIdDirective
1375
- ],
1376
- exports: [
1377
- SkyIdDirective
1378
- ]
1379
- })
1380
- ], SkyIdModule);
1381
- return SkyIdModule;
1382
- }());
1383
-
1384
- /**
1385
- * @deprecated The `SkyLogService` no longer needs the `SkyLogModule`.
1386
- * The `SkyLogModule` can be removed from your project.
1387
- */
1388
- var SkyLogModule = /** @class */ (function () {
1389
- function SkyLogModule() {
1390
- }
1391
- SkyLogModule = __decorate([
1392
- NgModule({})
1393
- ], SkyLogModule);
1394
- return SkyLogModule;
1395
- }());
1396
-
1397
- /**
1398
- * @deprecated The `SkyLogService` will be removed in the next major version of `@skyux/core`.
1399
- */
1400
- var SkyLogService = /** @class */ (function () {
1401
- function SkyLogService() {
1402
- }
1403
- SkyLogService.prototype.warn = function (message) {
1404
- var optionalParams = [];
1405
- for (var _i = 1; _i < arguments.length; _i++) {
1406
- optionalParams[_i - 1] = arguments[_i];
1407
- }
1408
- /*istanbul ignore else */
1409
- if (window.console) {
1410
- window.console.warn.apply(window.console, arguments);
1411
- }
1412
- };
1413
- SkyLogService.ɵprov = ɵɵdefineInjectable({ factory: function SkyLogService_Factory() { return new SkyLogService(); }, token: SkyLogService, providedIn: "root" });
1414
- SkyLogService = __decorate([
1415
- Injectable({
1416
- providedIn: 'root'
1417
- })
1418
- ], SkyLogService);
1419
- return SkyLogService;
1420
- }());
1421
-
1422
- /**
1423
- * @deprecated The `SkyMediaQueryService` no longer needs the `SkyMediaQueryModule`.
1424
- * The `SkyMediaQueryModule` can be removed from your project.
1425
- */
1426
- var SkyMediaQueryModule = /** @class */ (function () {
1427
- function SkyMediaQueryModule() {
1428
- }
1429
- SkyMediaQueryModule = __decorate([
1430
- NgModule({})
1431
- ], SkyMediaQueryModule);
1432
- return SkyMediaQueryModule;
1433
- }());
1434
-
1435
- var SkyMediaQueryService = /** @class */ (function () {
1436
- function SkyMediaQueryService(zone) {
1437
- this.zone = zone;
1438
- this.currentSubject = new BehaviorSubject(this.current);
1439
- this._current = SkyMediaBreakpoints.md;
1440
- this.breakpoints = [
1441
- {
1442
- mediaQueryString: SkyMediaQueryService_1.xs,
1443
- name: SkyMediaBreakpoints.xs
1444
- },
1445
- {
1446
- mediaQueryString: SkyMediaQueryService_1.sm,
1447
- name: SkyMediaBreakpoints.sm
1448
- },
1449
- {
1450
- mediaQueryString: SkyMediaQueryService_1.md,
1451
- name: SkyMediaBreakpoints.md
1452
- },
1453
- {
1454
- mediaQueryString: SkyMediaQueryService_1.lg,
1455
- name: SkyMediaBreakpoints.lg
1456
- }
1457
- ];
1458
- this.mediaQueries = [];
1459
- this.addListeners();
1460
- }
1461
- SkyMediaQueryService_1 = SkyMediaQueryService;
1462
- Object.defineProperty(SkyMediaQueryService.prototype, "current", {
1463
- /**
1464
- * Returns the current breakpoint.
1465
- */
1466
- get: function () {
1467
- return this._current;
1468
- },
1469
- enumerable: true,
1470
- configurable: true
1471
- });
1472
- SkyMediaQueryService.prototype.ngOnDestroy = function () {
1473
- this.removeListeners();
1474
- this.currentSubject.complete();
1475
- };
1476
- /**
1477
- * Suscribes to screen size changes.
1478
- * @param listener Specifies a function that is called when breakpoints change.
1479
- */
1480
- SkyMediaQueryService.prototype.subscribe = function (listener) {
1481
- return this.currentSubject.subscribe({
1482
- next: function (breakpoints) {
1483
- listener(breakpoints);
1484
- }
1485
- });
1486
- };
1487
- /**
1488
- * @internal
1489
- */
1490
- SkyMediaQueryService.prototype.destroy = function () {
1491
- this.removeListeners();
1492
- this.currentSubject.complete();
1493
- };
1494
- SkyMediaQueryService.prototype.addListeners = function () {
1495
- var _this = this;
1496
- this.mediaQueries = this.breakpoints.map(function (breakpoint) {
1497
- var mq = matchMedia(breakpoint.mediaQueryString);
1498
- var listener = function (event) {
1499
- // Run the check outside of Angular's change detection since Angular
1500
- // does not wrap matchMedia listeners in NgZone.
1501
- // See: https://blog.assaf.co/angular-2-change-detection-zones-and-an-example/
1502
- _this.zone.run(function () {
1503
- if (event.matches) {
1504
- _this.notifyBreakpointChange(breakpoint.name);
1505
- }
1506
- });
1507
- };
1508
- mq.addListener(listener);
1509
- if (mq.matches) {
1510
- _this.notifyBreakpointChange(breakpoint.name);
1511
- }
1512
- return {
1513
- mediaQueryList: mq,
1514
- listener: listener
1515
- };
1516
- });
1517
- };
1518
- SkyMediaQueryService.prototype.removeListeners = function () {
1519
- this.mediaQueries.forEach(function (mediaQuery) {
1520
- mediaQuery.mediaQueryList.removeListener(mediaQuery.listener);
1521
- });
1522
- this.mediaQueries = [];
1523
- };
1524
- SkyMediaQueryService.prototype.notifyBreakpointChange = function (breakpoint) {
1525
- this._current = breakpoint;
1526
- this.currentSubject.next(breakpoint);
1527
- };
1528
- var SkyMediaQueryService_1;
1529
- /**
1530
- * The size for the `xs` breakpoint.
1531
- */
1532
- SkyMediaQueryService.xs = '(max-width: 767px)';
1533
- /**
1534
- * The size for the `sm` breakpoint.
1535
- */
1536
- SkyMediaQueryService.sm = '(min-width: 768px) and (max-width: 991px)';
1537
- /**
1538
- * The size for the `md` breakpoint.
1539
- */
1540
- SkyMediaQueryService.md = '(min-width: 992px) and (max-width: 1199px)';
1541
- /**
1542
- * The size for the `lg` breakpoint.
1543
- */
1544
- SkyMediaQueryService.lg = '(min-width: 1200px)';
1545
- SkyMediaQueryService.ctorParameters = function () { return [
1546
- { type: NgZone }
1547
- ]; };
1548
- SkyMediaQueryService.ɵprov = ɵɵdefineInjectable({ factory: function SkyMediaQueryService_Factory() { return new SkyMediaQueryService(ɵɵinject(NgZone)); }, token: SkyMediaQueryService, providedIn: "root" });
1549
- SkyMediaQueryService = SkyMediaQueryService_1 = __decorate([
1550
- Injectable({
1551
- providedIn: 'root'
1552
- })
1553
- ], SkyMediaQueryService);
1554
- return SkyMediaQueryService;
1555
- }());
1556
-
1557
- var SkyCoreResourcesProvider = /** @class */ (function () {
1558
- function SkyCoreResourcesProvider() {
1559
- this.resources = { "EN-US": { "skyux_numeric_billions_symbol": "B", "skyux_numeric_millions_symbol": "M", "skyux_numeric_thousands_symbol": "K", "skyux_numeric_trillions_symbol": "T" } };
1560
- }
1561
- SkyCoreResourcesProvider.prototype.getString = function (localeInfo, name) {
1562
- return getStringForLocale(this.resources, localeInfo.locale, name);
1563
- };
1564
- SkyCoreResourcesProvider = __decorate([
1565
- Injectable()
1566
- ], SkyCoreResourcesProvider);
1567
- return SkyCoreResourcesProvider;
1568
- }());
1569
-
1570
- var SkyCoreResourcesModule = /** @class */ (function () {
1571
- function SkyCoreResourcesModule() {
1572
- }
1573
- SkyCoreResourcesModule = __decorate([
1574
- NgModule({
1575
- providers: [{
1576
- provide: SKY_LIB_RESOURCES_PROVIDERS,
1577
- useClass: SkyCoreResourcesProvider,
1578
- multi: true
1579
- }]
1580
- })
1581
- ], SkyCoreResourcesModule);
1582
- return SkyCoreResourcesModule;
1583
- }());
1584
-
1585
- /* tslint:disable:no-null-keyword */
1586
- function isNumeric(value) {
1587
- return !isNaN(value - parseFloat(value));
1588
- }
1589
- function parseIntAutoRadix(text) {
1590
- var result = parseInt(text, 10);
1591
- /* istanbul ignore next */
1592
- if (isNaN(result)) {
1593
- throw new Error('Invalid integer literal when parsing ' + text);
1594
- }
1595
- return result;
1596
- }
1597
- // Need to add the following to classes which contain static methods.
1598
- // See: https://github.com/ng-packagr/ng-packagr/issues/641
1599
- // @dynamic
1600
- var SkyNumberFormatUtility = /** @class */ (function () {
1601
- /* istanbul ignore next */
1602
- function SkyNumberFormatUtility() {
1603
- }
1604
- SkyNumberFormatUtility.formatNumber = function (locale, value, style, digits, currency, currencyAsSymbol) {
1605
- if (currency === void 0) { currency = null; }
1606
- if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
1607
- if (value == null) {
1608
- return null;
1609
- }
1610
- // Convert strings to numbers
1611
- value = typeof value === 'string' && isNumeric(value) ? +value : value;
1612
- if (typeof value !== 'number') {
1613
- throw Error("SkyInvalidPipeArgument: '" + value + "'");
1614
- }
1615
- var minInt = undefined;
1616
- var minFraction = undefined;
1617
- var maxFraction = undefined;
1618
- if (style !== SkyIntlNumberFormatStyle.Currency) {
1619
- // rely on Intl default for currency
1620
- minInt = 1;
1621
- minFraction = 0;
1622
- maxFraction = 3;
1623
- }
1624
- if (digits) {
1625
- var parts = digits.match(this._NUMBER_FORMAT_REGEXP);
1626
- if (parts === null) {
1627
- throw new Error(digits + " is not a valid digit info for number pipes");
1628
- }
1629
- /* istanbul ignore else */
1630
- if (parts[1] != null) { // min integer digits
1631
- minInt = parseIntAutoRadix(parts[1]);
1632
- }
1633
- /* istanbul ignore else */
1634
- if (parts[3] != null) { // min fraction digits
1635
- minFraction = parseIntAutoRadix(parts[3]);
1636
- }
1637
- /* istanbul ignore else */
1638
- if (parts[5] != null) { // max fraction digits
1639
- maxFraction = parseIntAutoRadix(parts[5]);
1640
- }
1641
- }
1642
- return SkyIntlNumberFormatter.format(value, locale, style, {
1643
- minimumIntegerDigits: minInt,
1644
- minimumFractionDigits: minFraction,
1645
- maximumFractionDigits: maxFraction,
1646
- currency: currency,
1647
- currencyAsSymbol: currencyAsSymbol
1648
- });
1649
- };
1650
- SkyNumberFormatUtility._NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
1651
- return SkyNumberFormatUtility;
1652
- }());
1653
-
1654
- var SkyNumericService = /** @class */ (function () {
1655
- function SkyNumericService(resourcesService) {
1656
- this.resourcesService = resourcesService;
1657
- this.symbolIndex = [
1658
- { value: 1E12, label: this.getSymbol('skyux_numeric_trillions_symbol') },
1659
- { value: 1E9, label: this.getSymbol('skyux_numeric_billions_symbol') },
1660
- { value: 1E6, label: this.getSymbol('skyux_numeric_millions_symbol') },
1661
- { value: 1E3, label: this.getSymbol('skyux_numeric_thousands_symbol') }
1662
- ];
1663
- }
1664
- Object.defineProperty(SkyNumericService.prototype, "currentLocale", {
1665
- get: function () {
1666
- return this._locale || 'en-US';
1667
- },
1668
- /**
1669
- * The browser's current locale.
1670
- * @internal
1671
- */
1672
- set: function (value) {
1673
- this._locale = value;
1674
- },
1675
- enumerable: true,
1676
- configurable: true
1677
- });
1678
- /**
1679
- * Shortens with or without symbol (K/M/B/T) depending on value of number.
1680
- * @param value The number to format.
1681
- * @param options Format options.
1682
- */
1683
- SkyNumericService.prototype.formatNumber = function (value, options) {
1684
- /* tslint:disable-next-line:no-null-keyword */
1685
- if (isNaN(value) || value === null) {
1686
- return '';
1687
- }
1688
- var decimalPlaceRegExp = /\.0+$|(\.[0-9]*[1-9])0+$/;
1689
- // Get the symbol for the number after rounding, since rounding could push the number
1690
- // into a different symbol range.
1691
- var roundedNumber = this.roundNumber(value, options.digits);
1692
- var roundedNumberAbs = Math.abs(roundedNumber);
1693
- var suffix = '';
1694
- for (var i = 0; i < this.symbolIndex.length; i++) {
1695
- var symbol = this.symbolIndex[i];
1696
- if (options.truncate &&
1697
- roundedNumberAbs >= options.truncateAfter && roundedNumberAbs >= symbol.value) {
1698
- roundedNumber = this.roundNumber((value / symbol.value), options.digits);
1699
- if (Math.abs(roundedNumber) === 1000 && i > 0) {
1700
- // Rounding caused the number to cross into the range of the next symbol.
1701
- symbol = this.symbolIndex[i - 1];
1702
- roundedNumber /= 1000;
1703
- }
1704
- suffix = symbol.label;
1705
- break;
1706
- }
1707
- }
1708
- var output = roundedNumber.toString().replace(decimalPlaceRegExp, '$1') + suffix;
1709
- this.storeShortenSymbol(output);
1710
- var locale = options.locale || this.currentLocale;
1711
- var digits;
1712
- // Checks the string entered for format. Using toLowerCase to ignore case.
1713
- switch (options.format.toLowerCase()) {
1714
- // In a case where a decimal value was not shortened and
1715
- // the digit input is 2 or higher, it forces 2 digits.
1716
- // For example, this prevents a value like $15.50 from displaying as $15.5.
1717
- // Note: This will need to be reviewed if we support currencies with
1718
- // three decimal digits.
1719
- case 'currency':
1720
- var isDecimal = (value % 1 !== 0);
1721
- if (options.minDigits) {
1722
- digits = "1." + options.minDigits + "-" + options.digits;
1723
- }
1724
- else if (isDecimal && options.digits >= 2) {
1725
- digits = "1.2-" + options.digits;
1726
- }
1727
- else {
1728
- digits = "1.0-" + options.digits;
1729
- }
1730
- // Angular 5+ needs a string for this parameter, but Angular 4 needs a boolean.
1731
- // To support both versions we can supply 'symbol' which will evaluate truthy for Angular 4
1732
- // and the appropriate string value for Angular 5+.
1733
- // See: https://angular.io/api/common/CurrencyPipe#parameters
1734
- var symbolDisplay = 'symbol';
1735
- output = SkyNumberFormatUtility.formatNumber(locale, parseFloat(output), SkyIntlNumberFormatStyle.Currency, digits, options.iso, symbolDisplay);
1736
- break;
1737
- // The following is a catch-all to ensure that if
1738
- // anything but currency (or a future option) are entered,
1739
- // it will be treated like a number.
1740
- default:
1741
- // Ensures localization of the number to ensure comma and
1742
- // decimal separator
1743
- if (options.minDigits) {
1744
- digits = "1." + options.minDigits + "-" + options.digits;
1745
- }
1746
- else if (options.truncate) {
1747
- digits = "1.0-" + options.digits;
1748
- }
1749
- else {
1750
- digits = "1." + options.digits + "-" + options.digits;
1751
- }
1752
- output = SkyNumberFormatUtility.formatNumber(locale, parseFloat(output), SkyIntlNumberFormatStyle.Decimal, digits);
1753
- break;
1754
- }
1755
- if (options.truncate) {
1756
- output = this.replaceShortenSymbol(output);
1757
- }
1758
- return output;
1759
- };
1760
- /**
1761
- * Rounds a given number
1762
- *
1763
- * JS's limitation - numbers bigger than Number.MIN_SAFE_INTEGER or Number.MAX_SAFE_INTEGER
1764
- * are not guaranteed to be represented or rounded correctly
1765
- * @param value - value to round
1766
- * @param precision - what precision to round with, defaults to 0 decimal places
1767
- */
1768
- SkyNumericService.prototype.roundNumber = function (value, precision) {
1769
- if (precision === void 0) { precision = 0; }
1770
- if (precision < 0) {
1771
- throw new Error('SkyInvalidArgument: precision must be >= 0');
1772
- }
1773
- /* tslint:disable-next-line:no-null-keyword */
1774
- /* Sanity check - ignoring coverage but should not ignore if we make this method public */
1775
- /* istanbul ignore next */
1776
- if (isNaN(value) || value === null) {
1777
- return 0;
1778
- }
1779
- var scaledValue = this.scaleNumberByPowerOfTen(value, precision, true);
1780
- var scaledRoundedValue = Math.round(scaledValue);
1781
- var unscaledRoundedValue = this.scaleNumberByPowerOfTen(scaledRoundedValue, precision, false);
1782
- return unscaledRoundedValue;
1783
- };
1784
- /**
1785
- * Scales a given number by a power of 10
1786
- * @param value - value to scale
1787
- * @param scalar - 10^scalar
1788
- * @param scaleUp - whether to increase or decrease the value
1789
- */
1790
- SkyNumericService.prototype.scaleNumberByPowerOfTen = function (value, scalar, scaleUp) {
1791
- var valueStr = value.toString().toLowerCase();
1792
- var isExponentFormat = valueStr.includes('e');
1793
- if (isExponentFormat) {
1794
- var _a = __read(valueStr.split('e'), 2), base = _a[0], exp = _a[1];
1795
- var newExp = scaleUp ? (Number(exp) + scalar) : (Number(exp) - scalar);
1796
- return Number(base + "e" + newExp);
1797
- }
1798
- else {
1799
- var e = scaleUp ? 'e' : 'e-';
1800
- return Number("" + value + e + scalar);
1801
- }
1802
- };
1803
- /**
1804
- * Stores the symbol added from shortening to reapply later.
1805
- * @param value The string to derive the shorten symbol from.
1806
- */
1807
- SkyNumericService.prototype.storeShortenSymbol = function (value) {
1808
- var symbols = this.symbolIndex.map(function (s) { return s.label; });
1809
- var regexp = new RegExp(symbols.join('|'), 'ig');
1810
- var match = value.match(regexp);
1811
- this.shortSymbol = (match) ? match.toString() : '';
1812
- };
1813
- /**
1814
- * Must have previously called storeShortenSymbol to have something to replace.
1815
- * Finds the last number in the formatted number, gets the index of the position
1816
- * after that character and re-inserts the symbol.
1817
- * Works regardless of currency symbol position.
1818
- * @param value The string to modify.
1819
- */
1820
- SkyNumericService.prototype.replaceShortenSymbol = function (value) {
1821
- var result = /(\d)(?!.*\d)/g.exec(value);
1822
- var pos = result.index + result.length;
1823
- var output = value.substring(0, pos) + this.shortSymbol + value.substring(pos);
1824
- return output;
1825
- };
1826
- SkyNumericService.prototype.getSymbol = function (key) {
1827
- // TODO: Need to implement the async `getString` method in a breaking change.
1828
- return this.resourcesService.getStringForLocale({ locale: 'en_US' }, key);
1829
- };
1830
- SkyNumericService.ctorParameters = function () { return [
1831
- { type: SkyLibResourcesService }
1832
- ]; };
1833
- SkyNumericService.ɵprov = ɵɵdefineInjectable({ factory: function SkyNumericService_Factory() { return new SkyNumericService(ɵɵinject(SkyLibResourcesService)); }, token: SkyNumericService, providedIn: "any" });
1834
- SkyNumericService = __decorate([
1835
- Injectable({
1836
- providedIn: 'any'
1837
- })
1838
- ], SkyNumericService);
1839
- return SkyNumericService;
1840
- }());
1841
-
1842
- /**
1843
- * Provides arguments for the number to format.
1844
- */
1845
- var NumericOptions = /** @class */ (function () {
1846
- function NumericOptions() {
1847
- /**
1848
- * Specifies the maximum number of digits after the decimal separator.
1849
- * @default 1
1850
- */
1851
- this.digits = 1;
1852
- /**
1853
- * Specifies how to format the number. Options are `currency` or `number`.
1854
- * @default "number"
1855
- */
1856
- this.format = 'number';
1857
- /**
1858
- * Specifies the ISO4217 currency code to use for currency formatting. If you do not specify a
1859
- * currency code, the component uses the browser's culture to determine the currency unless your
1860
- * SPA provides a different culture with `SkyAppLocaleProvider`.
1861
- * @default 'USD'
1862
- */
1863
- this.iso = 'USD';
1864
- /**
1865
- * Indicates whether to shorten numbers to rounded numbers and abbreviation characters
1866
- * such as K for thousands, M for millions, B for billions, and T for trillion.
1867
- */
1868
- this.truncate = true;
1869
- /**
1870
- * Specifies the starting point after which numbers are shortened to rounded numbers
1871
- * and abbreviation characters.
1872
- * @default 0
1873
- */
1874
- this.truncateAfter = 0;
1875
- }
1876
- return NumericOptions;
1877
- }());
1878
-
1879
- /**
1880
- * Shorten numbers to rounded numbers and abbreviation characters such as K for thousands,
1881
- * M for millions, B for billions, and T for trillion. The pipe also formats for currency.
1882
- * Be sure you have a space after the two curly brackets opening the pipe and
1883
- * a space before the two curly brackets closing the pipe or it will not work.
1884
- * Usage:
1885
- * ```
1886
- * {{ value | skyNumeric(config) }}
1887
- * ```
1888
- */
1889
- var SkyNumericPipe = /** @class */ (function () {
1890
- function SkyNumericPipe(localeProvider, numericService) {
1891
- this.localeProvider = localeProvider;
1892
- this.numericService = numericService;
1893
- this.ngUnsubscribe = new Subject();
1894
- this.localeProvider.getLocaleInfo()
1895
- .pipe(takeUntil(this.ngUnsubscribe))
1896
- .subscribe(function (localeInfo) {
1897
- numericService.currentLocale = localeInfo.locale;
1898
- });
1899
- }
1900
- SkyNumericPipe.prototype.ngOnDestroy = function () {
1901
- this.ngUnsubscribe.next();
1902
- this.ngUnsubscribe.complete();
1903
- };
1904
- SkyNumericPipe.prototype.transform = function (value, config) {
1905
- var options = new NumericOptions();
1906
- // The default number of digits is `1`. When truncate is disabled, set digits
1907
- // to `0` to avoid the unnecessary addition of `.0` at the end of the formatted number.
1908
- if (config &&
1909
- config.truncate === false &&
1910
- config.digits === undefined) {
1911
- config.digits = 0;
1912
- }
1913
- // If the minimum digits is less than the set maximum digits then throw an error
1914
- if (config &&
1915
- config.minDigits &&
1916
- config.digits &&
1917
- config.minDigits > config.digits) {
1918
- throw new Error('The `digits` property must be greater than or equal to the `minDigits` property');
1919
- // If there is a minimum digits given but not a maximum then default the maximum to the minimum
1920
- }
1921
- else if (config &&
1922
- config.minDigits &&
1923
- !config.digits) {
1924
- config.digits = config.minDigits;
1925
- }
1926
- Object.assign(options, config);
1927
- return this.numericService.formatNumber(value, options);
1928
- };
1929
- SkyNumericPipe.ctorParameters = function () { return [
1930
- { type: SkyAppLocaleProvider },
1931
- { type: SkyNumericService }
1932
- ]; };
1933
- SkyNumericPipe = __decorate([
1934
- Pipe({
1935
- name: 'skyNumeric'
1936
- })
1937
- ], SkyNumericPipe);
1938
- return SkyNumericPipe;
1939
- }());
1940
-
1941
- var SkyNumericModule = /** @class */ (function () {
1942
- function SkyNumericModule() {
1943
- }
1944
- SkyNumericModule = __decorate([
1945
- NgModule({
1946
- declarations: [
1947
- SkyNumericPipe
1948
- ],
1949
- providers: [
1950
- SkyNumericPipe
1951
- ],
1952
- imports: [
1953
- SkyI18nModule,
1954
- SkyCoreResourcesModule
1955
- ],
1956
- exports: [
1957
- SkyNumericPipe
1958
- ]
1959
- })
1960
- ], SkyNumericModule);
1961
- return SkyNumericModule;
1962
- }());
1963
-
1964
- /**
1965
- * Represents a new overlay instance. It is used to manage the "closed" state of the overlay,
1966
- * and access any public members on the appended content component instance.
1967
- */
1968
- var SkyOverlayInstance = /** @class */ (function () {
1969
- function SkyOverlayInstance(
1970
- /**
1971
- * The configuration for the overlay.
1972
- */
1973
- config, componentRef) {
1974
- var _this = this;
1975
- this.config = config;
1976
- this.componentRef = componentRef;
1977
- this._backdropClick = new Subject();
1978
- this._closed = new Subject();
1979
- this.componentRef.instance.closed.subscribe(function () {
1980
- _this._closed.next();
1981
- _this._closed.complete();
1982
- _this._backdropClick.complete();
1983
- });
1984
- this.componentRef.instance.backdropClick.subscribe(function () {
1985
- _this._backdropClick.next();
1986
- });
1987
- }
1988
- Object.defineProperty(SkyOverlayInstance.prototype, "backdropClick", {
1989
- /**
1990
- * Emits when the overlay is clicked (but not its content).
1991
- */
1992
- get: function () {
1993
- return this._backdropClick.asObservable();
1994
- },
1995
- enumerable: true,
1996
- configurable: true
1997
- });
1998
- Object.defineProperty(SkyOverlayInstance.prototype, "closed", {
1999
- /**
2000
- * Emits after the overlay is closed.
2001
- */
2002
- get: function () {
2003
- return this._closed.asObservable();
2004
- },
2005
- enumerable: true,
2006
- configurable: true
2007
- });
2008
- /**
2009
- * Creates and attaches a component to the overlay.
2010
- * @param component The component to attach.
2011
- * @param providers Custom providers to apply to the component.
2012
- */
2013
- SkyOverlayInstance.prototype.attachComponent = function (component, providers) {
2014
- var componentRef = this.componentRef.instance.attachComponent(component, providers);
2015
- return componentRef.instance;
2016
- };
2017
- /**
2018
- * Attaches a `TemplateRef` to the overlay.
2019
- * @param templateRef The `TemplateRef` to attach.
2020
- * @param context The context to provide to the template.
2021
- */
2022
- SkyOverlayInstance.prototype.attachTemplate = function (templateRef, context) {
2023
- this.componentRef.instance.attachTemplate(templateRef, context);
2024
- };
2025
- return SkyOverlayInstance;
2026
- }());
2027
-
2028
- /**
2029
- * Provides contextual information to each overlay created.
2030
- * @internal
2031
- */
2032
- var SkyOverlayContext = /** @class */ (function () {
2033
- function SkyOverlayContext(config) {
2034
- this.config = config;
2035
- }
2036
- return SkyOverlayContext;
2037
- }());
2038
-
2039
- /**
2040
- * Omnibar is 1000.
2041
- * See: https://github.com/blackbaud/auth-client/blob/master/src/omnibar/omnibar.ts#L139
2042
- * ---
2043
- * Modals start their z-indexes at 1040. However, each modal's z-index is a multiple of 10, so it
2044
- * will be difficult to reliably predict a z-index that will always appear above all other
2045
- * layers. Starting the z-index for overlays at a number much greater than modals will accommodate
2046
- * the most reasonable of scenarios.
2047
- * See: https://github.com/blackbaud/skyux-modals/blob/master/src/app/public/modules/modal/modal-host.service.ts#L22
2048
- * (NOTE: It should be noted that modals do not use the overlay service, which is something we
2049
- * should do in the near future to make sure z-indexes are predictable across all component
2050
- * libraries.)
2051
- */
2052
- var uniqueZIndex = 5000;
2053
- /**
2054
- * @internal
2055
- */
2056
- var SkyOverlayComponent = /** @class */ (function () {
2057
- function SkyOverlayComponent(changeDetector, resolver, injector, coreAdapter, context, router) {
2058
- this.changeDetector = changeDetector;
2059
- this.resolver = resolver;
2060
- this.injector = injector;
2061
- this.coreAdapter = coreAdapter;
2062
- this.context = context;
2063
- this.router = router;
2064
- this.wrapperClass = '';
2065
- this.enablePointerEvents = false;
2066
- this.showBackdrop = false;
2067
- this.zIndex = "" + ++uniqueZIndex;
2068
- this.ngUnsubscribe = new Subject();
2069
- this._backdropClick = new Subject();
2070
- this._closed = new Subject();
2071
- }
2072
- Object.defineProperty(SkyOverlayComponent.prototype, "backdropClick", {
2073
- get: function () {
2074
- return this._backdropClick.asObservable();
2075
- },
2076
- enumerable: true,
2077
- configurable: true
2078
- });
2079
- Object.defineProperty(SkyOverlayComponent.prototype, "closed", {
2080
- get: function () {
2081
- return this._closed.asObservable();
2082
- },
2083
- enumerable: true,
2084
- configurable: true
2085
- });
2086
- SkyOverlayComponent.prototype.ngOnInit = function () {
2087
- var _this = this;
2088
- this.applyConfig(this.context.config);
2089
- setTimeout(function () {
2090
- _this.addBackdropClickListener();
2091
- });
2092
- if (this.context.config.closeOnNavigation) {
2093
- this.addRouteListener();
2094
- }
2095
- };
2096
- SkyOverlayComponent.prototype.ngOnDestroy = function () {
2097
- this.removeRouteListener();
2098
- this.ngUnsubscribe.next();
2099
- this.ngUnsubscribe.complete();
2100
- this._backdropClick.complete();
2101
- this._closed.next();
2102
- this._closed.complete();
2103
- };
2104
- SkyOverlayComponent.prototype.attachComponent = function (component, providers) {
2105
- if (providers === void 0) { providers = []; }
2106
- this.targetRef.clear();
2107
- var factory = this.resolver.resolveComponentFactory(component);
2108
- var injector = Injector.create({
2109
- providers: providers,
2110
- parent: this.injector
2111
- });
2112
- var componentRef = this.targetRef.createComponent(factory, undefined, injector);
2113
- // Run an initial change detection cycle after the component has been created.
2114
- componentRef.changeDetectorRef.detectChanges();
2115
- return componentRef;
2116
- };
2117
- SkyOverlayComponent.prototype.attachTemplate = function (templateRef, context) {
2118
- this.targetRef.clear();
2119
- return this.targetRef.createEmbeddedView(templateRef, context);
2120
- };
2121
- SkyOverlayComponent.prototype.applyConfig = function (config) {
2122
- this.wrapperClass = config.wrapperClass || '';
2123
- this.showBackdrop = config.showBackdrop;
2124
- this.enablePointerEvents = config.enablePointerEvents;
2125
- this.changeDetector.markForCheck();
2126
- };
2127
- SkyOverlayComponent.prototype.addBackdropClickListener = function () {
2128
- var _this = this;
2129
- fromEvent(window.document, 'click')
2130
- .pipe(takeUntil(this.ngUnsubscribe))
2131
- .subscribe(function (event) {
2132
- var isChild = _this.overlayContentRef.nativeElement.contains(event.target);
2133
- var isAbove = _this.coreAdapter.isTargetAboveElement(event.target, _this.overlayRef.nativeElement);
2134
- /* istanbul ignore else */
2135
- if (!isChild && !isAbove) {
2136
- _this._backdropClick.next();
2137
- if (_this.context.config.enableClose) {
2138
- _this._closed.next();
2139
- }
2140
- }
2141
- });
2142
- };
2143
- SkyOverlayComponent.prototype.addRouteListener = function () {
2144
- var _this = this;
2145
- /*istanbul ignore else*/
2146
- if (this.router) {
2147
- this.routerSubscription = this.router.events.subscribe(function (event) {
2148
- /* istanbul ignore else */
2149
- if (event instanceof NavigationStart) {
2150
- _this._closed.next();
2151
- }
2152
- });
2153
- }
2154
- };
2155
- SkyOverlayComponent.prototype.removeRouteListener = function () {
2156
- if (this.routerSubscription) {
2157
- this.routerSubscription.unsubscribe();
2158
- this.routerSubscription = undefined;
2159
- }
2160
- };
2161
- SkyOverlayComponent.ctorParameters = function () { return [
2162
- { type: ChangeDetectorRef },
2163
- { type: ComponentFactoryResolver },
2164
- { type: Injector },
2165
- { type: SkyCoreAdapterService },
2166
- { type: SkyOverlayContext },
2167
- { type: Router, decorators: [{ type: Optional }] }
2168
- ]; };
2169
- __decorate([
2170
- ViewChild('overlayContentRef', {
2171
- read: ElementRef,
2172
- static: true
2173
- })
2174
- ], SkyOverlayComponent.prototype, "overlayContentRef", void 0);
2175
- __decorate([
2176
- ViewChild('overlayRef', {
2177
- read: ElementRef,
2178
- static: true
2179
- })
2180
- ], SkyOverlayComponent.prototype, "overlayRef", void 0);
2181
- __decorate([
2182
- ViewChild('target', {
2183
- read: ViewContainerRef,
2184
- static: true
2185
- })
2186
- ], SkyOverlayComponent.prototype, "targetRef", void 0);
2187
- SkyOverlayComponent = __decorate([
2188
- Component({
2189
- selector: 'sky-overlay',
2190
- template: "<div\n [class]=\"wrapperClass\"\n [style.zIndex]=\"zIndex\"\n [ngClass]=\"{\n 'enable-pointer-events-pass-through': enablePointerEvents,\n 'sky-overlay': true\n }\"\n #overlayRef\n>\n <div\n class=\"sky-overlay-content\"\n #overlayContentRef\n >\n <ng-template\n #target\n >\n </ng-template>\n </div>\n <div *ngIf=\"showBackdrop\"\n class=\"sky-overlay-backdrop\"\n ></div>\n</div>\n",
2191
- changeDetection: ChangeDetectionStrategy.OnPush,
2192
- styles: [".sky-overlay{position:fixed;top:0;right:0;left:0;bottom:0;width:100%;height:100%;display:flex;pointer-events:auto}.sky-overlay-content{position:relative;z-index:1;display:inline-flex;-ms-grid-row-align:start;align-self:start;pointer-events:auto}.sky-overlay-backdrop{background:rgba(0,0,0,.5);top:0;right:0;left:0;bottom:0;width:100%;height:100%;position:absolute}.enable-pointer-events-pass-through,.enable-pointer-events-pass-through .sky-overlay-backdrop{pointer-events:none}.enable-pointer-events-pass-through .sky-overlay-content{pointer-events:auto}"]
2193
- }),
2194
- __param(5, Optional())
2195
- ], SkyOverlayComponent);
2196
- return SkyOverlayComponent;
2197
- }());
2198
-
2199
- var SkyOverlayModule = /** @class */ (function () {
2200
- function SkyOverlayModule() {
2201
- }
2202
- SkyOverlayModule = __decorate([
2203
- NgModule({
2204
- imports: [
2205
- CommonModule
2206
- ],
2207
- declarations: [
2208
- SkyOverlayComponent
2209
- ],
2210
- entryComponents: [
2211
- SkyOverlayComponent
2212
- ]
2213
- })
2214
- ], SkyOverlayModule);
2215
- return SkyOverlayModule;
2216
- }());
2217
-
2218
- /**
2219
- * @internal
2220
- */
2221
- var SkyOverlayAdapterService = /** @class */ (function () {
2222
- function SkyOverlayAdapterService(rendererFactory) {
2223
- this.renderer = rendererFactory.createRenderer(undefined, undefined);
2224
- }
2225
- SkyOverlayAdapterService.prototype.restrictBodyScroll = function () {
2226
- // Create a style element to avoid overwriting any existing inline body styles.
2227
- var styleElement = this.renderer.createElement('style');
2228
- var textNode = this.renderer.createText('body { overflow: hidden }');
2229
- // Apply a `data-` attribute to make unit testing easier.
2230
- this.renderer.setAttribute(styleElement, 'data-test-selector', 'sky-overlay-restrict-scroll-styles');
2231
- this.renderer.appendChild(styleElement, textNode);
2232
- this.renderer.appendChild(document.head, styleElement);
2233
- if (this.styleElement) {
2234
- this.destroyStyleElement();
2235
- }
2236
- this.styleElement = styleElement;
2237
- };
2238
- SkyOverlayAdapterService.prototype.releaseBodyScroll = function () {
2239
- this.destroyStyleElement();
2240
- };
2241
- SkyOverlayAdapterService.prototype.destroyStyleElement = function () {
2242
- if (this.styleElement.parentElement === document.head) {
2243
- this.renderer.removeChild(document.head, this.styleElement);
2244
- }
2245
- };
2246
- SkyOverlayAdapterService.ctorParameters = function () { return [
2247
- { type: RendererFactory2 }
2248
- ]; };
2249
- SkyOverlayAdapterService.ɵprov = ɵɵdefineInjectable({ factory: function SkyOverlayAdapterService_Factory() { return new SkyOverlayAdapterService(ɵɵinject(RendererFactory2)); }, token: SkyOverlayAdapterService, providedIn: "root" });
2250
- SkyOverlayAdapterService = __decorate([
2251
- Injectable({
2252
- providedIn: 'root'
2253
- })
2254
- ], SkyOverlayAdapterService);
2255
- return SkyOverlayAdapterService;
2256
- }());
2257
-
2258
- /**
2259
- * This service is used to create new overlays.
2260
- * @dynamic
2261
- */
2262
- var SkyOverlayService = /** @class */ (function () {
2263
- function SkyOverlayService(applicationRef, componentFactoryResolver, injector, adapter) {
2264
- this.applicationRef = applicationRef;
2265
- this.componentFactoryResolver = componentFactoryResolver;
2266
- this.injector = injector;
2267
- this.adapter = adapter;
2268
- }
2269
- SkyOverlayService_1 = SkyOverlayService;
2270
- /**
2271
- * Creates an empty overlay. Use the returned `SkyOverlayInstance` to append content.
2272
- * @param config Configuration for the overlay.
2273
- */
2274
- SkyOverlayService.prototype.create = function (config) {
2275
- var _this = this;
2276
- var settings = this.prepareConfig(config);
2277
- if (settings.enableScroll === false) {
2278
- this.adapter.restrictBodyScroll();
2279
- }
2280
- var componentRef = this.createOverlay(settings);
2281
- var instance = new SkyOverlayInstance(settings, componentRef);
2282
- instance.closed.subscribe(function () {
2283
- // Only execute the service's close method if the instance still exists.
2284
- // This is needed to address a race condition if the deprecated instance.close method is used instead.
2285
- if (SkyOverlayService_1.overlays.indexOf(instance) > -1) {
2286
- _this.close(instance);
2287
- }
2288
- });
2289
- SkyOverlayService_1.overlays.push(instance);
2290
- return instance;
2291
- };
2292
- /**
2293
- * Closes (and destroys) an overlay instance.
2294
- * @param instance The instance to close.
2295
- */
2296
- SkyOverlayService.prototype.close = function (instance) {
2297
- this.destroyOverlay(instance);
2298
- this.applicationRef.detachView(instance.componentRef.hostView);
2299
- instance.componentRef.destroy();
2300
- // In some cases, Angular keeps dynamically-generated component's nodes in the DOM during
2301
- // unit tests. This can make querying difficult because the older DOM nodes still exist and
2302
- // produce inconsistent results.
2303
- // Angular Material's overlay appears to do the same thing:
2304
- // https://github.com/angular/components/blob/master/src/cdk/portal/dom-portal-outlet.ts#L143-L145
2305
- // (Ignoring coverage since this branch will only be hit by consumer unit tests.)
2306
- var componentElement = instance.componentRef.location.nativeElement;
2307
- /* istanbul ignore if */
2308
- if (componentElement.parentNode !== null) {
2309
- componentElement.parentNode.removeChild(componentElement);
2310
- }
2311
- };
2312
- /**
2313
- * Closes all overlay instances.
2314
- */
2315
- SkyOverlayService.prototype.closeAll = function () {
2316
- // The `close` event handler for each instance alters the array's length asynchronously,
2317
- // so the only "safe" index to call is zero.
2318
- while (SkyOverlayService_1.overlays.length > 0) {
2319
- this.close(SkyOverlayService_1.overlays[0]);
2320
- }
2321
- };
2322
- SkyOverlayService.prototype.createOverlay = function (config) {
2323
- var injector = Injector.create({
2324
- parent: this.injector,
2325
- providers: [{
2326
- provide: SkyOverlayContext,
2327
- useValue: new SkyOverlayContext(config)
2328
- }]
2329
- });
2330
- var componentRef = this.componentFactoryResolver
2331
- .resolveComponentFactory(SkyOverlayComponent)
2332
- .create(injector);
2333
- this.applicationRef.attachView(componentRef.hostView);
2334
- var domElem = componentRef.hostView
2335
- .rootNodes[0];
2336
- document.body.appendChild(domElem);
2337
- return componentRef;
2338
- };
2339
- SkyOverlayService.prototype.prepareConfig = function (config) {
2340
- var defaults = {
2341
- closeOnNavigation: true,
2342
- enableClose: false,
2343
- enablePointerEvents: false,
2344
- enableScroll: true,
2345
- showBackdrop: false,
2346
- wrapperClass: ''
2347
- };
2348
- return __assign(__assign({}, defaults), config);
2349
- };
2350
- SkyOverlayService.prototype.destroyOverlay = function (instance) {
2351
- SkyOverlayService_1.overlays.splice(SkyOverlayService_1.overlays.indexOf(instance), 1);
2352
- if (instance.config.enableScroll === false) {
2353
- // Only release the body scroll if no other overlay wishes it to be disabled.
2354
- var anotherOverlayDisablesScroll = SkyOverlayService_1.overlays.some(function (o) { return !o.config.enableScroll; });
2355
- if (!anotherOverlayDisablesScroll) {
2356
- this.adapter.releaseBodyScroll();
2357
- }
2358
- }
2359
- };
2360
- var SkyOverlayService_1;
2361
- SkyOverlayService.overlays = [];
2362
- SkyOverlayService.ctorParameters = function () { return [
2363
- { type: ApplicationRef },
2364
- { type: ComponentFactoryResolver },
2365
- { type: Injector },
2366
- { type: SkyOverlayAdapterService }
2367
- ]; };
2368
- SkyOverlayService.ɵprov = ɵɵdefineInjectable({ factory: function SkyOverlayService_Factory() { return new SkyOverlayService(ɵɵinject(ApplicationRef), ɵɵinject(ComponentFactoryResolver), ɵɵinject(INJECTOR), ɵɵinject(SkyOverlayAdapterService)); }, token: SkyOverlayService, providedIn: "root" });
2369
- SkyOverlayService = SkyOverlayService_1 = __decorate([
2370
- Injectable({
2371
- providedIn: 'root'
2372
- })
2373
- ], SkyOverlayService);
2374
- return SkyOverlayService;
2375
- }());
2376
-
2377
- var SkyPercentPipe = /** @class */ (function () {
2378
- function SkyPercentPipe(localeProvider) {
2379
- var _this = this;
2380
- this.localeProvider = localeProvider;
2381
- this.defaultFormat = '1.0-2';
2382
- this.defaultLocale = 'en-US';
2383
- this.ngUnsubscribe = new Subject();
2384
- this.localeProvider.getLocaleInfo()
2385
- .pipe(takeUntil(this.ngUnsubscribe))
2386
- .subscribe(function (localeInfo) {
2387
- _this.defaultLocale = localeInfo.locale;
2388
- _this.updateFormattedValue();
2389
- });
2390
- }
2391
- SkyPercentPipe.prototype.ngOnDestroy = function () {
2392
- this.ngUnsubscribe.next();
2393
- this.ngUnsubscribe.complete();
2394
- };
2395
- SkyPercentPipe.prototype.transform = function (value, format, locale) {
2396
- this.value = value;
2397
- this.format = format;
2398
- this.locale = locale;
2399
- this.updateFormattedValue();
2400
- return this.formattedValue;
2401
- };
2402
- SkyPercentPipe.prototype.updateFormattedValue = function () {
2403
- var locale = this.locale || this.defaultLocale;
2404
- var format = this.format || this.defaultFormat;
2405
- this.formattedValue = SkyNumberFormatUtility.formatNumber(locale, this.value, SkyIntlNumberFormatStyle.Percent, format);
2406
- };
2407
- SkyPercentPipe.ctorParameters = function () { return [
2408
- { type: SkyAppLocaleProvider }
2409
- ]; };
2410
- SkyPercentPipe = __decorate([
2411
- Pipe({
2412
- name: 'skyPercent',
2413
- pure: false
2414
- })
2415
- ], SkyPercentPipe);
2416
- return SkyPercentPipe;
2417
- }());
2418
-
2419
- var SkyPercentPipeModule = /** @class */ (function () {
2420
- function SkyPercentPipeModule() {
2421
- }
2422
- SkyPercentPipeModule = __decorate([
2423
- NgModule({
2424
- declarations: [
2425
- SkyPercentPipe
2426
- ],
2427
- providers: [
2428
- SkyPercentPipe
2429
- ],
2430
- imports: [
2431
- CommonModule,
2432
- SkyCoreResourcesModule
2433
- ],
2434
- exports: [
2435
- SkyPercentPipe
2436
- ]
2437
- })
2438
- ], SkyPercentPipeModule);
2439
- return SkyPercentPipeModule;
2440
- }());
2441
-
2442
- /**
2443
- * Provides a method for setting a formatted title on the current window.
2444
- */
2445
- var SkyAppTitleService = /** @class */ (function () {
2446
- function SkyAppTitleService(title) {
2447
- this.title = title;
2448
- }
2449
- /**
2450
- * Sets the title on the current window.
2451
- * @param args An array of title parts. The parts will be concatenated with a hyphen between
2452
- * each part.
2453
- */
2454
- SkyAppTitleService.prototype.setTitle = function (args) {
2455
- if (args && args.titleParts) {
2456
- this.title.setTitle(args.titleParts.join(' - '));
2457
- }
2458
- };
2459
- SkyAppTitleService.ctorParameters = function () { return [
2460
- { type: Title }
2461
- ]; };
2462
- SkyAppTitleService.ɵprov = ɵɵdefineInjectable({ factory: function SkyAppTitleService_Factory() { return new SkyAppTitleService(ɵɵinject(Title)); }, token: SkyAppTitleService, providedIn: "root" });
2463
- SkyAppTitleService = __decorate([
2464
- Injectable({
2465
- providedIn: 'root'
2466
- })
2467
- ], SkyAppTitleService);
2468
- return SkyAppTitleService;
2469
- }());
2470
-
2471
- var SkyUIConfigService = /** @class */ (function () {
2472
- function SkyUIConfigService() {
2473
- }
2474
- SkyUIConfigService.prototype.getConfig = function (key, defaultConfig) {
2475
- return of(defaultConfig);
2476
- };
2477
- /* istanbul ignore next */
2478
- SkyUIConfigService.prototype.setConfig = function (key, value) {
2479
- return of({});
2480
- };
2481
- SkyUIConfigService.ɵprov = ɵɵdefineInjectable({ factory: function SkyUIConfigService_Factory() { return new SkyUIConfigService(); }, token: SkyUIConfigService, providedIn: "root" });
2482
- SkyUIConfigService = __decorate([
2483
- Injectable({
2484
- providedIn: 'root'
2485
- })
2486
- ], SkyUIConfigService);
2487
- return SkyUIConfigService;
2488
- }());
2489
-
2490
- var SkyViewkeeperHostOptions = /** @class */ (function () {
2491
- function SkyViewkeeperHostOptions() {
2492
- }
2493
- SkyViewkeeperHostOptions = __decorate([
2494
- Injectable()
2495
- ], SkyViewkeeperHostOptions);
2496
- return SkyViewkeeperHostOptions;
2497
- }());
2498
-
2499
- var CLS_VIEWKEEPER_FIXED = 'sky-viewkeeper-fixed';
2500
- var EVT_AFTER_VIEWKEEPER_SYNC = 'afterViewkeeperSync';
2501
- var styleEl;
2502
- var nextIdIndex;
2503
- function ensureStyleEl() {
2504
- if (!styleEl) {
2505
- styleEl = document.createElement('style');
2506
- var css = document.createTextNode("\n." + CLS_VIEWKEEPER_FIXED + " {\n position: fixed !important;\n z-index: 999;\n opacity: 0.95;\n overflow: hidden;\n}\n\n.sky-theme-modern ." + CLS_VIEWKEEPER_FIXED + " {\n box-shadow: 0px 1px 8px -1px rgba(0, 0, 0, 0.3);\n opacity: initial;\n}\n");
2507
- styleEl.appendChild(css);
2508
- document.head.appendChild(styleEl);
2509
- }
2510
- }
2511
- function nextId() {
2512
- nextIdIndex = (nextIdIndex || 0) + 1;
2513
- return 'viewkeeper-' + nextIdIndex;
2514
- }
2515
- function getOffset(el) {
2516
- var rect = el.getBoundingClientRect();
2517
- return {
2518
- top: rect.top + document.documentElement.scrollTop,
2519
- left: rect.left + document.documentElement.scrollLeft
2520
- };
2521
- }
2522
- function px(value) {
2523
- var pxValue = value ? value.toString() : '';
2524
- if (typeof value === 'number') {
2525
- pxValue = value + 'px';
2526
- }
2527
- return pxValue;
2528
- }
2529
- function setElPosition(el, left, top, width, marginTop) {
2530
- el.style.top = px(top);
2531
- el.style.left = px(left);
2532
- el.style.marginTop = px(marginTop);
2533
- /*istanbul ignore else*/
2534
- /* sanity check */
2535
- if (width !== null) {
2536
- el.style.width = px(width);
2537
- }
2538
- }
2539
- function getHeightWithMargin(el) {
2540
- var computedStyle = getComputedStyle(el);
2541
- return el.offsetHeight + parseInt(computedStyle.marginTop, 10) + parseInt(computedStyle.marginBottom, 10);
2542
- }
2543
- function createCustomEvent(name) {
2544
- var evt = document.createEvent('CustomEvent');
2545
- evt.initCustomEvent(name, false, false, undefined);
2546
- return evt;
2547
- }
2548
- var SkyViewkeeper = /** @class */ (function () {
2549
- function SkyViewkeeper(options) {
2550
- var _this = this;
2551
- options = options || /* istanbul ignore next */ {};
2552
- this.setWidth = options.setWidth;
2553
- this.id = nextId();
2554
- this.el = options.el;
2555
- this.boundaryEl = options.boundaryEl;
2556
- this.verticalOffset = options.verticalOffset || 0;
2557
- this.verticalOffsetEl = options.verticalOffsetEl;
2558
- this.viewportMarginTop = options.viewportMarginTop || 0;
2559
- this.syncElPositionHandler = function () { return _this.syncElPosition(); };
2560
- if (this.verticalOffsetEl) {
2561
- this.verticalOffsetEl.addEventListener(EVT_AFTER_VIEWKEEPER_SYNC, this.syncElPositionHandler);
2562
- }
2563
- window.addEventListener('scroll', this.syncElPositionHandler);
2564
- window.addEventListener('resize', this.syncElPositionHandler);
2565
- window.addEventListener('orientationchange', this.syncElPositionHandler);
2566
- ensureStyleEl();
2567
- this.syncElPosition();
2568
- }
2569
- SkyViewkeeper.prototype.syncElPosition = function () {
2570
- var verticalOffset = this.calculateVerticalOffset();
2571
- // When the element isn't visible, its size can't be calculated, so don't attempt syncing position in this case.
2572
- if (this.el.offsetWidth === 0 && this.el.offsetHeight === 0) {
2573
- return;
2574
- }
2575
- var boundaryInfo = this.getBoundaryInfo();
2576
- var fixedStyles = this.getFixedStyles(boundaryInfo, verticalOffset);
2577
- var doFixEl = this.shouldFixEl(boundaryInfo, verticalOffset);
2578
- if (this.needsUpdating(doFixEl, fixedStyles)) {
2579
- if (doFixEl) {
2580
- this.fixEl(boundaryInfo, fixedStyles);
2581
- }
2582
- else {
2583
- this.unfixEl();
2584
- }
2585
- }
2586
- var evt = createCustomEvent(EVT_AFTER_VIEWKEEPER_SYNC);
2587
- this.el.dispatchEvent(evt);
2588
- };
2589
- SkyViewkeeper.prototype.destroy = function () {
2590
- if (!this.isDestroyed) {
2591
- window.removeEventListener('scroll', this.syncElPositionHandler);
2592
- window.removeEventListener('resize', this.syncElPositionHandler);
2593
- window.removeEventListener('orientationchange', this.syncElPositionHandler);
2594
- this.unfixEl();
2595
- if (this.verticalOffsetEl) {
2596
- this.verticalOffsetEl.removeEventListener(EVT_AFTER_VIEWKEEPER_SYNC, this.syncElPositionHandler);
2597
- }
2598
- this.el =
2599
- this.boundaryEl =
2600
- this.verticalOffsetEl = undefined;
2601
- this.isDestroyed = true;
2602
- }
2603
- };
2604
- SkyViewkeeper.prototype.getSpacerId = function () {
2605
- return this.id + '-spacer';
2606
- };
2607
- SkyViewkeeper.prototype.unfixEl = function () {
2608
- var spacerEl = document.getElementById(this.getSpacerId());
2609
- if (spacerEl) {
2610
- spacerEl.parentElement.removeChild(spacerEl);
2611
- }
2612
- this.el.classList.remove(CLS_VIEWKEEPER_FIXED);
2613
- this.currentElFixedLeft =
2614
- this.currentElFixedTop =
2615
- this.currentElFixedWidth = undefined;
2616
- var width;
2617
- if (this.setWidth) {
2618
- width = 'auto';
2619
- }
2620
- setElPosition(this.el, '', '', width, '');
2621
- };
2622
- SkyViewkeeper.prototype.calculateVerticalOffset = function () {
2623
- var offset = this.verticalOffset;
2624
- if (this.verticalOffsetEl) {
2625
- var verticalOffsetElTopStyle = this.verticalOffsetEl.style.top;
2626
- var verticalOffsetElTop = parseInt(verticalOffsetElTopStyle, 10) || 0;
2627
- offset += (this.verticalOffsetEl.offsetHeight + verticalOffsetElTop);
2628
- }
2629
- return offset;
2630
- };
2631
- SkyViewkeeper.prototype.shouldFixEl = function (boundaryInfo, verticalOffset) {
2632
- var anchorTop;
2633
- var doFixEl;
2634
- if (boundaryInfo.spacerEl) {
2635
- anchorTop = getOffset(boundaryInfo.spacerEl).top;
2636
- }
2637
- else {
2638
- anchorTop = getOffset(this.el).top;
2639
- }
2640
- doFixEl = boundaryInfo.scrollTop + verticalOffset + this.viewportMarginTop > anchorTop;
2641
- return doFixEl;
2642
- };
2643
- SkyViewkeeper.prototype.getFixedStyles = function (boundaryInfo, verticalOffset) {
2644
- var elFixedTop;
2645
- // If the element needs to be fixed, this will calculate its position. The position
2646
- // will be 0 (fully visible) unless the user is scrolling the boundary out of view.
2647
- // In that case, the element should begin to scroll out of view with the
2648
- // rest of the boundary by setting its top position to a negative value.
2649
- elFixedTop = Math.min((boundaryInfo.boundaryBottom - boundaryInfo.elHeight) - boundaryInfo.scrollTop, verticalOffset);
2650
- var elFixedWidth = boundaryInfo.boundaryEl.getBoundingClientRect().width;
2651
- var elFixedLeft = boundaryInfo.boundaryOffset.left - boundaryInfo.scrollLeft;
2652
- return {
2653
- elFixedLeft: elFixedLeft,
2654
- elFixedTop: elFixedTop,
2655
- elFixedWidth: elFixedWidth
2656
- };
2657
- };
2658
- SkyViewkeeper.prototype.needsUpdating = function (doFixEl, fixedStyles) {
2659
- if ((doFixEl &&
2660
- this.currentElFixedLeft === fixedStyles.elFixedLeft &&
2661
- this.currentElFixedTop === fixedStyles.elFixedTop &&
2662
- this.currentElFixedWidth === fixedStyles.elFixedWidth) ||
2663
- (!doFixEl &&
2664
- !(this.currentElFixedLeft !== undefined && this.currentElFixedLeft !== null))) {
2665
- // The element is either currently fixed and its position and width do not need
2666
- // to change, or the element is not currently fixed and does not need to be fixed.
2667
- // No changes are needed.
2668
- return false;
2669
- }
2670
- return true;
2671
- };
2672
- SkyViewkeeper.prototype.fixEl = function (boundaryInfo, fixedStyles) {
2673
- var el = this.el;
2674
- /* istanbul ignore else */
2675
- /* sanity check */
2676
- if (!boundaryInfo.spacerEl) {
2677
- var spacerHeight = boundaryInfo.elHeight;
2678
- var spacerEl = document.createElement('div');
2679
- spacerEl.id = boundaryInfo.spacerId;
2680
- spacerEl.style.height = px(spacerHeight);
2681
- el.parentNode.insertBefore(spacerEl, el.nextSibling);
2682
- }
2683
- el.classList.add(CLS_VIEWKEEPER_FIXED);
2684
- this.currentElFixedTop = fixedStyles.elFixedTop;
2685
- this.currentElFixedLeft = fixedStyles.elFixedLeft;
2686
- this.currentElFixedWidth = fixedStyles.elFixedWidth;
2687
- var width;
2688
- if (this.setWidth) {
2689
- width = fixedStyles.elFixedWidth;
2690
- }
2691
- setElPosition(el, fixedStyles.elFixedLeft, fixedStyles.elFixedTop, width, this.viewportMarginTop);
2692
- };
2693
- SkyViewkeeper.prototype.getBoundaryInfo = function () {
2694
- var spacerId = this.getSpacerId();
2695
- var spacerEl = document.getElementById(spacerId);
2696
- var boundaryEl = this.boundaryEl;
2697
- var boundaryOffset = getOffset(boundaryEl);
2698
- var boundaryTop = boundaryOffset.top;
2699
- var boundaryBottom = boundaryTop + boundaryEl.getBoundingClientRect().height;
2700
- var scrollLeft = document.documentElement.scrollLeft;
2701
- var scrollTop = document.documentElement.scrollTop;
2702
- var elHeight = getHeightWithMargin(this.el);
2703
- return {
2704
- boundaryBottom: boundaryBottom,
2705
- boundaryOffset: boundaryOffset,
2706
- boundaryEl: boundaryEl,
2707
- elHeight: elHeight,
2708
- scrollLeft: scrollLeft,
2709
- scrollTop: scrollTop,
2710
- spacerId: spacerId,
2711
- spacerEl: spacerEl
2712
- };
2713
- };
2714
- return SkyViewkeeper;
2715
- }());
2716
-
2717
- /**
2718
- * Provides methods for creating and destroying viewkeeper instances.
2719
- */
2720
- var SkyViewkeeperService = /** @class */ (function () {
2721
- function SkyViewkeeperService(hostOptions) {
2722
- this.hostOptions = hostOptions;
2723
- }
2724
- /**
2725
- *
2726
- * @param options Creates a viewkeeper instance, applying host options where applicable.
2727
- */
2728
- SkyViewkeeperService.prototype.create = function (options) {
2729
- options = Object.assign({}, this.hostOptions || {}, options);
2730
- return new SkyViewkeeper(options);
2731
- };
2732
- /**
2733
- * Destroys a viewkeeper instance.
2734
- * @param vk Viewkeeper instance to destroy.
2735
- */
2736
- SkyViewkeeperService.prototype.destroy = function (vk) {
2737
- vk.destroy();
2738
- };
2739
- SkyViewkeeperService.ctorParameters = function () { return [
2740
- { type: SkyViewkeeperHostOptions, decorators: [{ type: Optional }] }
2741
- ]; };
2742
- SkyViewkeeperService.ɵprov = ɵɵdefineInjectable({ factory: function SkyViewkeeperService_Factory() { return new SkyViewkeeperService(ɵɵinject(SkyViewkeeperHostOptions, 8)); }, token: SkyViewkeeperService, providedIn: "root" });
2743
- SkyViewkeeperService = __decorate([
2744
- Injectable({
2745
- providedIn: 'root'
2746
- }),
2747
- __param(0, Optional())
2748
- ], SkyViewkeeperService);
2749
- return SkyViewkeeperService;
2750
- }());
2751
-
2752
- var SkyViewkeeperDirective = /** @class */ (function () {
2753
- function SkyViewkeeperDirective(el, mutationObserverSvc, viewkeeperSvc) {
2754
- this.el = el;
2755
- this.mutationObserverSvc = mutationObserverSvc;
2756
- this.viewkeeperSvc = viewkeeperSvc;
2757
- this.viewkeepers = [];
2758
- }
2759
- Object.defineProperty(SkyViewkeeperDirective.prototype, "skyViewkeeper", {
2760
- get: function () {
2761
- return this._skyViewkeeper;
2762
- },
2763
- set: function (value) {
2764
- this._skyViewkeeper = value;
2765
- this.detectElements();
2766
- },
2767
- enumerable: true,
2768
- configurable: true
2769
- });
2770
- SkyViewkeeperDirective.prototype.ngOnInit = function () {
2771
- var _this = this;
2772
- this.observer = this.mutationObserverSvc.create(function () { return _this.detectElements(); });
2773
- this.observer.observe(this.el.nativeElement, {
2774
- childList: true,
2775
- subtree: true
2776
- });
2777
- };
2778
- SkyViewkeeperDirective.prototype.ngOnDestroy = function () {
2779
- this.observer.disconnect();
2780
- this.destroyViewkeepers();
2781
- };
2782
- SkyViewkeeperDirective.prototype.destroyViewkeepers = function () {
2783
- var e_1, _a;
2784
- try {
2785
- for (var _b = __values(this.viewkeepers), _c = _b.next(); !_c.done; _c = _b.next()) {
2786
- var viewkeeper = _c.value;
2787
- this.viewkeeperSvc.destroy(viewkeeper);
2788
- }
2789
- }
2790
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2791
- finally {
2792
- try {
2793
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2794
- }
2795
- finally { if (e_1) throw e_1.error; }
2796
- }
2797
- this.viewkeepers = [];
2798
- };
2799
- SkyViewkeeperDirective.prototype.getViewkeeperEls = function () {
2800
- var e_2, _a;
2801
- var viewkeeperEls;
2802
- if (this.skyViewkeeper) {
2803
- viewkeeperEls = [];
2804
- try {
2805
- for (var _b = __values(this.skyViewkeeper), _c = _b.next(); !_c.done; _c = _b.next()) {
2806
- var item = _c.value;
2807
- var matchingEls = Array.from(this.el.nativeElement.querySelectorAll(item));
2808
- viewkeeperEls = __spread(viewkeeperEls, matchingEls);
2809
- }
2810
- }
2811
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2812
- finally {
2813
- try {
2814
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2815
- }
2816
- finally { if (e_2) throw e_2.error; }
2817
- }
2818
- }
2819
- return viewkeeperEls;
2820
- };
2821
- SkyViewkeeperDirective.prototype.viewkeeperElsChanged = function (viewkeeperEls) {
2822
- if (!viewkeeperEls !== !this.currentViewkeeperEls) {
2823
- return true;
2824
- }
2825
- if (viewkeeperEls && this.currentViewkeeperEls) {
2826
- if (viewkeeperEls.length !== this.currentViewkeeperEls.length) {
2827
- return true;
2828
- }
2829
- for (var i = 0, n = viewkeeperEls.length; i < n; i++) {
2830
- if (viewkeeperEls[i] !== this.currentViewkeeperEls[i]) {
2831
- return true;
2832
- }
2833
- }
2834
- }
2835
- return false;
2836
- };
2837
- SkyViewkeeperDirective.prototype.detectElements = function () {
2838
- var e_3, _a;
2839
- var viewkeeperEls = this.getViewkeeperEls();
2840
- if (this.viewkeeperElsChanged(viewkeeperEls)) {
2841
- this.destroyViewkeepers();
2842
- var previousViewkeeperEl = void 0;
2843
- try {
2844
- for (var viewkeeperEls_1 = __values(viewkeeperEls), viewkeeperEls_1_1 = viewkeeperEls_1.next(); !viewkeeperEls_1_1.done; viewkeeperEls_1_1 = viewkeeperEls_1.next()) {
2845
- var viewkeeperEl = viewkeeperEls_1_1.value;
2846
- this.viewkeepers.push(this.viewkeeperSvc.create({
2847
- boundaryEl: this.el.nativeElement,
2848
- el: viewkeeperEl,
2849
- setWidth: true,
2850
- verticalOffsetEl: previousViewkeeperEl
2851
- }));
2852
- previousViewkeeperEl = viewkeeperEl;
2853
- }
2854
- }
2855
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
2856
- finally {
2857
- try {
2858
- if (viewkeeperEls_1_1 && !viewkeeperEls_1_1.done && (_a = viewkeeperEls_1.return)) _a.call(viewkeeperEls_1);
2859
- }
2860
- finally { if (e_3) throw e_3.error; }
2861
- }
2862
- this.currentViewkeeperEls = viewkeeperEls;
2863
- }
2864
- };
2865
- SkyViewkeeperDirective.ctorParameters = function () { return [
2866
- { type: ElementRef },
2867
- { type: MutationObserverService },
2868
- { type: SkyViewkeeperService }
2869
- ]; };
2870
- __decorate([
2871
- Input()
2872
- ], SkyViewkeeperDirective.prototype, "skyViewkeeper", null);
2873
- SkyViewkeeperDirective = __decorate([
2874
- Directive({
2875
- selector: '[skyViewkeeper]'
2876
- })
2877
- ], SkyViewkeeperDirective);
2878
- return SkyViewkeeperDirective;
2879
- }());
2880
-
2881
- var SkyViewkeeperModule = /** @class */ (function () {
2882
- function SkyViewkeeperModule() {
2883
- }
2884
- SkyViewkeeperModule = __decorate([
2885
- NgModule({
2886
- declarations: [
2887
- SkyViewkeeperDirective
2888
- ],
2889
- exports: [
2890
- SkyViewkeeperDirective
2891
- ]
2892
- })
2893
- ], SkyViewkeeperModule);
2894
- return SkyViewkeeperModule;
2895
- }());
2896
-
2897
- /**
2898
- * Generated bundle index. Do not edit.
2899
- */
2900
-
2901
- export { MutationObserverService, NumericOptions, SkyAffixAutoFitContext, SkyAffixModule, SkyAffixService, SkyAffixer, SkyAppFormat, SkyAppTitleService, SkyAppWindowRef, SkyCoreAdapterModule, SkyCoreAdapterService, SkyDockItem, SkyDockModule, SkyDockService, SkyDynamicComponentLocation, SkyDynamicComponentModule, SkyDynamicComponentService, SkyIdModule, SkyLogModule, SkyLogService, SkyMediaBreakpoints, SkyMediaQueryModule, SkyMediaQueryService, SkyNumericModule, SkyNumericPipe, SkyNumericService, SkyOverlayInstance, SkyOverlayModule, SkyOverlayService, SkyPercentPipe, SkyPercentPipeModule, SkyUIConfigService, SkyViewkeeperHostOptions, SkyViewkeeperModule, SkyViewkeeperService, getWindow, SkyAffixDirective as ɵa, SkyDockComponent as ɵb, SkyDockDomAdapterService as ɵc, SkyIdDirective as ɵd, SkyCoreResourcesModule as ɵe, SkyCoreResourcesProvider as ɵf, SkyOverlayComponent as ɵg, SkyOverlayContext as ɵh, SkyOverlayAdapterService as ɵi, SkyViewkeeperDirective as ɵj };
2902
- //# sourceMappingURL=skyux-core.js.map