@skyux/modals 5.7.2 → 6.0.0-beta.2
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 +4 -4
- package/esm2020/index.mjs +26 -0
- package/esm2020/lib/modules/confirm/confirm-button-action.mjs +2 -0
- package/esm2020/lib/modules/confirm/confirm-button-config.mjs +2 -0
- package/esm2020/lib/modules/confirm/confirm-button.mjs +2 -0
- package/esm2020/lib/modules/confirm/confirm-closed-event-args.mjs +2 -0
- package/esm2020/lib/modules/confirm/confirm-config.mjs +2 -0
- package/esm2020/lib/modules/confirm/confirm-instance.mjs +12 -0
- package/esm2020/lib/modules/confirm/confirm-modal-context.mjs +4 -0
- package/esm2020/lib/modules/confirm/confirm-type.mjs +25 -0
- package/esm2020/lib/modules/confirm/confirm.component.mjs +123 -0
- package/esm2020/lib/modules/confirm/confirm.module.mjs +34 -0
- package/esm2020/lib/modules/confirm/confirm.service.mjs +55 -0
- package/esm2020/lib/modules/modal/modal-adapter.service.mjs +47 -0
- package/esm2020/lib/modules/modal/modal-before-close-handler.mjs +7 -0
- package/esm2020/lib/modules/modal/modal-close-args.mjs +3 -0
- package/esm2020/lib/modules/modal/modal-component-adapter.service.mjs +98 -0
- package/esm2020/lib/modules/modal/modal-configuration.mjs +19 -0
- package/esm2020/lib/modules/modal/modal-content.component.mjs +14 -0
- package/esm2020/lib/modules/modal/modal-footer.component.mjs +14 -0
- package/esm2020/lib/modules/modal/modal-header.component.mjs +15 -0
- package/esm2020/lib/modules/modal/modal-host.component.mjs +96 -0
- package/esm2020/lib/modules/modal/modal-host.service.mjs +55 -0
- package/esm2020/lib/modules/modal/modal-instance.mjs +105 -0
- package/esm2020/lib/modules/modal/modal-scroll-shadow-event-args.mjs +2 -0
- package/esm2020/lib/modules/modal/modal-scroll-shadow.directive.mjs +122 -0
- package/esm2020/lib/modules/modal/modal-state-animation.mjs +8 -0
- package/esm2020/lib/modules/modal/modal.component.mjs +178 -0
- package/esm2020/lib/modules/modal/modal.interface.mjs +4 -0
- package/esm2020/lib/modules/modal/modal.module.mjs +63 -0
- package/esm2020/lib/modules/modal/modal.service.mjs +85 -0
- package/esm2020/lib/modules/shared/sky-modals-resources.module.mjs +54 -0
- package/esm2020/skyux-modals.mjs +5 -0
- package/esm2020/testing/modal-fixture.mjs +168 -0
- package/esm2020/testing/public-api.mjs +2 -0
- package/esm2020/testing/skyux-modals-testing.mjs +5 -0
- package/fesm2015/{skyux-modals-testing.js → skyux-modals-testing.mjs} +1 -1
- package/fesm2015/skyux-modals-testing.mjs.map +1 -0
- package/fesm2015/skyux-modals.mjs +1159 -0
- package/fesm2015/skyux-modals.mjs.map +1 -0
- package/{esm2015/testing/modal-fixture.js → fesm2020/skyux-modals-testing.mjs} +8 -2
- package/fesm2020/skyux-modals-testing.mjs.map +1 -0
- package/{fesm2015/skyux-modals.js → fesm2020/skyux-modals.mjs} +58 -88
- package/fesm2020/skyux-modals.mjs.map +1 -0
- package/package.json +39 -15
- package/testing/package.json +5 -5
- package/bundles/skyux-modals-testing.umd.js +0 -538
- package/bundles/skyux-modals.umd.js +0 -1356
- package/esm2015/index.js +0 -26
- package/esm2015/index.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-button-action.js +0 -2
- package/esm2015/lib/modules/confirm/confirm-button-action.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-button-config.js +0 -2
- package/esm2015/lib/modules/confirm/confirm-button-config.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-button.js +0 -2
- package/esm2015/lib/modules/confirm/confirm-button.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-closed-event-args.js +0 -2
- package/esm2015/lib/modules/confirm/confirm-closed-event-args.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-config.js +0 -2
- package/esm2015/lib/modules/confirm/confirm-config.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-instance.js +0 -12
- package/esm2015/lib/modules/confirm/confirm-instance.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-modal-context.js +0 -4
- package/esm2015/lib/modules/confirm/confirm-modal-context.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm-type.js +0 -25
- package/esm2015/lib/modules/confirm/confirm-type.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm.component.js +0 -127
- package/esm2015/lib/modules/confirm/confirm.component.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm.module.js +0 -35
- package/esm2015/lib/modules/confirm/confirm.module.js.map +0 -1
- package/esm2015/lib/modules/confirm/confirm.service.js +0 -55
- package/esm2015/lib/modules/confirm/confirm.service.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-adapter.service.js +0 -47
- package/esm2015/lib/modules/modal/modal-adapter.service.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-before-close-handler.js +0 -7
- package/esm2015/lib/modules/modal/modal-before-close-handler.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-close-args.js +0 -3
- package/esm2015/lib/modules/modal/modal-close-args.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-component-adapter.service.js +0 -98
- package/esm2015/lib/modules/modal/modal-component-adapter.service.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-configuration.js +0 -19
- package/esm2015/lib/modules/modal/modal-configuration.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-content.component.js +0 -19
- package/esm2015/lib/modules/modal/modal-content.component.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-footer.component.js +0 -18
- package/esm2015/lib/modules/modal/modal-footer.component.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-header.component.js +0 -19
- package/esm2015/lib/modules/modal/modal-header.component.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-host.component.js +0 -101
- package/esm2015/lib/modules/modal/modal-host.component.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-host.service.js +0 -55
- package/esm2015/lib/modules/modal/modal-host.service.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-instance.js +0 -105
- package/esm2015/lib/modules/modal/modal-instance.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-scroll-shadow-event-args.js +0 -2
- package/esm2015/lib/modules/modal/modal-scroll-shadow-event-args.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-scroll-shadow.directive.js +0 -122
- package/esm2015/lib/modules/modal/modal-scroll-shadow.directive.js.map +0 -1
- package/esm2015/lib/modules/modal/modal-state-animation.js +0 -8
- package/esm2015/lib/modules/modal/modal-state-animation.js.map +0 -1
- package/esm2015/lib/modules/modal/modal.component.js +0 -184
- package/esm2015/lib/modules/modal/modal.component.js.map +0 -1
- package/esm2015/lib/modules/modal/modal.interface.js +0 -4
- package/esm2015/lib/modules/modal/modal.interface.js.map +0 -1
- package/esm2015/lib/modules/modal/modal.module.js +0 -64
- package/esm2015/lib/modules/modal/modal.module.js.map +0 -1
- package/esm2015/lib/modules/modal/modal.service.js +0 -85
- package/esm2015/lib/modules/modal/modal.service.js.map +0 -1
- package/esm2015/lib/modules/shared/sky-modals-resources.module.js +0 -54
- package/esm2015/lib/modules/shared/sky-modals-resources.module.js.map +0 -1
- package/esm2015/skyux-modals.js +0 -5
- package/esm2015/skyux-modals.js.map +0 -1
- package/esm2015/testing/modal-fixture.js.map +0 -1
- package/esm2015/testing/public-api.js +0 -2
- package/esm2015/testing/public-api.js.map +0 -1
- package/esm2015/testing/skyux-modals-testing.js +0 -5
- package/esm2015/testing/skyux-modals-testing.js.map +0 -1
- package/fesm2015/skyux-modals-testing.js.map +0 -1
- package/fesm2015/skyux-modals.js.map +0 -1
|
@@ -0,0 +1,1159 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, NgModule, Component, ViewEncapsulation, Injectable, Injector, ViewContainerRef, ViewChild, Directive, Optional, Output, HostListener, ElementRef, Host, HostBinding, Input } from '@angular/core';
|
|
3
|
+
import * as i6 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import * as i1 from '@skyux/theme';
|
|
6
|
+
import { SkyTheme, SkyThemeModule } from '@skyux/theme';
|
|
7
|
+
import * as i2 from '@angular/router';
|
|
8
|
+
import { NavigationStart, RouterModule } from '@angular/router';
|
|
9
|
+
import * as i5 from '@skyux/indicators';
|
|
10
|
+
import { SkyIconModule } from '@skyux/indicators';
|
|
11
|
+
import * as i3$1 from '@skyux/i18n';
|
|
12
|
+
import { getLibStringForLocale, SkyI18nModule, SKY_LIB_RESOURCES_PROVIDERS } from '@skyux/i18n';
|
|
13
|
+
import { takeWhile, takeUntil } from 'rxjs/operators';
|
|
14
|
+
import * as i3 from '@skyux/core';
|
|
15
|
+
import { SkyDockLocation, SkyDockService } from '@skyux/core';
|
|
16
|
+
import { Subject, BehaviorSubject, zip } from 'rxjs';
|
|
17
|
+
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
18
|
+
|
|
19
|
+
class SkyConfirmInstance {
|
|
20
|
+
constructor() {
|
|
21
|
+
/**
|
|
22
|
+
* Fires when users select an action to close the confirmation dialog. This event
|
|
23
|
+
* returns a `SkyConfirmCloseEventArgs` object with information about the button that
|
|
24
|
+
* users select.
|
|
25
|
+
*/
|
|
26
|
+
this.closed = new EventEmitter();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* istanbul ignore next */
|
|
31
|
+
class SkyConfirmModalContext {
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var SkyConfirmType;
|
|
35
|
+
(function (SkyConfirmType) {
|
|
36
|
+
/**
|
|
37
|
+
* Allows you to define your own `buttons` using the buttons property to
|
|
38
|
+
* specify an array of `SkyConfirmButtonConfig` objects.
|
|
39
|
+
*/
|
|
40
|
+
SkyConfirmType[SkyConfirmType["Custom"] = 0] = "Custom";
|
|
41
|
+
/**
|
|
42
|
+
* Displays one button with an **OK** label.
|
|
43
|
+
*/
|
|
44
|
+
SkyConfirmType[SkyConfirmType["OK"] = 1] = "OK";
|
|
45
|
+
/**
|
|
46
|
+
* Displays two buttons with **Yes** and **Cancel** labels.
|
|
47
|
+
* @deprecated Use the `Custom` type to follow the guidance that labels
|
|
48
|
+
* should clearly indicate the actions that occur when users select buttons.
|
|
49
|
+
*/
|
|
50
|
+
SkyConfirmType[SkyConfirmType["YesCancel"] = 2] = "YesCancel";
|
|
51
|
+
/**
|
|
52
|
+
* Displays three buttons with **Yes**, **No**, and **Cancel** labels.
|
|
53
|
+
* @deprecated Use the `Custom` type to follow the guidance that labels
|
|
54
|
+
* should clearly indicate the actions that occur when users select buttons.
|
|
55
|
+
*/
|
|
56
|
+
SkyConfirmType[SkyConfirmType["YesNoCancel"] = 3] = "YesNoCancel";
|
|
57
|
+
})(SkyConfirmType || (SkyConfirmType = {}));
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* NOTICE: DO NOT MODIFY THIS FILE!
|
|
61
|
+
* The contents of this file were automatically generated by
|
|
62
|
+
* the 'ng generate @skyux/i18n:lib-resources-module lib/modules/shared/sky-modals' schematic.
|
|
63
|
+
* To update this file, simply rerun the command.
|
|
64
|
+
*/
|
|
65
|
+
const RESOURCES = {
|
|
66
|
+
'EN-US': {
|
|
67
|
+
skyux_confirm_dialog_default_ok_text: { message: 'OK' },
|
|
68
|
+
skyux_confirm_dialog_default_yes_text: { message: 'Yes' },
|
|
69
|
+
skyux_confirm_dialog_default_no_text: { message: 'No' },
|
|
70
|
+
skyux_confirm_dialog_default_cancel_text: { message: 'Cancel' },
|
|
71
|
+
skyux_modal_close: { message: 'Close modal' },
|
|
72
|
+
skyux_modal_open_help: { message: 'Open Help' },
|
|
73
|
+
skyux_modal_footer_cancel_button: { message: 'Cancel' },
|
|
74
|
+
skyux_modal_footer_primary_button: { message: 'Save' },
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
class SkyModalsResourcesProvider {
|
|
78
|
+
getString(localeInfo, name) {
|
|
79
|
+
return getLibStringForLocale(RESOURCES, localeInfo.locale, name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Import into any component library module that needs to use resource strings.
|
|
84
|
+
*/
|
|
85
|
+
class SkyModalsResourcesModule {
|
|
86
|
+
}
|
|
87
|
+
SkyModalsResourcesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalsResourcesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
88
|
+
SkyModalsResourcesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalsResourcesModule, exports: [SkyI18nModule] });
|
|
89
|
+
SkyModalsResourcesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalsResourcesModule, providers: [
|
|
90
|
+
{
|
|
91
|
+
provide: SKY_LIB_RESOURCES_PROVIDERS,
|
|
92
|
+
useClass: SkyModalsResourcesProvider,
|
|
93
|
+
multi: true,
|
|
94
|
+
},
|
|
95
|
+
], imports: [SkyI18nModule] });
|
|
96
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalsResourcesModule, decorators: [{
|
|
97
|
+
type: NgModule,
|
|
98
|
+
args: [{
|
|
99
|
+
exports: [SkyI18nModule],
|
|
100
|
+
providers: [
|
|
101
|
+
{
|
|
102
|
+
provide: SKY_LIB_RESOURCES_PROVIDERS,
|
|
103
|
+
useClass: SkyModalsResourcesProvider,
|
|
104
|
+
multi: true,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
}]
|
|
108
|
+
}] });
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Specifies content to display in the modal's body.
|
|
112
|
+
*/
|
|
113
|
+
class SkyModalContentComponent {
|
|
114
|
+
}
|
|
115
|
+
SkyModalContentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
116
|
+
SkyModalContentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyModalContentComponent, selector: "sky-modal-content", ngImport: i0, template: "<ng-content></ng-content>\n", styles: ["sky-modal-content{display:block;min-height:100%}.sky-theme-modern sky-modal-content{padding:10px 30px 30px}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
117
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalContentComponent, decorators: [{
|
|
118
|
+
type: Component,
|
|
119
|
+
args: [{ selector: 'sky-modal-content', encapsulation: ViewEncapsulation.None, template: "<ng-content></ng-content>\n", styles: ["sky-modal-content{display:block;min-height:100%}.sky-theme-modern sky-modal-content{padding:10px 30px 30px}\n"] }]
|
|
120
|
+
}] });
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Specifies content to display in the modal's footer.
|
|
124
|
+
*/
|
|
125
|
+
class SkyModalFooterComponent {
|
|
126
|
+
}
|
|
127
|
+
SkyModalFooterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalFooterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
128
|
+
SkyModalFooterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyModalFooterComponent, selector: "sky-modal-footer", ngImport: i0, template: "<div class=\"sky-modal-footer-container sky-padding-even-large\">\n <ng-content></ng-content>\n</div>\n", styles: [".sky-modal-footer-container{background-color:#fff;border-top:1px solid #e2e3e4}.sky-modal-footer-container ::ng-deep .sky-btn-link:first-child{margin-left:-12px}:host-context(.sky-theme-modern) .sky-modal-footer-container{border-top:none;padding:20px 30px}.sky-theme-modern .sky-modal-footer-container{border-top:none;padding:20px 30px}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-footer-container{background-color:transparent}.sky-theme-modern.sky-theme-mode-dark .sky-modal-footer-container{background-color:transparent}\n"] });
|
|
129
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalFooterComponent, decorators: [{
|
|
130
|
+
type: Component,
|
|
131
|
+
args: [{ selector: 'sky-modal-footer', template: "<div class=\"sky-modal-footer-container sky-padding-even-large\">\n <ng-content></ng-content>\n</div>\n", styles: [".sky-modal-footer-container{background-color:#fff;border-top:1px solid #e2e3e4}.sky-modal-footer-container ::ng-deep .sky-btn-link:first-child{margin-left:-12px}:host-context(.sky-theme-modern) .sky-modal-footer-container{border-top:none;padding:20px 30px}.sky-theme-modern .sky-modal-footer-container{border-top:none;padding:20px 30px}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-footer-container{background-color:transparent}.sky-theme-modern.sky-theme-mode-dark .sky-modal-footer-container{background-color:transparent}\n"] }]
|
|
132
|
+
}] });
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Specifies a header for the modal.
|
|
136
|
+
*/
|
|
137
|
+
class SkyModalHeaderComponent {
|
|
138
|
+
}
|
|
139
|
+
SkyModalHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
140
|
+
SkyModalHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyModalHeaderComponent, selector: "sky-modal-header", ngImport: i0, template: "<h1\n class=\"sky-emphasized\"\n [skyThemeClass]=\"{\n 'sky-font-display-3': 'modern'\n }\"\n>\n <ng-content></ng-content>\n</h1>\n", styles: ["h1{margin:0;line-height:1.2}:host-context(.sky-theme-modern.sky-theme-mode-dark) h1{color:#fbfcfe}.sky-theme-modern.sky-theme-mode-dark h1{color:#fbfcfe}\n"], directives: [{ type: i1.λ2, selector: "[skyThemeClass]", inputs: ["class", "skyThemeClass"] }] });
|
|
141
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHeaderComponent, decorators: [{
|
|
142
|
+
type: Component,
|
|
143
|
+
args: [{ selector: 'sky-modal-header', template: "<h1\n class=\"sky-emphasized\"\n [skyThemeClass]=\"{\n 'sky-font-display-3': 'modern'\n }\"\n>\n <ng-content></ng-content>\n</h1>\n", styles: ["h1{margin:0;line-height:1.2}:host-context(.sky-theme-modern.sky-theme-mode-dark) h1{color:#fbfcfe}.sky-theme-modern.sky-theme-mode-dark h1{color:#fbfcfe}\n"] }]
|
|
144
|
+
}] });
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
class SkyModalAdapterService {
|
|
150
|
+
constructor(windowRef) {
|
|
151
|
+
this.windowRef = windowRef;
|
|
152
|
+
this.docRef = this.windowRef.nativeWindow.document;
|
|
153
|
+
this.bodyEl = this.windowRef.nativeWindow.document.body;
|
|
154
|
+
}
|
|
155
|
+
toggleFullPageModalClass(isAddFull) {
|
|
156
|
+
if (isAddFull) {
|
|
157
|
+
this.addClassToBody(SkyModalAdapterService.MODAL_BODY_FULL_CLASS);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this.removeClassFromBody(SkyModalAdapterService.MODAL_BODY_FULL_CLASS);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
setPageScroll(isAdd) {
|
|
164
|
+
if (isAdd) {
|
|
165
|
+
this.addClassToBody(SkyModalAdapterService.MODAL_BODY_CLASS);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this.removeClassFromBody(SkyModalAdapterService.MODAL_BODY_CLASS);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
getModalOpener() {
|
|
172
|
+
return this.docRef.activeElement;
|
|
173
|
+
}
|
|
174
|
+
addClassToBody(className) {
|
|
175
|
+
this.bodyEl.classList.add(className);
|
|
176
|
+
}
|
|
177
|
+
removeClassFromBody(className) {
|
|
178
|
+
this.bodyEl.classList.remove(className);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
SkyModalAdapterService.MODAL_BODY_FULL_CLASS = 'sky-modal-body-full-page';
|
|
182
|
+
SkyModalAdapterService.MODAL_BODY_CLASS = 'sky-modal-body-open';
|
|
183
|
+
SkyModalAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalAdapterService, deps: [{ token: i3.SkyAppWindowRef }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
184
|
+
SkyModalAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalAdapterService });
|
|
185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalAdapterService, decorators: [{
|
|
186
|
+
type: Injectable
|
|
187
|
+
}], ctorParameters: function () { return [{ type: i3.SkyAppWindowRef }]; } });
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
class SkyModalConfiguration {
|
|
193
|
+
constructor() {
|
|
194
|
+
this.size = 'medium';
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
SkyModalConfiguration.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalConfiguration, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
198
|
+
SkyModalConfiguration.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalConfiguration, providedIn: 'any' });
|
|
199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalConfiguration, decorators: [{
|
|
200
|
+
type: Injectable,
|
|
201
|
+
args: [{
|
|
202
|
+
providedIn: 'any',
|
|
203
|
+
}]
|
|
204
|
+
}], ctorParameters: function () { return []; } });
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
* @dynamic
|
|
209
|
+
*/
|
|
210
|
+
class SkyModalHostService {
|
|
211
|
+
constructor() {
|
|
212
|
+
this.close = new EventEmitter();
|
|
213
|
+
this.fullPage = false;
|
|
214
|
+
this.openHelp = new EventEmitter();
|
|
215
|
+
SkyModalHostService.modalHosts.push(this);
|
|
216
|
+
}
|
|
217
|
+
static get openModalCount() {
|
|
218
|
+
return SkyModalHostService.modalHosts.length;
|
|
219
|
+
}
|
|
220
|
+
static get fullPageModalCount() {
|
|
221
|
+
const fullPageModals = SkyModalHostService.modalHosts.filter((modal) => modal.fullPage);
|
|
222
|
+
return fullPageModals.length;
|
|
223
|
+
}
|
|
224
|
+
static get BASE_Z_INDEX() {
|
|
225
|
+
return 1040;
|
|
226
|
+
}
|
|
227
|
+
static get backdropZIndex() {
|
|
228
|
+
return (SkyModalHostService.BASE_Z_INDEX +
|
|
229
|
+
SkyModalHostService.modalHosts.length * 10);
|
|
230
|
+
}
|
|
231
|
+
static get topModal() {
|
|
232
|
+
return SkyModalHostService.modalHosts[SkyModalHostService.modalHosts.length - 1];
|
|
233
|
+
}
|
|
234
|
+
getModalZIndex() {
|
|
235
|
+
let zIndex = SkyModalHostService.BASE_Z_INDEX + 1;
|
|
236
|
+
zIndex += (SkyModalHostService.modalHosts.indexOf(this) + 1) * 10;
|
|
237
|
+
return zIndex;
|
|
238
|
+
}
|
|
239
|
+
onClose() {
|
|
240
|
+
this.close.emit();
|
|
241
|
+
}
|
|
242
|
+
onOpenHelp(helpKey) {
|
|
243
|
+
this.openHelp.emit(helpKey);
|
|
244
|
+
}
|
|
245
|
+
destroy() {
|
|
246
|
+
SkyModalHostService.modalHosts.splice(SkyModalHostService.modalHosts.indexOf(this), 1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
SkyModalHostService.modalHosts = [];
|
|
250
|
+
SkyModalHostService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHostService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
251
|
+
SkyModalHostService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHostService, providedIn: 'root' });
|
|
252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHostService, decorators: [{
|
|
253
|
+
type: Injectable,
|
|
254
|
+
args: [{
|
|
255
|
+
providedIn: 'root',
|
|
256
|
+
}]
|
|
257
|
+
}], ctorParameters: function () { return []; } });
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @internal
|
|
261
|
+
*/
|
|
262
|
+
class SkyModalHostComponent {
|
|
263
|
+
constructor(resolver, adapter, injector, router, changeDetector) {
|
|
264
|
+
this.resolver = resolver;
|
|
265
|
+
this.adapter = adapter;
|
|
266
|
+
this.injector = injector;
|
|
267
|
+
this.router = router;
|
|
268
|
+
this.changeDetector = changeDetector;
|
|
269
|
+
}
|
|
270
|
+
get modalOpen() {
|
|
271
|
+
return SkyModalHostService.openModalCount > 0;
|
|
272
|
+
}
|
|
273
|
+
get backdropZIndex() {
|
|
274
|
+
return SkyModalHostService.backdropZIndex;
|
|
275
|
+
}
|
|
276
|
+
open(modalInstance, component, config) {
|
|
277
|
+
const params = Object.assign({}, config);
|
|
278
|
+
const factory = this.resolver.resolveComponentFactory(component);
|
|
279
|
+
const hostService = new SkyModalHostService();
|
|
280
|
+
hostService.fullPage = !!params.fullPage;
|
|
281
|
+
const adapter = this.adapter;
|
|
282
|
+
const modalOpener = adapter.getModalOpener();
|
|
283
|
+
let isOpen = true;
|
|
284
|
+
params.providers.push({
|
|
285
|
+
provide: SkyModalHostService,
|
|
286
|
+
useValue: hostService,
|
|
287
|
+
});
|
|
288
|
+
params.providers.push({
|
|
289
|
+
provide: SkyModalConfiguration,
|
|
290
|
+
useValue: params,
|
|
291
|
+
});
|
|
292
|
+
adapter.setPageScroll(SkyModalHostService.openModalCount > 0);
|
|
293
|
+
adapter.toggleFullPageModalClass(SkyModalHostService.fullPageModalCount > 0);
|
|
294
|
+
const providers = params.providers || /* istanbul ignore next */ [];
|
|
295
|
+
const injector = Injector.create({
|
|
296
|
+
providers,
|
|
297
|
+
parent: this.injector,
|
|
298
|
+
});
|
|
299
|
+
const modalComponentRef = this.target.createComponent(factory, undefined, injector);
|
|
300
|
+
modalInstance.componentInstance = modalComponentRef.instance;
|
|
301
|
+
function closeModal() {
|
|
302
|
+
hostService.destroy();
|
|
303
|
+
adapter.setPageScroll(SkyModalHostService.openModalCount > 0);
|
|
304
|
+
adapter.toggleFullPageModalClass(SkyModalHostService.fullPageModalCount > 0);
|
|
305
|
+
/* istanbul ignore else */
|
|
306
|
+
/* sanity check */
|
|
307
|
+
if (modalOpener && modalOpener.focus) {
|
|
308
|
+
modalOpener.focus();
|
|
309
|
+
}
|
|
310
|
+
modalComponentRef.destroy();
|
|
311
|
+
}
|
|
312
|
+
hostService.openHelp.subscribe((helpKey) => {
|
|
313
|
+
modalInstance.openHelp(helpKey);
|
|
314
|
+
});
|
|
315
|
+
hostService.close.subscribe(() => {
|
|
316
|
+
modalInstance.close();
|
|
317
|
+
});
|
|
318
|
+
this.router.events.pipe(takeWhile(() => isOpen)).subscribe((event) => {
|
|
319
|
+
/* istanbul ignore else */
|
|
320
|
+
if (event instanceof NavigationStart) {
|
|
321
|
+
modalInstance.close();
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
modalInstance.closed.subscribe(() => {
|
|
325
|
+
isOpen = false;
|
|
326
|
+
closeModal();
|
|
327
|
+
});
|
|
328
|
+
// Necessary if the host was created via a consumer's lifecycle hook such as ngOnInit
|
|
329
|
+
this.changeDetector.detectChanges();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
SkyModalHostComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHostComponent, deps: [{ token: i0.ComponentFactoryResolver }, { token: SkyModalAdapterService }, { token: i0.Injector }, { token: i2.Router }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
333
|
+
SkyModalHostComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyModalHostComponent, selector: "sky-modal-host", viewQueries: [{ propertyName: "target", first: true, predicate: ["target"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<div\n class=\"sky-modal-host-backdrop\"\n [hidden]=\"!modalOpen\"\n [ngStyle]=\"{\n zIndex: backdropZIndex\n }\"\n></div>\n<div #target></div>\n", styles: [".sky-modal-host-backdrop{background-color:#00000080;position:fixed;top:0;left:0;bottom:0;right:0}\n"], directives: [{ type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], viewProviders: [SkyModalAdapterService] });
|
|
334
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalHostComponent, decorators: [{
|
|
335
|
+
type: Component,
|
|
336
|
+
args: [{ selector: 'sky-modal-host', viewProviders: [SkyModalAdapterService], template: "<div\n class=\"sky-modal-host-backdrop\"\n [hidden]=\"!modalOpen\"\n [ngStyle]=\"{\n zIndex: backdropZIndex\n }\"\n></div>\n<div #target></div>\n", styles: [".sky-modal-host-backdrop{background-color:#00000080;position:fixed;top:0;left:0;bottom:0;right:0}\n"] }]
|
|
337
|
+
}], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: SkyModalAdapterService }, { type: i0.Injector }, { type: i2.Router }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { target: [{
|
|
338
|
+
type: ViewChild,
|
|
339
|
+
args: ['target', {
|
|
340
|
+
read: ViewContainerRef,
|
|
341
|
+
static: true,
|
|
342
|
+
}]
|
|
343
|
+
}] } });
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Raises an event when the box shadow for the modal header or footer should be adjusted
|
|
347
|
+
* based on the scroll position of the host element.
|
|
348
|
+
* @internal
|
|
349
|
+
*/
|
|
350
|
+
class SkyModalScrollShadowDirective {
|
|
351
|
+
constructor(elRef, themeSvc, mutationObserverSvc, ngZone) {
|
|
352
|
+
this.elRef = elRef;
|
|
353
|
+
this.themeSvc = themeSvc;
|
|
354
|
+
this.mutationObserverSvc = mutationObserverSvc;
|
|
355
|
+
this.ngZone = ngZone;
|
|
356
|
+
this.skyModalScrollShadow = new EventEmitter();
|
|
357
|
+
this.ngUnsubscribe = new Subject();
|
|
358
|
+
}
|
|
359
|
+
windowResize() {
|
|
360
|
+
this.checkForShadow();
|
|
361
|
+
}
|
|
362
|
+
scroll() {
|
|
363
|
+
this.checkForShadow();
|
|
364
|
+
}
|
|
365
|
+
ngOnInit() {
|
|
366
|
+
if (this.themeSvc) {
|
|
367
|
+
this.themeSvc.settingsChange
|
|
368
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
369
|
+
.subscribe((themeSettings) => {
|
|
370
|
+
this.currentTheme = themeSettings.currentSettings.theme;
|
|
371
|
+
if (this.currentTheme === SkyTheme.presets.modern) {
|
|
372
|
+
this.initMutationObserver();
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
this.emitShadow({
|
|
376
|
+
bottomShadow: 'none',
|
|
377
|
+
topShadow: 'none',
|
|
378
|
+
});
|
|
379
|
+
this.destroyMutationObserver();
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
ngOnDestroy() {
|
|
385
|
+
this.ngUnsubscribe.next();
|
|
386
|
+
this.ngUnsubscribe.complete();
|
|
387
|
+
this.destroyMutationObserver();
|
|
388
|
+
}
|
|
389
|
+
initMutationObserver() {
|
|
390
|
+
if (!this.mutationObserver) {
|
|
391
|
+
const el = this.elRef.nativeElement;
|
|
392
|
+
// MutationObserver is patched by Zone.js and therefore becomes part of the
|
|
393
|
+
// Angular change detection cycle, but this can lead to infinite loops in some
|
|
394
|
+
// secnarios. This will keep MutationObserver from triggering change detection.
|
|
395
|
+
this.ngZone.runOutsideAngular(() => {
|
|
396
|
+
this.mutationObserver = this.mutationObserverSvc.create(() => {
|
|
397
|
+
this.checkForShadow();
|
|
398
|
+
});
|
|
399
|
+
this.mutationObserver.observe(el, {
|
|
400
|
+
attributes: true,
|
|
401
|
+
characterData: true,
|
|
402
|
+
childList: true,
|
|
403
|
+
subtree: true,
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
destroyMutationObserver() {
|
|
409
|
+
if (this.mutationObserver) {
|
|
410
|
+
this.mutationObserver.disconnect();
|
|
411
|
+
this.mutationObserver = undefined;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
checkForShadow() {
|
|
415
|
+
if (this.currentTheme === SkyTheme.presets.modern) {
|
|
416
|
+
const el = this.elRef.nativeElement;
|
|
417
|
+
const topShadow = this.buildShadowStyle(el.scrollTop);
|
|
418
|
+
const bottomShadow = this.buildShadowStyle(el.scrollHeight - el.scrollTop - el.clientHeight);
|
|
419
|
+
this.emitShadow({
|
|
420
|
+
bottomShadow,
|
|
421
|
+
topShadow,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
buildShadowStyle(pixelsFromEnd) {
|
|
426
|
+
// Progressively darken the shadow until the user scrolls 30 pixels from the top or bottom
|
|
427
|
+
// of the scrollable element, with a max opacity of 0.3.
|
|
428
|
+
const opacity = Math.min(pixelsFromEnd / 30, 1) * 0.3;
|
|
429
|
+
return opacity > 0 ? `0px 1px 8px 0px rgba(0, 0, 0, ${opacity})` : 'none';
|
|
430
|
+
}
|
|
431
|
+
emitShadow(shadow) {
|
|
432
|
+
if (!this.currentShadow ||
|
|
433
|
+
this.currentShadow.bottomShadow !== shadow.bottomShadow ||
|
|
434
|
+
this.currentShadow.topShadow !== shadow.topShadow) {
|
|
435
|
+
this.skyModalScrollShadow.emit(shadow);
|
|
436
|
+
this.currentShadow = shadow;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
SkyModalScrollShadowDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalScrollShadowDirective, deps: [{ token: i0.ElementRef }, { token: i1.SkyThemeService, optional: true }, { token: i3.MutationObserverService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
441
|
+
SkyModalScrollShadowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.2.7", type: SkyModalScrollShadowDirective, selector: "[skyModalScrollShadow]", outputs: { skyModalScrollShadow: "skyModalScrollShadow" }, host: { listeners: { "window:resize": "windowResize()", "scroll": "scroll()" } }, ngImport: i0 });
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalScrollShadowDirective, decorators: [{
|
|
443
|
+
type: Directive,
|
|
444
|
+
args: [{
|
|
445
|
+
selector: '[skyModalScrollShadow]',
|
|
446
|
+
}]
|
|
447
|
+
}], ctorParameters: function () {
|
|
448
|
+
return [{ type: i0.ElementRef }, { type: i1.SkyThemeService, decorators: [{
|
|
449
|
+
type: Optional
|
|
450
|
+
}] }, { type: i3.MutationObserverService }, { type: i0.NgZone }];
|
|
451
|
+
}, propDecorators: { skyModalScrollShadow: [{
|
|
452
|
+
type: Output
|
|
453
|
+
}], windowResize: [{
|
|
454
|
+
type: HostListener,
|
|
455
|
+
args: ['window:resize']
|
|
456
|
+
}], scroll: [{
|
|
457
|
+
type: HostListener,
|
|
458
|
+
args: ['scroll']
|
|
459
|
+
}] } });
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @internal
|
|
463
|
+
*/
|
|
464
|
+
class SkyModalComponentAdapterService {
|
|
465
|
+
constructor(coreAdapter) {
|
|
466
|
+
this.coreAdapter = coreAdapter;
|
|
467
|
+
}
|
|
468
|
+
handleWindowChange(modalEl) {
|
|
469
|
+
const boundedHeightEl = modalEl.nativeElement.querySelector('.sky-modal');
|
|
470
|
+
const fullPageModalEl = modalEl.nativeElement.querySelector('.sky-modal-full-page');
|
|
471
|
+
/*
|
|
472
|
+
Set modal height equal to max height of window (accounting for padding above and below modal)
|
|
473
|
+
*/
|
|
474
|
+
const newHeight = window.innerHeight - 40;
|
|
475
|
+
boundedHeightEl.style.maxHeight = newHeight.toString() + 'px';
|
|
476
|
+
if (fullPageModalEl) {
|
|
477
|
+
this.setFullPageHeight(fullPageModalEl);
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
/*
|
|
481
|
+
IE11 doesn't handle flex and max-height correctly so we have to explicitly add
|
|
482
|
+
max-height to the content that accounts for standard header and footer height.
|
|
483
|
+
*/
|
|
484
|
+
const modalContentEl = modalEl.nativeElement.querySelector('.sky-modal-content');
|
|
485
|
+
const contentHeight = newHeight - 114;
|
|
486
|
+
modalContentEl.style.maxHeight = contentHeight.toString() + 'px';
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
isFocusInFirstItem(event, list) {
|
|
490
|
+
/* istanbul ignore next */
|
|
491
|
+
/* sanity check */
|
|
492
|
+
const eventTarget = event.target || event.srcElement;
|
|
493
|
+
return list.length > 0 && eventTarget === list[0];
|
|
494
|
+
}
|
|
495
|
+
isFocusInLastItem(event, list) {
|
|
496
|
+
/* istanbul ignore next */
|
|
497
|
+
/* sanity check */
|
|
498
|
+
const eventTarget = event.target || event.srcElement;
|
|
499
|
+
return list.length > 0 && eventTarget === list[list.length - 1];
|
|
500
|
+
}
|
|
501
|
+
isModalFocused(event, modalEl) {
|
|
502
|
+
/* istanbul ignore next */
|
|
503
|
+
/* sanity check */
|
|
504
|
+
const eventTarget = event.target || event.srcElement;
|
|
505
|
+
return (modalEl &&
|
|
506
|
+
eventTarget === modalEl.nativeElement.querySelector('.sky-modal-dialog'));
|
|
507
|
+
}
|
|
508
|
+
focusLastElement(list) {
|
|
509
|
+
if (list.length > 0) {
|
|
510
|
+
list[list.length - 1].focus();
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
focusFirstElement(list) {
|
|
516
|
+
if (list.length > 0) {
|
|
517
|
+
list[0].focus();
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
modalOpened(modalEl) {
|
|
523
|
+
/* istanbul ignore else */
|
|
524
|
+
/* handle the case where somehow there is a focused element already in the modal */
|
|
525
|
+
if (!(document.activeElement &&
|
|
526
|
+
modalEl.nativeElement.contains(document.activeElement))) {
|
|
527
|
+
const currentScrollX = window.pageXOffset;
|
|
528
|
+
const currentScrollY = window.pageYOffset;
|
|
529
|
+
const inputWithAutofocus = modalEl.nativeElement.querySelector('[autofocus]');
|
|
530
|
+
if (inputWithAutofocus) {
|
|
531
|
+
inputWithAutofocus.focus();
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
this.coreAdapter.getFocusableChildrenAndApplyFocus(modalEl, '.sky-modal-content', true);
|
|
535
|
+
}
|
|
536
|
+
window.scrollTo(currentScrollX, currentScrollY);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
setFullPageHeight(fullPageModalEl) {
|
|
540
|
+
const windowHeight = window.innerHeight;
|
|
541
|
+
const fullPageModalStyle = getComputedStyle(fullPageModalEl);
|
|
542
|
+
const marginTopBottom = parseInt(fullPageModalStyle.marginTop, 10) +
|
|
543
|
+
parseInt(fullPageModalStyle.marginBottom, 10);
|
|
544
|
+
const fullPageModalHeight = windowHeight - marginTopBottom + 'px';
|
|
545
|
+
fullPageModalEl.style.height = fullPageModalHeight;
|
|
546
|
+
fullPageModalEl.style.maxHeight = fullPageModalHeight;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
SkyModalComponentAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalComponentAdapterService, deps: [{ token: i3.SkyCoreAdapterService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
550
|
+
SkyModalComponentAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalComponentAdapterService });
|
|
551
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalComponentAdapterService, decorators: [{
|
|
552
|
+
type: Injectable
|
|
553
|
+
}], ctorParameters: function () { return [{ type: i3.SkyCoreAdapterService }]; } });
|
|
554
|
+
|
|
555
|
+
const skyAnimationModalState = trigger('modalState', [
|
|
556
|
+
state('in', style({ opacity: '1.0' })),
|
|
557
|
+
state('out', style({ opacity: '0.0' })),
|
|
558
|
+
transition('void => *', [style({ opacity: '0.0' }), animate(150)]),
|
|
559
|
+
transition('* => void', [animate(150, style({ opacity: '0.0' }))]),
|
|
560
|
+
]);
|
|
561
|
+
|
|
562
|
+
let skyModalUniqueIdentifier = 0;
|
|
563
|
+
/**
|
|
564
|
+
* Provides a common look-and-feel for modal content with options to display
|
|
565
|
+
* a common modal header, specify body content, and display a common modal footer
|
|
566
|
+
* and buttons. For information about how to test modals in SKY UX, see
|
|
567
|
+
* [write unit tests for modals](https://developer.blackbaud.com/skyux/learn/get-started/advanced/unit-test-modals).
|
|
568
|
+
*/
|
|
569
|
+
class SkyModalComponent {
|
|
570
|
+
constructor(hostService, config, elRef, windowRef, componentAdapter, coreAdapter, dockService) {
|
|
571
|
+
this.hostService = hostService;
|
|
572
|
+
this.config = config;
|
|
573
|
+
this.elRef = elRef;
|
|
574
|
+
this.windowRef = windowRef;
|
|
575
|
+
this.componentAdapter = componentAdapter;
|
|
576
|
+
this.coreAdapter = coreAdapter;
|
|
577
|
+
this.dockService = dockService;
|
|
578
|
+
this.modalState = 'in';
|
|
579
|
+
this.modalContentId = 'sky-modal-content-id-' + skyModalUniqueIdentifier.toString();
|
|
580
|
+
this.modalHeaderId = 'sky-modal-header-id-' + skyModalUniqueIdentifier.toString();
|
|
581
|
+
}
|
|
582
|
+
get wrapperClass() {
|
|
583
|
+
return this.config.wrapperClass;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* @internal
|
|
587
|
+
*/
|
|
588
|
+
get ariaRole() {
|
|
589
|
+
return this.config.ariaRole || 'dialog';
|
|
590
|
+
}
|
|
591
|
+
set ariaRole(value) {
|
|
592
|
+
this.config.ariaRole = value;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* @internal
|
|
596
|
+
*/
|
|
597
|
+
set tiledBody(value) {
|
|
598
|
+
this.config.tiledBody = value;
|
|
599
|
+
}
|
|
600
|
+
get modalZIndex() {
|
|
601
|
+
return this.hostService.getModalZIndex();
|
|
602
|
+
}
|
|
603
|
+
get modalFullPage() {
|
|
604
|
+
return this.config.fullPage;
|
|
605
|
+
}
|
|
606
|
+
get isSmallSize() {
|
|
607
|
+
return !this.modalFullPage && this.isSizeEqual(this.config.size, 'small');
|
|
608
|
+
}
|
|
609
|
+
get isMediumSize() {
|
|
610
|
+
return !this.modalFullPage && !(this.isSmallSize || this.isLargeSize);
|
|
611
|
+
}
|
|
612
|
+
get isLargeSize() {
|
|
613
|
+
return !this.modalFullPage && this.isSizeEqual(this.config.size, 'large');
|
|
614
|
+
}
|
|
615
|
+
get isTiledBody() {
|
|
616
|
+
return this.config.tiledBody;
|
|
617
|
+
}
|
|
618
|
+
get ariaDescribedBy() {
|
|
619
|
+
return this.config.ariaDescribedBy || this.modalContentId;
|
|
620
|
+
}
|
|
621
|
+
get ariaLabelledBy() {
|
|
622
|
+
return this.config.ariaLabelledBy || this.modalHeaderId;
|
|
623
|
+
}
|
|
624
|
+
get helpKey() {
|
|
625
|
+
return this.config.helpKey;
|
|
626
|
+
}
|
|
627
|
+
onDocumentKeyUp(event) {
|
|
628
|
+
/* istanbul ignore else */
|
|
629
|
+
/* sanity check */
|
|
630
|
+
if (SkyModalHostService.openModalCount > 0) {
|
|
631
|
+
const topModal = SkyModalHostService.topModal;
|
|
632
|
+
if (topModal && topModal === this.hostService) {
|
|
633
|
+
if (event.which === 27) {
|
|
634
|
+
// Escape key up
|
|
635
|
+
event.preventDefault();
|
|
636
|
+
this.closeButtonClick();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
onDocumentKeyDown(event) {
|
|
642
|
+
/* istanbul ignore else */
|
|
643
|
+
/* sanity check */
|
|
644
|
+
if (SkyModalHostService.openModalCount > 0) {
|
|
645
|
+
const topModal = SkyModalHostService.topModal;
|
|
646
|
+
if (topModal && topModal === this.hostService) {
|
|
647
|
+
if (event.which === 9) {
|
|
648
|
+
// Tab pressed
|
|
649
|
+
let focusChanged = false;
|
|
650
|
+
const focusElementList = this.coreAdapter.getFocusableChildren(this.elRef.nativeElement);
|
|
651
|
+
if (event.shiftKey &&
|
|
652
|
+
(this.componentAdapter.isFocusInFirstItem(event, focusElementList) ||
|
|
653
|
+
this.componentAdapter.isModalFocused(event, this.elRef))) {
|
|
654
|
+
focusChanged =
|
|
655
|
+
this.componentAdapter.focusLastElement(focusElementList);
|
|
656
|
+
}
|
|
657
|
+
else if (!event.shiftKey &&
|
|
658
|
+
this.componentAdapter.isFocusInLastItem(event, focusElementList)) {
|
|
659
|
+
focusChanged =
|
|
660
|
+
this.componentAdapter.focusFirstElement(focusElementList);
|
|
661
|
+
}
|
|
662
|
+
if (focusChanged) {
|
|
663
|
+
event.preventDefault();
|
|
664
|
+
event.stopPropagation();
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
ngAfterViewInit() {
|
|
671
|
+
skyModalUniqueIdentifier++;
|
|
672
|
+
this.componentAdapter.handleWindowChange(this.elRef);
|
|
673
|
+
// Adding a timeout to avoid ExpressionChangedAfterItHasBeenCheckedError.
|
|
674
|
+
// https://stackoverflow.com/questions/40562845
|
|
675
|
+
this.windowRef.nativeWindow.setTimeout(() => {
|
|
676
|
+
this.componentAdapter.modalOpened(this.elRef);
|
|
677
|
+
});
|
|
678
|
+
this.dockService.setDockOptions({
|
|
679
|
+
location: SkyDockLocation.ElementBottom,
|
|
680
|
+
referenceEl: this.modalContentWrapperElement.nativeElement,
|
|
681
|
+
zIndex: 5,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
helpButtonClick() {
|
|
685
|
+
this.hostService.onOpenHelp(this.helpKey);
|
|
686
|
+
}
|
|
687
|
+
closeButtonClick() {
|
|
688
|
+
this.hostService.onClose();
|
|
689
|
+
}
|
|
690
|
+
windowResize() {
|
|
691
|
+
this.componentAdapter.handleWindowChange(this.elRef);
|
|
692
|
+
}
|
|
693
|
+
scrollShadowChange(args) {
|
|
694
|
+
this.scrollShadow = args;
|
|
695
|
+
}
|
|
696
|
+
isSizeEqual(actualSize, size) {
|
|
697
|
+
return actualSize && actualSize.toLowerCase() === size;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
SkyModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalComponent, deps: [{ token: SkyModalHostService }, { token: SkyModalConfiguration }, { token: i0.ElementRef }, { token: i3.SkyAppWindowRef }, { token: SkyModalComponentAdapterService }, { token: i3.SkyCoreAdapterService }, { token: i3.SkyDockService, host: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
701
|
+
SkyModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyModalComponent, selector: "sky-modal", inputs: { ariaRole: "ariaRole", tiledBody: "tiledBody" }, host: { listeners: { "document:keyup": "onDocumentKeyUp($event)", "document:keydown": "onDocumentKeyDown($event)" }, properties: { "class": "this.wrapperClass" } }, providers: [SkyModalComponentAdapterService, SkyDockService], viewQueries: [{ propertyName: "modalContentWrapperElement", first: true, predicate: ["modalContentWrapper"], descendants: true, read: ElementRef }], ngImport: i0, template: "<!--\n Animations are broken in Chrome v52. Angular 2 RC5 will fix it.\n https://github.com/angular/angular/issues/10245\n-->\n<!--<div @modalState=\"modalState\">-->\n\n<div\n class=\"sky-modal-dialog\"\n aria-modal=\"true\"\n [attr.aria-describedby]=\"ariaDescribedBy\"\n [attr.aria-labelledby]=\"ariaLabelledBy\"\n [attr.role]=\"ariaRole\"\n (window:resize)=\"windowResize()\"\n>\n <div\n class=\"sky-modal sky-shadow sky-box sky-elevation-16\"\n tabindex=\"-1\"\n [ngClass]=\"{\n 'sky-modal-full-page': modalFullPage,\n 'sky-modal-small': isSmallSize,\n 'sky-modal-medium': isMediumSize,\n 'sky-modal-large': isLargeSize,\n 'sky-modal-tiled': isTiledBody\n }\"\n [ngStyle]=\"{\n zIndex: modalZIndex\n }\"\n >\n <div\n class=\"sky-modal-header\"\n [hidden]=\"!headerContent || !headerContent.children || headerContent.children.length < 1\"\n [ngStyle]=\"{\n 'box-shadow': scrollShadow?.topShadow\n }\"\n >\n <div\n class=\"sky-modal-header-content\"\n [attr.id]=\"modalHeaderId\"\n [ngClass]=\"{\n 'sky-section-heading': modalFullPage\n }\"\n #headerContent\n >\n <ng-content select=\"sky-modal-header\"></ng-content>\n </div>\n <div class=\"sky-modal-header-buttons\">\n <button\n *ngIf=\"helpKey\"\n class=\"sky-btn sky-modal-btn-help\"\n name=\"help-button\"\n type=\"button\"\n [attr.aria-label]=\"'skyux_modal_open_help' | skyLibResources\"\n (click)=\"helpButtonClick()\"\n >\n <sky-icon icon=\"question-circle\"></sky-icon>\n </button>\n\n <button\n type=\"button\"\n class=\"sky-btn sky-modal-btn-close\"\n [attr.aria-label]=\"'skyux_modal_close' | skyLibResources\"\n (click)=\"closeButtonClick()\"\n >\n <sky-icon icon=\"close\"></sky-icon>\n </button>\n </div>\n </div>\n <div\n class=\"sky-modal-content sky-padding-even-large\"\n role=\"region\"\n tabindex=\"0\"\n [attr.aria-labelledby]=\"modalHeaderId\"\n [attr.id]=\"modalContentId\"\n (skyModalScrollShadow)=\"scrollShadowChange($event)\"\n #modalContentWrapper\n >\n <ng-content select=\"sky-modal-content\"></ng-content>\n </div>\n <div\n class=\"sky-modal-footer\"\n [ngStyle]=\"{\n 'box-shadow': scrollShadow?.bottomShadow\n }\"\n >\n <ng-content select=\"sky-modal-footer\"></ng-content>\n </div>\n </div>\n</div>\n", styles: [".sky-modal{border-top:1px solid #cdcfd2;border-bottom:1px solid #cdcfd2;border-left:1px solid #cdcfd2;border-right:1px solid #cdcfd2;position:fixed;width:auto;left:0;right:0;top:20px;margin:10px;display:flex;flex-direction:column;overflow:hidden}.sky-modal:focus{outline:none}@media (min-width: 768px){.sky-modal:not(.sky-modal-large){margin:0 auto}.sky-modal-small{width:300px}.sky-modal-small .sky-modal-content,.sky-modal-small .sky-modal-header,.sky-modal-small .sky-modal-footer{max-width:300px}.sky-modal-medium{width:600px}.sky-modal-medium .sky-modal-content,.sky-modal-medium .sky-modal-header,.sky-modal-medium .sky-modal-footer{max-width:600px}}@media (min-width: 920px){.sky-modal-large{margin:0 auto;width:900px}.sky-modal-large .sky-modal-content,.sky-modal-large .sky-modal-header,.sky-modal-large .sky-modal-footer{max-width:900px}}.sky-modal-content{background-color:#fff}.sky-modal-content:focus{outline-style:dotted;outline-width:thin;outline-offset:-1px}.sky-modal-tiled .sky-modal-content{background-color:#eeeeef}.sky-modal-tiled .sky-modal-content ::ng-deep .sky-tile-title{font-family:BLKB Sans,Helvetica Neue,Arial,sans-serif;color:#686c73;font-weight:300;font-size:19px}.sky-modal-header{padding:9px 3px 9px 15px;background-color:#fff;display:flex;align-items:baseline;border-bottom:1px solid #e2e3e4}.sky-modal-header-buttons{flex-shrink:.0001}.sky-modal-header-buttons .sky-btn{border:none;color:#cdcfd2;cursor:pointer}.sky-modal-header-buttons .sky-btn:hover{color:#979ba2;transition:color .15s}.sky-modal-header-content{flex-grow:1}.sky-modal-header{flex-shrink:0;z-index:2}.sky-modal-content{overflow-y:auto}.sky-modal-footer{flex-shrink:0;z-index:2}.sky-modal-footer ::ng-deep sky-tabset-nav-button+sky-tabset-nav-button{margin-left:10px}.sky-modal-footer ::ng-deep sky-tabset-nav-button+.sky-btn{margin-left:10px}.sky-modal-footer ::ng-deep .sky-btn+.sky-btn{margin-left:10px}.sky-modal-footer ::ng-deep .sky-btn+.sky-btn-link{margin-left:-2px}.sky-modal-full-page{width:100%;top:0;margin:0}.sky-modal-full-page .sky-modal-header-buttons sky-icon[icon=close]{font-size:20px}.sky-modal-full-page .sky-modal-content{flex-grow:1}:host ::ng-deep .sky-sectioned-form{min-height:460px;margin:-15px}.sky-modal-content>::ng-deep sky-dock{bottom:-15px;margin-left:-15px;margin-bottom:-15px;padding-top:15px;width:calc(100% + 30px)}:host-context(.sky-theme-modern) .sky-modal-header{border:none;padding:20px 30px}:host-context(.sky-theme-modern) .sky-modal-btn-help,:host-context(.sky-theme-modern) .sky-modal-btn-close{display:none}:host-context(.sky-theme-modern) .sky-modal-content{padding:0}:host-context(.sky-theme-modern) .sky-modal-full-page{width:calc(100% - 60px);margin:30px}:host-context(.sky-theme-modern) .sky-modal-content>::ng-deep sky-dock{bottom:0;margin-left:initial;margin-bottom:initial;padding-top:initial;width:100%}.sky-theme-modern .sky-modal-header{border:none;padding:20px 30px}.sky-theme-modern .sky-modal-btn-help,.sky-theme-modern .sky-modal-btn-close{display:none}.sky-theme-modern .sky-modal-content{padding:0}.sky-theme-modern .sky-modal-full-page{width:calc(100% - 60px);margin:30px}.sky-theme-modern .sky-modal-content>::ng-deep sky-dock{bottom:0;margin-left:initial;margin-bottom:initial;padding-top:initial;width:100%}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal{border-color:#121212}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-header{color:#fbfcfe}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-header,:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-content{background-color:transparent}.sky-theme-modern.sky-theme-mode-dark .sky-modal{border-color:#121212}.sky-theme-modern.sky-theme-mode-dark .sky-modal-header{color:#fbfcfe}.sky-theme-modern.sky-theme-mode-dark .sky-modal-header,.sky-theme-modern.sky-theme-mode-dark .sky-modal-content{background-color:transparent}\n"], components: [{ type: i5.λ4, selector: "sky-icon", inputs: ["icon", "iconType", "size", "fixedWidth", "variant"] }], directives: [{ type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: SkyModalScrollShadowDirective, selector: "[skyModalScrollShadow]", outputs: ["skyModalScrollShadow"] }], pipes: { "skyLibResources": i3$1.SkyLibResourcesPipe }, animations: [skyAnimationModalState] });
|
|
702
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalComponent, decorators: [{
|
|
703
|
+
type: Component,
|
|
704
|
+
args: [{ selector: 'sky-modal', animations: [skyAnimationModalState], providers: [SkyModalComponentAdapterService, SkyDockService], template: "<!--\n Animations are broken in Chrome v52. Angular 2 RC5 will fix it.\n https://github.com/angular/angular/issues/10245\n-->\n<!--<div @modalState=\"modalState\">-->\n\n<div\n class=\"sky-modal-dialog\"\n aria-modal=\"true\"\n [attr.aria-describedby]=\"ariaDescribedBy\"\n [attr.aria-labelledby]=\"ariaLabelledBy\"\n [attr.role]=\"ariaRole\"\n (window:resize)=\"windowResize()\"\n>\n <div\n class=\"sky-modal sky-shadow sky-box sky-elevation-16\"\n tabindex=\"-1\"\n [ngClass]=\"{\n 'sky-modal-full-page': modalFullPage,\n 'sky-modal-small': isSmallSize,\n 'sky-modal-medium': isMediumSize,\n 'sky-modal-large': isLargeSize,\n 'sky-modal-tiled': isTiledBody\n }\"\n [ngStyle]=\"{\n zIndex: modalZIndex\n }\"\n >\n <div\n class=\"sky-modal-header\"\n [hidden]=\"!headerContent || !headerContent.children || headerContent.children.length < 1\"\n [ngStyle]=\"{\n 'box-shadow': scrollShadow?.topShadow\n }\"\n >\n <div\n class=\"sky-modal-header-content\"\n [attr.id]=\"modalHeaderId\"\n [ngClass]=\"{\n 'sky-section-heading': modalFullPage\n }\"\n #headerContent\n >\n <ng-content select=\"sky-modal-header\"></ng-content>\n </div>\n <div class=\"sky-modal-header-buttons\">\n <button\n *ngIf=\"helpKey\"\n class=\"sky-btn sky-modal-btn-help\"\n name=\"help-button\"\n type=\"button\"\n [attr.aria-label]=\"'skyux_modal_open_help' | skyLibResources\"\n (click)=\"helpButtonClick()\"\n >\n <sky-icon icon=\"question-circle\"></sky-icon>\n </button>\n\n <button\n type=\"button\"\n class=\"sky-btn sky-modal-btn-close\"\n [attr.aria-label]=\"'skyux_modal_close' | skyLibResources\"\n (click)=\"closeButtonClick()\"\n >\n <sky-icon icon=\"close\"></sky-icon>\n </button>\n </div>\n </div>\n <div\n class=\"sky-modal-content sky-padding-even-large\"\n role=\"region\"\n tabindex=\"0\"\n [attr.aria-labelledby]=\"modalHeaderId\"\n [attr.id]=\"modalContentId\"\n (skyModalScrollShadow)=\"scrollShadowChange($event)\"\n #modalContentWrapper\n >\n <ng-content select=\"sky-modal-content\"></ng-content>\n </div>\n <div\n class=\"sky-modal-footer\"\n [ngStyle]=\"{\n 'box-shadow': scrollShadow?.bottomShadow\n }\"\n >\n <ng-content select=\"sky-modal-footer\"></ng-content>\n </div>\n </div>\n</div>\n", styles: [".sky-modal{border-top:1px solid #cdcfd2;border-bottom:1px solid #cdcfd2;border-left:1px solid #cdcfd2;border-right:1px solid #cdcfd2;position:fixed;width:auto;left:0;right:0;top:20px;margin:10px;display:flex;flex-direction:column;overflow:hidden}.sky-modal:focus{outline:none}@media (min-width: 768px){.sky-modal:not(.sky-modal-large){margin:0 auto}.sky-modal-small{width:300px}.sky-modal-small .sky-modal-content,.sky-modal-small .sky-modal-header,.sky-modal-small .sky-modal-footer{max-width:300px}.sky-modal-medium{width:600px}.sky-modal-medium .sky-modal-content,.sky-modal-medium .sky-modal-header,.sky-modal-medium .sky-modal-footer{max-width:600px}}@media (min-width: 920px){.sky-modal-large{margin:0 auto;width:900px}.sky-modal-large .sky-modal-content,.sky-modal-large .sky-modal-header,.sky-modal-large .sky-modal-footer{max-width:900px}}.sky-modal-content{background-color:#fff}.sky-modal-content:focus{outline-style:dotted;outline-width:thin;outline-offset:-1px}.sky-modal-tiled .sky-modal-content{background-color:#eeeeef}.sky-modal-tiled .sky-modal-content ::ng-deep .sky-tile-title{font-family:BLKB Sans,Helvetica Neue,Arial,sans-serif;color:#686c73;font-weight:300;font-size:19px}.sky-modal-header{padding:9px 3px 9px 15px;background-color:#fff;display:flex;align-items:baseline;border-bottom:1px solid #e2e3e4}.sky-modal-header-buttons{flex-shrink:.0001}.sky-modal-header-buttons .sky-btn{border:none;color:#cdcfd2;cursor:pointer}.sky-modal-header-buttons .sky-btn:hover{color:#979ba2;transition:color .15s}.sky-modal-header-content{flex-grow:1}.sky-modal-header{flex-shrink:0;z-index:2}.sky-modal-content{overflow-y:auto}.sky-modal-footer{flex-shrink:0;z-index:2}.sky-modal-footer ::ng-deep sky-tabset-nav-button+sky-tabset-nav-button{margin-left:10px}.sky-modal-footer ::ng-deep sky-tabset-nav-button+.sky-btn{margin-left:10px}.sky-modal-footer ::ng-deep .sky-btn+.sky-btn{margin-left:10px}.sky-modal-footer ::ng-deep .sky-btn+.sky-btn-link{margin-left:-2px}.sky-modal-full-page{width:100%;top:0;margin:0}.sky-modal-full-page .sky-modal-header-buttons sky-icon[icon=close]{font-size:20px}.sky-modal-full-page .sky-modal-content{flex-grow:1}:host ::ng-deep .sky-sectioned-form{min-height:460px;margin:-15px}.sky-modal-content>::ng-deep sky-dock{bottom:-15px;margin-left:-15px;margin-bottom:-15px;padding-top:15px;width:calc(100% + 30px)}:host-context(.sky-theme-modern) .sky-modal-header{border:none;padding:20px 30px}:host-context(.sky-theme-modern) .sky-modal-btn-help,:host-context(.sky-theme-modern) .sky-modal-btn-close{display:none}:host-context(.sky-theme-modern) .sky-modal-content{padding:0}:host-context(.sky-theme-modern) .sky-modal-full-page{width:calc(100% - 60px);margin:30px}:host-context(.sky-theme-modern) .sky-modal-content>::ng-deep sky-dock{bottom:0;margin-left:initial;margin-bottom:initial;padding-top:initial;width:100%}.sky-theme-modern .sky-modal-header{border:none;padding:20px 30px}.sky-theme-modern .sky-modal-btn-help,.sky-theme-modern .sky-modal-btn-close{display:none}.sky-theme-modern .sky-modal-content{padding:0}.sky-theme-modern .sky-modal-full-page{width:calc(100% - 60px);margin:30px}.sky-theme-modern .sky-modal-content>::ng-deep sky-dock{bottom:0;margin-left:initial;margin-bottom:initial;padding-top:initial;width:100%}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal{border-color:#121212}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-header{color:#fbfcfe}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-header,:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-modal-content{background-color:transparent}.sky-theme-modern.sky-theme-mode-dark .sky-modal{border-color:#121212}.sky-theme-modern.sky-theme-mode-dark .sky-modal-header{color:#fbfcfe}.sky-theme-modern.sky-theme-mode-dark .sky-modal-header,.sky-theme-modern.sky-theme-mode-dark .sky-modal-content{background-color:transparent}\n"] }]
|
|
705
|
+
}], ctorParameters: function () {
|
|
706
|
+
return [{ type: SkyModalHostService }, { type: SkyModalConfiguration }, { type: i0.ElementRef }, { type: i3.SkyAppWindowRef }, { type: SkyModalComponentAdapterService }, { type: i3.SkyCoreAdapterService }, { type: i3.SkyDockService, decorators: [{
|
|
707
|
+
type: Host
|
|
708
|
+
}] }];
|
|
709
|
+
}, propDecorators: { wrapperClass: [{
|
|
710
|
+
type: HostBinding,
|
|
711
|
+
args: ['class']
|
|
712
|
+
}], ariaRole: [{
|
|
713
|
+
type: Input
|
|
714
|
+
}], tiledBody: [{
|
|
715
|
+
type: Input
|
|
716
|
+
}], modalContentWrapperElement: [{
|
|
717
|
+
type: ViewChild,
|
|
718
|
+
args: ['modalContentWrapper', { read: ElementRef }]
|
|
719
|
+
}], onDocumentKeyUp: [{
|
|
720
|
+
type: HostListener,
|
|
721
|
+
args: ['document:keyup', ['$event']]
|
|
722
|
+
}], onDocumentKeyDown: [{
|
|
723
|
+
type: HostListener,
|
|
724
|
+
args: ['document:keydown', ['$event']]
|
|
725
|
+
}] } });
|
|
726
|
+
|
|
727
|
+
class SkyModalModule {
|
|
728
|
+
}
|
|
729
|
+
SkyModalModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
730
|
+
SkyModalModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalModule, declarations: [SkyModalComponent,
|
|
731
|
+
SkyModalContentComponent,
|
|
732
|
+
SkyModalFooterComponent,
|
|
733
|
+
SkyModalHeaderComponent,
|
|
734
|
+
SkyModalHostComponent,
|
|
735
|
+
SkyModalScrollShadowDirective], imports: [CommonModule,
|
|
736
|
+
RouterModule,
|
|
737
|
+
SkyIconModule,
|
|
738
|
+
SkyModalsResourcesModule,
|
|
739
|
+
SkyThemeModule], exports: [SkyModalComponent,
|
|
740
|
+
SkyModalContentComponent,
|
|
741
|
+
SkyModalFooterComponent,
|
|
742
|
+
SkyModalHeaderComponent] });
|
|
743
|
+
SkyModalModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalModule, imports: [[
|
|
744
|
+
CommonModule,
|
|
745
|
+
RouterModule,
|
|
746
|
+
SkyIconModule,
|
|
747
|
+
SkyModalsResourcesModule,
|
|
748
|
+
SkyThemeModule,
|
|
749
|
+
]] });
|
|
750
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalModule, decorators: [{
|
|
751
|
+
type: NgModule,
|
|
752
|
+
args: [{
|
|
753
|
+
declarations: [
|
|
754
|
+
SkyModalComponent,
|
|
755
|
+
SkyModalContentComponent,
|
|
756
|
+
SkyModalFooterComponent,
|
|
757
|
+
SkyModalHeaderComponent,
|
|
758
|
+
SkyModalHostComponent,
|
|
759
|
+
SkyModalScrollShadowDirective,
|
|
760
|
+
],
|
|
761
|
+
imports: [
|
|
762
|
+
CommonModule,
|
|
763
|
+
RouterModule,
|
|
764
|
+
SkyIconModule,
|
|
765
|
+
SkyModalsResourcesModule,
|
|
766
|
+
SkyThemeModule,
|
|
767
|
+
],
|
|
768
|
+
exports: [
|
|
769
|
+
SkyModalComponent,
|
|
770
|
+
SkyModalContentComponent,
|
|
771
|
+
SkyModalFooterComponent,
|
|
772
|
+
SkyModalHeaderComponent,
|
|
773
|
+
],
|
|
774
|
+
}]
|
|
775
|
+
}] });
|
|
776
|
+
|
|
777
|
+
class SkyModalBeforeCloseHandler {
|
|
778
|
+
constructor(closeModal, closeArgs) {
|
|
779
|
+
this.closeModal = closeModal;
|
|
780
|
+
this.closeArgs = closeArgs;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
class SkyModalCloseArgs {
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// TODO: this class won't show in the generated docs until this work is done:
|
|
788
|
+
// https://github.com/blackbaud/skyux-docs-tools/issues/30
|
|
789
|
+
/**
|
|
790
|
+
* Allows you to close the modal and return data from the launched modal.
|
|
791
|
+
*/
|
|
792
|
+
class SkyModalInstance {
|
|
793
|
+
constructor() {
|
|
794
|
+
this._beforeClose = new Subject();
|
|
795
|
+
this._closed = new Subject();
|
|
796
|
+
this._helpOpened = new Subject();
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* An event that the modal instance emits when it is about to close.
|
|
800
|
+
* It emits a `SkyModalBeforeCloseHandler` object with a `closeModal` method
|
|
801
|
+
* that closes the modal. If a subscription exists for this event,
|
|
802
|
+
* the modal does not close until the subscriber calls the `closeModal` method.
|
|
803
|
+
*/
|
|
804
|
+
get beforeClose() {
|
|
805
|
+
return this._beforeClose;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* An event that the modal instance emits when it closes.
|
|
809
|
+
* It emits a `SkyModalCloseArgs` object with a `data` property that includes
|
|
810
|
+
* data passed from users on close or save and a `reason` property that indicates
|
|
811
|
+
* whether the modal was saved or closed without saving.
|
|
812
|
+
* The `reason` property accepts any string value.
|
|
813
|
+
* Common examples include `cancel`, `close`, and `save`.
|
|
814
|
+
*/
|
|
815
|
+
get closed() {
|
|
816
|
+
return this._closed;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* An event that the modal instance emits when users click
|
|
820
|
+
* the <i class="fa fa-question-circle" aria-hidden="true"></i> button.
|
|
821
|
+
* If a `helpKey` parameter was specified, the `helpOpened` event broadcasts the `helpKey`.
|
|
822
|
+
*/
|
|
823
|
+
get helpOpened() {
|
|
824
|
+
return this._helpOpened;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Closes the modal instance.
|
|
828
|
+
* @param result Specifies an object to emit to subscribers of the `closed` event of the
|
|
829
|
+
* modal instance. The `SkyModalInstance` provider can be injected into a component's constructor
|
|
830
|
+
* so that this `close` function can be called from a button in the `sky-modal-footer`.
|
|
831
|
+
* @param reason Specifies the reason for the modal closing, with the default reason of `close`.
|
|
832
|
+
* @param ignoreBeforeClose Indicates whether to ignore the modal instance's `beforeClose` event.
|
|
833
|
+
*/
|
|
834
|
+
close(result, reason, ignoreBeforeClose) {
|
|
835
|
+
if (reason === undefined) {
|
|
836
|
+
reason = 'close';
|
|
837
|
+
}
|
|
838
|
+
this.closeModal(reason, result, ignoreBeforeClose);
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Closes the modal instance with `reason=cancel`.
|
|
842
|
+
* @param result Specifies an object to emit to subscribers of the `closed` event of the modal
|
|
843
|
+
* instance. The `SkyModalInstance` provider can be injected into a component's constructor so
|
|
844
|
+
* that this cancel function can be called from a button in the `sky-modal-footer`.
|
|
845
|
+
*/
|
|
846
|
+
cancel(result) {
|
|
847
|
+
this.closeModal('cancel', result);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Closes the modal instance with `reason=save`.
|
|
851
|
+
* @param result Specifies an object to emit to subscribers of the `closed` event of the modal
|
|
852
|
+
* instance. The `SkyModalInstance` provider can be injected into a component's constructor so
|
|
853
|
+
* that this `save` function can be called from a button in `the sky-modal-footer`.
|
|
854
|
+
*/
|
|
855
|
+
save(result) {
|
|
856
|
+
this.closeModal('save', result);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Triggers the `helpOpened` event that broadcasts a `helpKey` parameter to open
|
|
860
|
+
* when users click the <i class="fa fa-question-circle" aria-hidden="true"></i> button.
|
|
861
|
+
* @param helpKey Specifies a string to emit to subscribers of
|
|
862
|
+
* the modal instance's `helpOpened` event. Consumers can inject the `SkyModalInstance` provider
|
|
863
|
+
* into a component's constructor to call the `openHelp` function in the modal template.
|
|
864
|
+
*/
|
|
865
|
+
openHelp(helpKey) {
|
|
866
|
+
this._helpOpened.next(helpKey);
|
|
867
|
+
}
|
|
868
|
+
closeModal(type, result, ignoreBeforeClose = false) {
|
|
869
|
+
const args = new SkyModalCloseArgs();
|
|
870
|
+
args.reason = type;
|
|
871
|
+
args.data = result;
|
|
872
|
+
if (this._beforeClose.observers.length === 0 || ignoreBeforeClose) {
|
|
873
|
+
this.notifyClosed(args);
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
this._beforeClose.next(new SkyModalBeforeCloseHandler(() => {
|
|
877
|
+
this.notifyClosed(args);
|
|
878
|
+
}, args));
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
notifyClosed(args) {
|
|
882
|
+
this._closed.next(args);
|
|
883
|
+
this._closed.complete();
|
|
884
|
+
this._beforeClose.complete();
|
|
885
|
+
this._helpOpened.complete();
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
class SkyConfirmComponent {
|
|
890
|
+
constructor(config, modal, resourcesService) {
|
|
891
|
+
this.config = config;
|
|
892
|
+
this.modal = modal;
|
|
893
|
+
this.resourcesService = resourcesService;
|
|
894
|
+
this.preserveWhiteSpace = false;
|
|
895
|
+
}
|
|
896
|
+
ngOnInit() {
|
|
897
|
+
if (this.config.type === SkyConfirmType.Custom &&
|
|
898
|
+
this.config.buttons.length > 0) {
|
|
899
|
+
this.buttons = this.getCustomButtons(this.config.buttons);
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
this.getPresetButtons().subscribe((buttons) => {
|
|
903
|
+
this.buttons = buttons;
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
this.message = this.config.message;
|
|
907
|
+
this.body = this.config.body;
|
|
908
|
+
this.preserveWhiteSpace = this.config.preserveWhiteSpace || false;
|
|
909
|
+
}
|
|
910
|
+
close(button) {
|
|
911
|
+
const result = {
|
|
912
|
+
action: button.action,
|
|
913
|
+
};
|
|
914
|
+
this.modal.close(result);
|
|
915
|
+
}
|
|
916
|
+
getPresetButtons() {
|
|
917
|
+
const emitter = new BehaviorSubject([]);
|
|
918
|
+
switch (this.config.type) {
|
|
919
|
+
default:
|
|
920
|
+
case SkyConfirmType.OK:
|
|
921
|
+
this.resourcesService
|
|
922
|
+
.getString('skyux_confirm_dialog_default_ok_text')
|
|
923
|
+
.subscribe((value) => {
|
|
924
|
+
emitter.next([
|
|
925
|
+
{
|
|
926
|
+
text: value,
|
|
927
|
+
autofocus: true,
|
|
928
|
+
styleType: 'primary',
|
|
929
|
+
action: 'ok',
|
|
930
|
+
},
|
|
931
|
+
]);
|
|
932
|
+
});
|
|
933
|
+
break;
|
|
934
|
+
case SkyConfirmType.YesNoCancel:
|
|
935
|
+
zip(this.resourcesService.getString('skyux_confirm_dialog_default_yes_text'), this.resourcesService.getString('skyux_confirm_dialog_default_no_text'), this.resourcesService.getString('skyux_confirm_dialog_default_cancel_text')).subscribe((values) => {
|
|
936
|
+
emitter.next([
|
|
937
|
+
{
|
|
938
|
+
text: values[0],
|
|
939
|
+
autofocus: true,
|
|
940
|
+
styleType: 'primary',
|
|
941
|
+
action: 'yes',
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
text: values[1],
|
|
945
|
+
styleType: 'default',
|
|
946
|
+
action: 'no',
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
text: values[2],
|
|
950
|
+
styleType: 'link',
|
|
951
|
+
action: 'cancel',
|
|
952
|
+
},
|
|
953
|
+
]);
|
|
954
|
+
});
|
|
955
|
+
break;
|
|
956
|
+
case SkyConfirmType.YesCancel:
|
|
957
|
+
zip(this.resourcesService.getString('skyux_confirm_dialog_default_yes_text'), this.resourcesService.getString('skyux_confirm_dialog_default_cancel_text')).subscribe((values) => {
|
|
958
|
+
emitter.next([
|
|
959
|
+
{
|
|
960
|
+
text: values[0],
|
|
961
|
+
autofocus: true,
|
|
962
|
+
styleType: 'primary',
|
|
963
|
+
action: 'yes',
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
text: values[1],
|
|
967
|
+
styleType: 'link',
|
|
968
|
+
action: 'cancel',
|
|
969
|
+
},
|
|
970
|
+
]);
|
|
971
|
+
});
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
return emitter;
|
|
975
|
+
}
|
|
976
|
+
getCustomButtons(buttonConfig) {
|
|
977
|
+
const buttons = [];
|
|
978
|
+
buttonConfig.forEach((config) => {
|
|
979
|
+
buttons.push({
|
|
980
|
+
text: config.text,
|
|
981
|
+
action: config.action,
|
|
982
|
+
styleType: config.styleType || 'default',
|
|
983
|
+
autofocus: config.autofocus || false,
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
return buttons;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
SkyConfirmComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmComponent, deps: [{ token: SkyConfirmModalContext }, { token: SkyModalInstance }, { token: i3$1.SkyLibResourcesService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
990
|
+
SkyConfirmComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SkyConfirmComponent, selector: "sky-confirm", ngImport: i0, template: "<div class=\"sky-confirm\">\n <sky-modal ariaRole=\"alertdialog\">\n <sky-modal-content class=\"sky-confirm-content\">\n <div\n class=\"sky-confirm-message\"\n [ngClass]=\"{\n 'sky-confirm-preserve-white-space': preserveWhiteSpace\n }\"\n [skyThemeClass]=\"{\n 'sky-emphasized': 'default',\n 'sky-font-heading-1 sky-font-display-3': 'modern'\n }\"\n >\n {{ message }}\n </div>\n\n <div\n *ngIf=\"body\"\n class=\"sky-confirm-body\"\n [ngClass]=\"{\n 'sky-confirm-preserve-white-space': preserveWhiteSpace\n }\"\n >\n {{ body }}\n </div>\n\n <div class=\"sky-confirm-buttons\">\n <button\n *ngFor=\"let button of buttons\"\n type=\"button\"\n class=\"sky-btn\"\n [ngClass]=\"['sky-btn-' + button.styleType]\"\n [skyThemeClass]=\"{\n 'sky-margin-inline-sm': 'modern',\n 'sky-margin-inline-compact': 'default'\n }\"\n (click)=\"close(button)\"\n [attr.autofocus]=\"button.autofocus ? 'autofocus' : null\"\n >\n {{ button.text }}\n </button>\n </div>\n </sky-modal-content>\n </sky-modal>\n</div>\n", styles: [".sky-confirm-message{margin-top:5px}.sky-confirm-body{margin-top:10px}.sky-confirm-buttons{margin-top:20px}.sky-confirm-preserve-white-space{white-space:pre-wrap}:host-context(.sky-theme-modern) .sky-confirm-content{padding:20px 30px}:host-context(.sky-theme-modern) .sky-confirm-message{padding-bottom:20px}:host-context(.sky-theme-modern) .sky-confirm-body{margin:0}.sky-theme-modern .sky-confirm-content{padding:20px 30px}.sky-theme-modern .sky-confirm-message{padding-bottom:20px}.sky-theme-modern .sky-confirm-body{margin:0}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-confirm-message{color:#fbfcfe}.sky-theme-modern.sky-theme-mode-dark .sky-confirm-message{color:#fbfcfe}\n"], components: [{ type: SkyModalComponent, selector: "sky-modal", inputs: ["ariaRole", "tiledBody"] }, { type: SkyModalContentComponent, selector: "sky-modal-content" }], directives: [{ type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.λ2, selector: "[skyThemeClass]", inputs: ["class", "skyThemeClass"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
991
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmComponent, decorators: [{
|
|
992
|
+
type: Component,
|
|
993
|
+
args: [{ selector: 'sky-confirm', template: "<div class=\"sky-confirm\">\n <sky-modal ariaRole=\"alertdialog\">\n <sky-modal-content class=\"sky-confirm-content\">\n <div\n class=\"sky-confirm-message\"\n [ngClass]=\"{\n 'sky-confirm-preserve-white-space': preserveWhiteSpace\n }\"\n [skyThemeClass]=\"{\n 'sky-emphasized': 'default',\n 'sky-font-heading-1 sky-font-display-3': 'modern'\n }\"\n >\n {{ message }}\n </div>\n\n <div\n *ngIf=\"body\"\n class=\"sky-confirm-body\"\n [ngClass]=\"{\n 'sky-confirm-preserve-white-space': preserveWhiteSpace\n }\"\n >\n {{ body }}\n </div>\n\n <div class=\"sky-confirm-buttons\">\n <button\n *ngFor=\"let button of buttons\"\n type=\"button\"\n class=\"sky-btn\"\n [ngClass]=\"['sky-btn-' + button.styleType]\"\n [skyThemeClass]=\"{\n 'sky-margin-inline-sm': 'modern',\n 'sky-margin-inline-compact': 'default'\n }\"\n (click)=\"close(button)\"\n [attr.autofocus]=\"button.autofocus ? 'autofocus' : null\"\n >\n {{ button.text }}\n </button>\n </div>\n </sky-modal-content>\n </sky-modal>\n</div>\n", styles: [".sky-confirm-message{margin-top:5px}.sky-confirm-body{margin-top:10px}.sky-confirm-buttons{margin-top:20px}.sky-confirm-preserve-white-space{white-space:pre-wrap}:host-context(.sky-theme-modern) .sky-confirm-content{padding:20px 30px}:host-context(.sky-theme-modern) .sky-confirm-message{padding-bottom:20px}:host-context(.sky-theme-modern) .sky-confirm-body{margin:0}.sky-theme-modern .sky-confirm-content{padding:20px 30px}.sky-theme-modern .sky-confirm-message{padding-bottom:20px}.sky-theme-modern .sky-confirm-body{margin:0}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-confirm-message{color:#fbfcfe}.sky-theme-modern.sky-theme-mode-dark .sky-confirm-message{color:#fbfcfe}\n"] }]
|
|
994
|
+
}], ctorParameters: function () {
|
|
995
|
+
return [{ type: SkyConfirmModalContext }, { type: SkyModalInstance }, { type: i3$1.SkyLibResourcesService, decorators: [{
|
|
996
|
+
type: Optional
|
|
997
|
+
}] }];
|
|
998
|
+
} });
|
|
999
|
+
|
|
1000
|
+
class SkyConfirmModule {
|
|
1001
|
+
}
|
|
1002
|
+
SkyConfirmModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1003
|
+
SkyConfirmModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmModule, declarations: [SkyConfirmComponent], imports: [CommonModule,
|
|
1004
|
+
SkyModalModule,
|
|
1005
|
+
SkyModalsResourcesModule,
|
|
1006
|
+
SkyThemeModule], exports: [SkyConfirmComponent] });
|
|
1007
|
+
SkyConfirmModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmModule, imports: [[
|
|
1008
|
+
CommonModule,
|
|
1009
|
+
SkyModalModule,
|
|
1010
|
+
SkyModalsResourcesModule,
|
|
1011
|
+
SkyThemeModule,
|
|
1012
|
+
]] });
|
|
1013
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmModule, decorators: [{
|
|
1014
|
+
type: NgModule,
|
|
1015
|
+
args: [{
|
|
1016
|
+
declarations: [SkyConfirmComponent],
|
|
1017
|
+
imports: [
|
|
1018
|
+
CommonModule,
|
|
1019
|
+
SkyModalModule,
|
|
1020
|
+
SkyModalsResourcesModule,
|
|
1021
|
+
SkyThemeModule,
|
|
1022
|
+
],
|
|
1023
|
+
exports: [SkyConfirmComponent],
|
|
1024
|
+
}]
|
|
1025
|
+
}] });
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* A service that lauches modals. For information about how to test modals in SKY UX, see
|
|
1029
|
+
* [write unit tests for modals](https://developer.blackbaud.com/skyux/learn/get-started/advanced/unit-test-modals).
|
|
1030
|
+
* @dynamic
|
|
1031
|
+
*/
|
|
1032
|
+
class SkyModalService {
|
|
1033
|
+
// TODO: In future breaking change - remove extra parameters as they are no longer used.
|
|
1034
|
+
/* tslint:disable:no-unused-variable */
|
|
1035
|
+
constructor(dynamicComponentService) {
|
|
1036
|
+
this.dynamicComponentService = dynamicComponentService;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* @private
|
|
1040
|
+
* Removes the modal host from the DOM.
|
|
1041
|
+
*/
|
|
1042
|
+
dispose() {
|
|
1043
|
+
if (SkyModalService.host) {
|
|
1044
|
+
this.dynamicComponentService.removeComponent(SkyModalService.host);
|
|
1045
|
+
SkyModalService.host = undefined;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Opens a modal using the specified component.
|
|
1050
|
+
* @param component Determines the component to render.
|
|
1051
|
+
* @param {SkyModalConfigurationInterface} config Populates the modal based on the `SkyModalConfigurationInterface` object.
|
|
1052
|
+
*/
|
|
1053
|
+
open(component, config) {
|
|
1054
|
+
const modalInstance = new SkyModalInstance();
|
|
1055
|
+
this.createHostComponent();
|
|
1056
|
+
const params = this.getConfigFromParameter(config);
|
|
1057
|
+
params.providers.push({
|
|
1058
|
+
provide: SkyModalInstance,
|
|
1059
|
+
useValue: modalInstance,
|
|
1060
|
+
});
|
|
1061
|
+
SkyModalService.host.instance.open(modalInstance, component, params);
|
|
1062
|
+
return modalInstance;
|
|
1063
|
+
}
|
|
1064
|
+
getConfigFromParameter(providersOrConfig) {
|
|
1065
|
+
const defaultParams = {
|
|
1066
|
+
providers: [],
|
|
1067
|
+
fullPage: false,
|
|
1068
|
+
size: 'medium',
|
|
1069
|
+
tiledBody: false,
|
|
1070
|
+
};
|
|
1071
|
+
let params = undefined;
|
|
1072
|
+
let method = undefined;
|
|
1073
|
+
// Object Literal Lookup for backwards compatability.
|
|
1074
|
+
method = {
|
|
1075
|
+
'providers?': Object.assign({}, defaultParams, {
|
|
1076
|
+
providers: providersOrConfig,
|
|
1077
|
+
}),
|
|
1078
|
+
config: Object.assign({}, defaultParams, providersOrConfig),
|
|
1079
|
+
};
|
|
1080
|
+
if (Array.isArray(providersOrConfig) === true) {
|
|
1081
|
+
params = method['providers?'];
|
|
1082
|
+
}
|
|
1083
|
+
else {
|
|
1084
|
+
params = method['config'];
|
|
1085
|
+
}
|
|
1086
|
+
return params;
|
|
1087
|
+
}
|
|
1088
|
+
createHostComponent() {
|
|
1089
|
+
if (!SkyModalService.host) {
|
|
1090
|
+
SkyModalService.host = this.dynamicComponentService.createComponent(SkyModalHostComponent);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
SkyModalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalService, deps: [{ token: i3.SkyDynamicComponentService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1095
|
+
SkyModalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalService, providedIn: 'any' });
|
|
1096
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyModalService, decorators: [{
|
|
1097
|
+
type: Injectable,
|
|
1098
|
+
args: [{
|
|
1099
|
+
// Must be 'any' so that the modal component is created in the context of its module's injector.
|
|
1100
|
+
// If set to 'root', the component's dependency injections would only be derived from the root
|
|
1101
|
+
// injector and may loose context if the modal was opened from within a lazy-loaded module.
|
|
1102
|
+
providedIn: 'any',
|
|
1103
|
+
}]
|
|
1104
|
+
}], ctorParameters: function () { return [{ type: i3.SkyDynamicComponentService }]; } });
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* The `SkyConfirmService` provider launches the confirmation dialog.
|
|
1108
|
+
* Within the service, you can specify the dialog's message and customize the button text.
|
|
1109
|
+
*/
|
|
1110
|
+
class SkyConfirmService {
|
|
1111
|
+
constructor(modalService) {
|
|
1112
|
+
this.modalService = modalService;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Opens a confirmation dialog and passes the `config` parameter of type `SkyConfirmConfig`
|
|
1116
|
+
* to the component's constructor. This method returns an object of type `SkyConfirmInstance`.
|
|
1117
|
+
*/
|
|
1118
|
+
open(config) {
|
|
1119
|
+
const modalInstance = this.modalService.open(SkyConfirmComponent, {
|
|
1120
|
+
providers: [
|
|
1121
|
+
{
|
|
1122
|
+
provide: SkyConfirmModalContext,
|
|
1123
|
+
useValue: config,
|
|
1124
|
+
},
|
|
1125
|
+
],
|
|
1126
|
+
});
|
|
1127
|
+
const confirmInstance = new SkyConfirmInstance();
|
|
1128
|
+
modalInstance.closed.subscribe((args) => {
|
|
1129
|
+
let result = args.data;
|
|
1130
|
+
// The modal was closed using the ESC key.
|
|
1131
|
+
if (result === undefined) {
|
|
1132
|
+
result = {
|
|
1133
|
+
action: 'cancel',
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
confirmInstance.closed.emit(result);
|
|
1137
|
+
confirmInstance.closed.complete();
|
|
1138
|
+
});
|
|
1139
|
+
return confirmInstance;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
SkyConfirmService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmService, deps: [{ token: SkyModalService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1143
|
+
SkyConfirmService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmService, providedIn: 'any' });
|
|
1144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SkyConfirmService, decorators: [{
|
|
1145
|
+
type: Injectable,
|
|
1146
|
+
args: [{
|
|
1147
|
+
// Must be 'any' so that the modal component is created in the context of its module's injector.
|
|
1148
|
+
// If set to 'root', the component's dependency injections would only be derived from the root
|
|
1149
|
+
// injector and may loose context if the modal was opened from within a lazy-loaded module.
|
|
1150
|
+
providedIn: 'any',
|
|
1151
|
+
}]
|
|
1152
|
+
}], ctorParameters: function () { return [{ type: SkyModalService }]; } });
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Generated bundle index. Do not edit.
|
|
1156
|
+
*/
|
|
1157
|
+
|
|
1158
|
+
export { SkyConfirmInstance, SkyConfirmModalContext, SkyConfirmModule, SkyConfirmService, SkyConfirmType, SkyModalBeforeCloseHandler, SkyModalCloseArgs, SkyModalConfiguration, SkyModalHostService, SkyModalInstance, SkyModalModule, SkyModalService, SkyConfirmComponent as λ1, SkyModalContentComponent as λ2, SkyModalFooterComponent as λ3, SkyModalHeaderComponent as λ4, SkyModalComponent as λ5 };
|
|
1159
|
+
//# sourceMappingURL=skyux-modals.mjs.map
|