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