@blackbaud/skyux-lib-addin-client 14.1.0 → 15.0.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.
|
@@ -1,344 +1,507 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { DOCUMENT } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { CSP_NONCE, EventEmitter, Injectable, RendererFactory2, inject } from "@angular/core";
|
|
4
|
+
import { AddinClient } from "@blackbaud/sky-addin-client";
|
|
5
|
+
import { SkyAppConfig } from "@skyux/config";
|
|
6
|
+
import { SkyTheme, SkyThemeMode, SkyThemeService, SkyThemeSettings } from "@skyux/theme";
|
|
7
|
+
import { AsyncSubject, from } from "rxjs";
|
|
8
|
+
import { SkyHelpService } from "@skyux/core";
|
|
9
|
+
var AddinClientConfigService = class {
|
|
10
|
+
getAddinClientConfig() {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
getHostedSurfaceMode(context) {
|
|
14
|
+
return "automatic";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var AddinEvent = class {};
|
|
18
|
+
var AddinEventHandlerInstance = class {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.addinEvent = new EventEmitter();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const NESTED_MODAL_BACKDROP_DEPTH = 2;
|
|
24
|
+
function resolveModalBackdrop(modalDepth, forceNormal) {
|
|
25
|
+
return forceNormal || modalDepth >= NESTED_MODAL_BACKDROP_DEPTH ? "normal" : "transparent";
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const CANONICAL_ADDIN_TYPE_TREATMENT = {
|
|
28
|
+
"action-button": "preserve",
|
|
29
|
+
box: "container",
|
|
30
|
+
button: "preserve",
|
|
31
|
+
dataset: "preserve",
|
|
32
|
+
flyout: "container",
|
|
33
|
+
generic: "preserve",
|
|
34
|
+
modal: "modal",
|
|
35
|
+
page: "preserve",
|
|
36
|
+
tab: "preserve",
|
|
37
|
+
tile: "container",
|
|
38
|
+
"vertical-tab-form": "container"
|
|
39
|
+
};
|
|
40
|
+
const READY_ARGS_ADDIN_TYPES = [
|
|
41
|
+
["modalConfig", "modal"],
|
|
42
|
+
["boxConfig", "box"],
|
|
43
|
+
["tabConfig", "tab"],
|
|
44
|
+
["tileConfig", "tile"],
|
|
45
|
+
["buttonConfig", "button"],
|
|
46
|
+
["actionButtonConfig", "action-button"]
|
|
47
|
+
];
|
|
48
|
+
const UNIDENTIFIED_RESOLUTION = {
|
|
49
|
+
backdrop: "preserve",
|
|
50
|
+
restoreBackdropDisplay: false,
|
|
51
|
+
treatment: "container"
|
|
52
|
+
};
|
|
53
|
+
const FULL_PAGE_RESOLUTION = {
|
|
54
|
+
backdrop: "preserve",
|
|
55
|
+
restoreBackdropDisplay: false,
|
|
56
|
+
treatment: "full-page"
|
|
57
|
+
};
|
|
58
|
+
function inferAddinType(readyArgs) {
|
|
59
|
+
return READY_ARGS_ADDIN_TYPES.find(([field]) => readyArgs[field] !== void 0)?.[1];
|
|
60
|
+
}
|
|
61
|
+
function resolveAddinType(addinType, readyArgs, modalDepth, hostReportsType) {
|
|
62
|
+
if (addinType === "modal") return readyArgs.modalConfig?.fullPage === true ? FULL_PAGE_RESOLUTION : modalResolution(hostReportsType, modalDepth);
|
|
63
|
+
return {
|
|
64
|
+
backdrop: "preserve",
|
|
65
|
+
restoreBackdropDisplay: false,
|
|
66
|
+
treatment: CANONICAL_ADDIN_TYPE_TREATMENT[addinType]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function modalResolution(compatibleHost, modalDepth) {
|
|
70
|
+
return {
|
|
71
|
+
backdrop: resolveModalBackdrop(modalDepth, compatibleHost),
|
|
72
|
+
inferredModalStyle: compatibleHost ? {
|
|
73
|
+
hostOverlay: false,
|
|
74
|
+
transparentBackground: true
|
|
75
|
+
} : { transparentBackground: true },
|
|
76
|
+
restoreBackdropDisplay: true,
|
|
77
|
+
treatment: "modal"
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function resolveHostedSurface(input) {
|
|
81
|
+
const { addinType, modalState, mode, readyArgs } = input;
|
|
82
|
+
if (mode === "preserve" || mode === "container") return {
|
|
83
|
+
backdrop: "preserve",
|
|
84
|
+
restoreBackdropDisplay: false,
|
|
85
|
+
treatment: mode
|
|
86
|
+
};
|
|
87
|
+
const style = readyArgs.modalConfig?.style;
|
|
88
|
+
if (style !== void 0) return {
|
|
89
|
+
backdrop: addinType === void 0 && style.hostOverlay === false && style.transparentBackground === true ? resolveModalBackdrop(modalState.modalDepth, false) : "preserve",
|
|
90
|
+
restoreBackdropDisplay: false,
|
|
91
|
+
treatment: "preserve"
|
|
92
|
+
};
|
|
93
|
+
if (addinType !== void 0) return resolveAddinType(addinType, readyArgs, modalState.modalDepth, true);
|
|
94
|
+
const inferredAddinType = inferAddinType(readyArgs);
|
|
95
|
+
if (inferredAddinType !== void 0) return resolveAddinType(inferredAddinType, readyArgs, modalState.modalDepth, false);
|
|
96
|
+
if (modalState.fullPageModalOpen) return FULL_PAGE_RESOLUTION;
|
|
97
|
+
if (modalState.modalOpen) return {
|
|
98
|
+
backdrop: resolveModalBackdrop(modalState.modalDepth, false),
|
|
99
|
+
restoreBackdropDisplay: true,
|
|
100
|
+
treatment: "modal"
|
|
101
|
+
};
|
|
102
|
+
return UNIDENTIFIED_RESOLUTION;
|
|
103
|
+
}
|
|
104
|
+
function withInferredModalStyle(readyArgs, style) {
|
|
105
|
+
if (style === void 0) return readyArgs;
|
|
106
|
+
return {
|
|
107
|
+
...readyArgs,
|
|
108
|
+
modalConfig: {
|
|
109
|
+
...readyArgs.modalConfig,
|
|
110
|
+
style
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const HOSTED_SURFACE_CLASSES = {
|
|
115
|
+
container: "bb-skyux-addin-client-container-background",
|
|
116
|
+
restoreBackdrop: "bb-skyux-addin-client-modal-backdrop-rendered",
|
|
117
|
+
transparent: "bb-skyux-addin-client-modal-background-transparent",
|
|
118
|
+
transparentBackdrop: "bb-skyux-addin-client-modal-backdrop-transparent"
|
|
119
|
+
};
|
|
120
|
+
const HOSTED_SURFACE_STYLE_ATTRIBUTE = "data-bb-skyux-addin-client-hosted-surface";
|
|
121
|
+
const MODAL_MARKER_CLASSES = ["sky-modal-body-open", "sky-modal-body-full-page"];
|
|
122
|
+
const STYLE_TEXT = `
|
|
123
|
+
body.${HOSTED_SURFACE_CLASSES.container} {
|
|
124
|
+
background-color: var(
|
|
125
|
+
--sky-theme-color-background-container-default,
|
|
126
|
+
var(--sky-background-color-container-default)
|
|
127
|
+
) !important;
|
|
27
128
|
}
|
|
28
129
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
class AddinEventHandlerInstance {
|
|
130
|
+
body.${HOSTED_SURFACE_CLASSES.transparent} {
|
|
131
|
+
background-color: transparent !important;
|
|
33
132
|
}
|
|
34
133
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
#themeService;
|
|
39
|
-
#addinClientConfigService;
|
|
40
|
-
constructor() {
|
|
41
|
-
// Init args
|
|
42
|
-
this._args = new AsyncSubject();
|
|
43
|
-
this.args = this._args.asObservable();
|
|
44
|
-
// Addin Client Events
|
|
45
|
-
/**
|
|
46
|
-
* Event emitted for box add-ins indicating that a control action button was clicked.
|
|
47
|
-
*/
|
|
48
|
-
this.actionClick = new EventEmitter(true);
|
|
49
|
-
/**
|
|
50
|
-
* Event emitted for button add-ins indicating that the button was clicked.
|
|
51
|
-
*/
|
|
52
|
-
this.buttonClick = new EventEmitter(true);
|
|
53
|
-
/**
|
|
54
|
-
* Event emitted for add-ins when context information has been updated
|
|
55
|
-
*/
|
|
56
|
-
this.updateContext = new EventEmitter();
|
|
57
|
-
/**
|
|
58
|
-
* Event emitted for flyout add-ins indicating that the next button was clicked.
|
|
59
|
-
*/
|
|
60
|
-
this.flyoutNextClick = new EventEmitter(true);
|
|
61
|
-
/**
|
|
62
|
-
* Event emitted for flyout add-ins indicating that the previous button was clicked.
|
|
63
|
-
*/
|
|
64
|
-
this.flyoutPreviousClick = new EventEmitter(true);
|
|
65
|
-
/**
|
|
66
|
-
* Event emitted for tile add-ins indicating that the help button was clicked.
|
|
67
|
-
* @deprecated Use tile inline help instead and handle the {@link inlineHelpClick} emitter.
|
|
68
|
-
*/
|
|
69
|
-
this.helpClick = new EventEmitter(true);
|
|
70
|
-
/**
|
|
71
|
-
* Event emitted indicating that the inline help button was clicked.
|
|
72
|
-
*/
|
|
73
|
-
this.inlineHelpClick = new EventEmitter(true);
|
|
74
|
-
/**
|
|
75
|
-
* Event emitted for tile add-ins indicating that the settings button was clicked.
|
|
76
|
-
*/
|
|
77
|
-
this.settingsClick = new EventEmitter(true);
|
|
78
|
-
this.#config = inject(SkyAppConfig, { optional: true });
|
|
79
|
-
this.#rendererFactory = inject(RendererFactory2);
|
|
80
|
-
this.#themeService = inject(SkyThemeService);
|
|
81
|
-
this.#addinClientConfigService = inject(AddinClientConfigService, { optional: true });
|
|
82
|
-
this.addinClient = new AddinClient({
|
|
83
|
-
callbacks: {
|
|
84
|
-
init: (args) => {
|
|
85
|
-
this.initializeTheme(args?.themeSettings);
|
|
86
|
-
this._args.next(args);
|
|
87
|
-
this._args.complete();
|
|
88
|
-
},
|
|
89
|
-
actionClick: (action) => {
|
|
90
|
-
this.actionClick.emit(action);
|
|
91
|
-
},
|
|
92
|
-
buttonClick: () => {
|
|
93
|
-
this.buttonClick.emit();
|
|
94
|
-
},
|
|
95
|
-
flyoutNextClick: () => {
|
|
96
|
-
this.flyoutNextClick.emit();
|
|
97
|
-
},
|
|
98
|
-
flyoutPreviousClick: () => {
|
|
99
|
-
this.flyoutPreviousClick.emit();
|
|
100
|
-
},
|
|
101
|
-
helpClick: () => {
|
|
102
|
-
this.helpClick.emit();
|
|
103
|
-
},
|
|
104
|
-
inlineHelpClick: () => {
|
|
105
|
-
this.inlineHelpClick.emit();
|
|
106
|
-
},
|
|
107
|
-
settingsClick: () => {
|
|
108
|
-
this.settingsClick.emit();
|
|
109
|
-
},
|
|
110
|
-
updateContext: (context) => {
|
|
111
|
-
this.updateContext.emit(context);
|
|
112
|
-
},
|
|
113
|
-
themeChange: (settings) => {
|
|
114
|
-
this.setTheme(settings);
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
config: this.#addinClientConfigService?.getAddinClientConfig()
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Informs the host to close this modal add-in.
|
|
122
|
-
* Should only be used from within the modal add-in and not the parent add-in.
|
|
123
|
-
* @param args Arguments to provide a context object back to the parent add-in.
|
|
124
|
-
*/
|
|
125
|
-
closeModal(args) {
|
|
126
|
-
this.addinClient.closeModal(args);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Requests the host page to launch a modal add-in.
|
|
130
|
-
* @param args Arguments for launching the modal.
|
|
131
|
-
* @returns Returns an observable that will publish a value when the modal add-in is closed.
|
|
132
|
-
* Observables will publish values with context data passed from the modal add-in's closeModal call.
|
|
133
|
-
*/
|
|
134
|
-
showModal(args) {
|
|
135
|
-
let modalReturn = this.addinClient.showModal(args);
|
|
136
|
-
return from(modalReturn.modalClosed);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Cleans up the AddinClient, releasing all resources.
|
|
140
|
-
*/
|
|
141
|
-
destroy() {
|
|
142
|
-
this.addinClient.destroy();
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Requests the host page to navigate.
|
|
146
|
-
* @param args Arguments describing the navigation request.
|
|
147
|
-
*/
|
|
148
|
-
navigate(args) {
|
|
149
|
-
this.addinClient.navigate(args);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Informs the host to open the help tab with the specified help key.
|
|
153
|
-
* @param args Arguments for launching the help tab.
|
|
154
|
-
*/
|
|
155
|
-
openHelp(args) {
|
|
156
|
-
this.addinClient.openHelp(args);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Requests a user identity token for the current user.
|
|
160
|
-
* @returns Returns an observable which will publish the token value.
|
|
161
|
-
*/
|
|
162
|
-
getUserIdentityToken() {
|
|
163
|
-
return from(this.addinClient.getUserIdentityToken());
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* @deprecated Use getUserIdentityToken
|
|
167
|
-
*/
|
|
168
|
-
getAuthToken() {
|
|
169
|
-
return from(this.addinClient.getUserIdentityToken());
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Informs the host to show a toast message.
|
|
173
|
-
* @param args Arguments for showing a toast.
|
|
174
|
-
*/
|
|
175
|
-
showToast(args) {
|
|
176
|
-
this.addinClient.showToast(args);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Requests the host page to launch a flyout add-in.
|
|
180
|
-
* @param args Arguments for launching the flyout.
|
|
181
|
-
* @returns Returns an observable that will notify when the flyout add-in is closed.
|
|
182
|
-
*/
|
|
183
|
-
showFlyout(args) {
|
|
184
|
-
const flyoutReturn = this.addinClient.showFlyout(args);
|
|
185
|
-
return from(flyoutReturn.flyoutClosed);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Requests the host page to close the flyout add-in.
|
|
189
|
-
*/
|
|
190
|
-
closeFlyout() {
|
|
191
|
-
this.addinClient.closeFlyout();
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Requests the host page to show a confirm dialog.
|
|
195
|
-
* @param args Arguments for showing a confirm dialog.
|
|
196
|
-
* @returns Returns an observable which will publish the confirm action value.
|
|
197
|
-
*/
|
|
198
|
-
showConfirm(args) {
|
|
199
|
-
return from(this.addinClient.showConfirm(args));
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Informs the host to show an error dialog.
|
|
203
|
-
* @param args Arguments for showing an error dialog.
|
|
204
|
-
*/
|
|
205
|
-
showError(args) {
|
|
206
|
-
this.addinClient.showError(args);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Requests the host page to show a page blocking wait indicator.
|
|
210
|
-
*/
|
|
211
|
-
showWait() {
|
|
212
|
-
this.addinClient.showWait();
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Requests the host page to hide a page blocking wait indicator.
|
|
216
|
-
*/
|
|
217
|
-
hideWait() {
|
|
218
|
-
this.addinClient.hideWait();
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Registers an event handler for the provided event type.
|
|
222
|
-
* @param eventType The event type to register.
|
|
223
|
-
* @returns AddinEventHandlerInstance
|
|
224
|
-
*/
|
|
225
|
-
addEventHandler(eventType) {
|
|
226
|
-
let eventHandlerInstance = new AddinEventHandlerInstance();
|
|
227
|
-
eventHandlerInstance.addinEvent = new EventEmitter();
|
|
228
|
-
const eventCallback = (context, done) => {
|
|
229
|
-
eventHandlerInstance.addinEvent.emit({
|
|
230
|
-
context,
|
|
231
|
-
done
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
this.addinClient.addEventHandler(eventType, eventCallback);
|
|
235
|
-
return eventHandlerInstance;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Sends an event to be handled by the host page.
|
|
239
|
-
* @param args The event arguments to be sent to the host page.
|
|
240
|
-
* @returns Returns an observable which will complete when the add-in host page receives the
|
|
241
|
-
* message. The request will fail if a subsequent event occurs, for the same event type, within
|
|
242
|
-
* 200 milliseconds. A failure can also occur if an event type is not one of the supported types
|
|
243
|
-
* from the host page.
|
|
244
|
-
* @see AddinClientInitArgs#supportedEventTypes
|
|
245
|
-
*/
|
|
246
|
-
sendEvent(args) {
|
|
247
|
-
return from(this.addinClient.sendEvent(args));
|
|
248
|
-
}
|
|
249
|
-
initializeTheme(themeSettings) {
|
|
250
|
-
if (!themeSettings) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const hostThemeSettings = AddinClientService.toSkyThemeSettings(themeSettings);
|
|
254
|
-
if (!this.#config) {
|
|
255
|
-
// no app config, initialize host theme
|
|
256
|
-
this.initializeTheme_(hostThemeSettings);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const themingConfig = this.#config.skyux.app?.theming;
|
|
260
|
-
if (themingConfig?.supportedThemes &&
|
|
261
|
-
themingConfig.supportedThemes.indexOf(themeSettings.theme) !== -1) {
|
|
262
|
-
// app supports host theme, initialize host theme
|
|
263
|
-
this.initializeTheme_(hostThemeSettings);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
// app does not support host theme, do nothing to initialize the app's default theme
|
|
267
|
-
}
|
|
268
|
-
initializeTheme_(themeSettings) {
|
|
269
|
-
this.#themeService.init(document.body, this.#rendererFactory.createRenderer(undefined, undefined), themeSettings);
|
|
270
|
-
}
|
|
271
|
-
setTheme(settings) {
|
|
272
|
-
if (!settings) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const hostThemeSettings = AddinClientService.toSkyThemeSettings(settings);
|
|
276
|
-
this.#themeService.setTheme(hostThemeSettings);
|
|
277
|
-
}
|
|
278
|
-
static toSkyThemeSettings(settings) {
|
|
279
|
-
if (settings.skyThemeSettings) {
|
|
280
|
-
// If the settings contain a serialized SkyThemeSettings object, deserialize it.
|
|
281
|
-
return SkyThemeSettings.deserialize(settings.skyThemeSettings);
|
|
282
|
-
}
|
|
283
|
-
return new SkyThemeSettings(AddinClientService.toSkyTheme(settings.theme), AddinClientService.toSkyThemeMode(settings.mode));
|
|
284
|
-
}
|
|
285
|
-
static toSkyTheme(theme) {
|
|
286
|
-
switch (theme) {
|
|
287
|
-
case 'modern':
|
|
288
|
-
return SkyTheme.presets.modern;
|
|
289
|
-
default:
|
|
290
|
-
return SkyTheme.presets.default;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
static toSkyThemeMode(mode) {
|
|
294
|
-
switch (mode) {
|
|
295
|
-
case 'dark':
|
|
296
|
-
return SkyThemeMode.presets.dark;
|
|
297
|
-
default:
|
|
298
|
-
return SkyThemeMode.presets.light;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: AddinClientService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
302
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: AddinClientService, providedIn: 'root' }); }
|
|
134
|
+
body.${HOSTED_SURFACE_CLASSES.restoreBackdrop}
|
|
135
|
+
.sky-modal-host-backdrop:not([hidden]) {
|
|
136
|
+
display: block !important;
|
|
303
137
|
}
|
|
304
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: AddinClientService, decorators: [{
|
|
305
|
-
type: Injectable,
|
|
306
|
-
args: [{
|
|
307
|
-
providedIn: 'root'
|
|
308
|
-
}]
|
|
309
|
-
}], ctorParameters: () => [] });
|
|
310
138
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
this.skyAddinClientService = inject(AddinClientService);
|
|
315
|
-
}
|
|
316
|
-
/** @inheritdoc */
|
|
317
|
-
openHelp(args) {
|
|
318
|
-
if (!args) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
this.skyAddinClientService.openHelp(args);
|
|
322
|
-
}
|
|
323
|
-
/** @inheritdoc */
|
|
324
|
-
updateHelp() {
|
|
325
|
-
throw new Error('Not implemented');
|
|
326
|
-
}
|
|
327
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: AddinClientHelpService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
328
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: AddinClientHelpService, providedIn: 'root' }); }
|
|
139
|
+
body.${HOSTED_SURFACE_CLASSES.transparentBackdrop}
|
|
140
|
+
.sky-modal-host-backdrop {
|
|
141
|
+
--sky-override-modal-host-backdrop-color: transparent;
|
|
329
142
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
143
|
+
`;
|
|
144
|
+
var HostedSurfaceStyleController = class {
|
|
145
|
+
#document;
|
|
146
|
+
#nonce;
|
|
147
|
+
#ownedClasses = /* @__PURE__ */ new Set();
|
|
148
|
+
#input;
|
|
149
|
+
#observer;
|
|
150
|
+
#styleElement;
|
|
151
|
+
constructor(documentRef, nonce = null) {
|
|
152
|
+
this.#document = documentRef;
|
|
153
|
+
this.#nonce = nonce;
|
|
154
|
+
}
|
|
155
|
+
update(addinType, readyArgs, mode = "automatic") {
|
|
156
|
+
const input = {
|
|
157
|
+
addinType,
|
|
158
|
+
mode,
|
|
159
|
+
readyArgs
|
|
160
|
+
};
|
|
161
|
+
this.#input = input;
|
|
162
|
+
this.#observe();
|
|
163
|
+
return this.#applyResolution(input);
|
|
164
|
+
}
|
|
165
|
+
refresh() {
|
|
166
|
+
if (this.#input !== void 0) this.#applyResolution(this.#input);
|
|
167
|
+
}
|
|
168
|
+
destroy() {
|
|
169
|
+
this.#observer?.disconnect();
|
|
170
|
+
this.#observer = void 0;
|
|
171
|
+
this.#input = void 0;
|
|
172
|
+
for (const className of this.#ownedClasses) this.#document.body.classList.remove(className);
|
|
173
|
+
this.#ownedClasses.clear();
|
|
174
|
+
this.#styleElement?.remove();
|
|
175
|
+
this.#styleElement = void 0;
|
|
176
|
+
}
|
|
177
|
+
#applyResolution(input) {
|
|
178
|
+
const resolution = resolveHostedSurface({
|
|
179
|
+
...input,
|
|
180
|
+
modalState: {
|
|
181
|
+
fullPageModalOpen: this.#document.body.classList.contains("sky-modal-body-full-page"),
|
|
182
|
+
modalDepth: this.#document.body.querySelectorAll("sky-modal").length,
|
|
183
|
+
modalOpen: this.#document.body.classList.contains("sky-modal-body-open")
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
this.#setClass(HOSTED_SURFACE_CLASSES.container, resolution.treatment === "container");
|
|
187
|
+
this.#setClass(HOSTED_SURFACE_CLASSES.transparent, resolution.treatment === "modal");
|
|
188
|
+
this.#setClass(HOSTED_SURFACE_CLASSES.restoreBackdrop, resolution.restoreBackdropDisplay);
|
|
189
|
+
this.#setClass(HOSTED_SURFACE_CLASSES.transparentBackdrop, resolution.backdrop === "transparent");
|
|
190
|
+
if (resolution.treatment === "container" || resolution.treatment === "modal" || resolution.restoreBackdropDisplay || resolution.backdrop === "transparent") this.#ensureStyle();
|
|
191
|
+
else {
|
|
192
|
+
this.#styleElement?.remove();
|
|
193
|
+
this.#styleElement = void 0;
|
|
194
|
+
}
|
|
195
|
+
return resolution;
|
|
196
|
+
}
|
|
197
|
+
#ensureStyle() {
|
|
198
|
+
if (this.#styleElement?.parentNode) return;
|
|
199
|
+
const style = this.#document.createElement("style");
|
|
200
|
+
style.setAttribute(HOSTED_SURFACE_STYLE_ATTRIBUTE, "");
|
|
201
|
+
if (this.#nonce) style.setAttribute("nonce", this.#nonce);
|
|
202
|
+
style.textContent = STYLE_TEXT;
|
|
203
|
+
this.#document.head.appendChild(style);
|
|
204
|
+
this.#styleElement = style;
|
|
205
|
+
}
|
|
206
|
+
#observe() {
|
|
207
|
+
if (this.#observer !== void 0) return;
|
|
208
|
+
this.#observer = new MutationObserver((records) => this.#handleMutations(records));
|
|
209
|
+
this.#observer.observe(this.#document.body, {
|
|
210
|
+
attributeFilter: ["class"],
|
|
211
|
+
attributeOldValue: true,
|
|
212
|
+
attributes: true,
|
|
213
|
+
childList: true,
|
|
214
|
+
subtree: true
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
#handleMutations(records) {
|
|
218
|
+
for (const record of records) if (this.#isRelevantMutation(record)) {
|
|
219
|
+
this.refresh();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
#isRelevantMutation(record) {
|
|
224
|
+
if (record.type === "attributes") return record.target === this.#document.body && this.#modalMarkerPresenceChanged(record.oldValue);
|
|
225
|
+
return this.#containsModalNode(record.addedNodes) || this.#containsModalNode(record.removedNodes);
|
|
226
|
+
}
|
|
227
|
+
#modalMarkerPresenceChanged(oldValue) {
|
|
228
|
+
const previousClasses = new Set((oldValue ?? "").split(/\s+/).filter((value) => value.length > 0));
|
|
229
|
+
const currentClasses = this.#document.body.classList;
|
|
230
|
+
return MODAL_MARKER_CLASSES.some((marker) => previousClasses.has(marker) !== currentClasses.contains(marker));
|
|
231
|
+
}
|
|
232
|
+
#containsModalNode(nodes) {
|
|
233
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
234
|
+
const node = nodes[index];
|
|
235
|
+
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
236
|
+
const element = node;
|
|
237
|
+
if (element.localName === "sky-modal" || element.querySelector("sky-modal")) return true;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
#setClass(className, enabled) {
|
|
242
|
+
if (enabled) {
|
|
243
|
+
if (!this.#document.body.classList.contains(className)) {
|
|
244
|
+
this.#document.body.classList.add(className);
|
|
245
|
+
this.#ownedClasses.add(className);
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (this.#ownedClasses.delete(className)) this.#document.body.classList.remove(className);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var AddinClientService = class AddinClientService {
|
|
253
|
+
#config;
|
|
254
|
+
#document;
|
|
255
|
+
#rendererFactory;
|
|
256
|
+
#themeService;
|
|
257
|
+
#addinClientConfigService;
|
|
258
|
+
constructor() {
|
|
259
|
+
this._args = new AsyncSubject();
|
|
260
|
+
this.args = this._args.asObservable();
|
|
261
|
+
this.actionClick = new EventEmitter(true);
|
|
262
|
+
this.buttonClick = new EventEmitter(true);
|
|
263
|
+
this.updateContext = new EventEmitter();
|
|
264
|
+
this.flyoutNextClick = new EventEmitter(true);
|
|
265
|
+
this.flyoutPreviousClick = new EventEmitter(true);
|
|
266
|
+
this.helpClick = new EventEmitter(true);
|
|
267
|
+
this.inlineHelpClick = new EventEmitter(true);
|
|
268
|
+
this.settingsClick = new EventEmitter(true);
|
|
269
|
+
this.#config = inject(SkyAppConfig, { optional: true });
|
|
270
|
+
this.#document = inject(DOCUMENT);
|
|
271
|
+
this.#rendererFactory = inject(RendererFactory2);
|
|
272
|
+
this.#themeService = inject(SkyThemeService);
|
|
273
|
+
this.#addinClientConfigService = inject(AddinClientConfigService, { optional: true });
|
|
274
|
+
this.destroyed = false;
|
|
275
|
+
this.hostedSurfaceController = new HostedSurfaceStyleController(this.#document, inject(CSP_NONCE, { optional: true }));
|
|
276
|
+
this.addinClient = new AddinClient({
|
|
277
|
+
callbacks: {
|
|
278
|
+
init: (args) => {
|
|
279
|
+
const preparedArgs = this.prepareInitArgs(args);
|
|
280
|
+
this.initializeTheme(preparedArgs.themeSettings);
|
|
281
|
+
this._args.next(preparedArgs);
|
|
282
|
+
this._args.complete();
|
|
283
|
+
},
|
|
284
|
+
actionClick: (action) => {
|
|
285
|
+
this.actionClick.emit(action);
|
|
286
|
+
},
|
|
287
|
+
buttonClick: () => {
|
|
288
|
+
this.buttonClick.emit();
|
|
289
|
+
},
|
|
290
|
+
flyoutNextClick: () => {
|
|
291
|
+
this.flyoutNextClick.emit();
|
|
292
|
+
},
|
|
293
|
+
flyoutPreviousClick: () => {
|
|
294
|
+
this.flyoutPreviousClick.emit();
|
|
295
|
+
},
|
|
296
|
+
helpClick: () => {
|
|
297
|
+
this.helpClick.emit();
|
|
298
|
+
},
|
|
299
|
+
inlineHelpClick: () => {
|
|
300
|
+
this.inlineHelpClick.emit();
|
|
301
|
+
},
|
|
302
|
+
settingsClick: () => {
|
|
303
|
+
this.settingsClick.emit();
|
|
304
|
+
},
|
|
305
|
+
updateContext: (context) => {
|
|
306
|
+
this.updateContext.emit(context);
|
|
307
|
+
},
|
|
308
|
+
themeChange: (settings) => {
|
|
309
|
+
this.setTheme(settings);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
config: this.#addinClientConfigService?.getAddinClientConfig()
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
closeModal(args) {
|
|
316
|
+
this.addinClient.closeModal(args);
|
|
317
|
+
}
|
|
318
|
+
showModal(args) {
|
|
319
|
+
let modalReturn = this.addinClient.showModal(args);
|
|
320
|
+
return from(modalReturn.modalClosed);
|
|
321
|
+
}
|
|
322
|
+
destroy() {
|
|
323
|
+
if (this.destroyed) return;
|
|
324
|
+
this.destroyed = true;
|
|
325
|
+
this.hostedSurfaceController.destroy();
|
|
326
|
+
this.addinClient.destroy();
|
|
327
|
+
}
|
|
328
|
+
prepareInitArgs(args) {
|
|
329
|
+
const ready = args.ready;
|
|
330
|
+
args.ready = (readyArgs) => {
|
|
331
|
+
if (this.destroyed || !this.#document.body) {
|
|
332
|
+
ready(readyArgs);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const resolution = this.hostedSurfaceController.update(args.addinType, readyArgs, this.getHostedSurfaceMode({
|
|
336
|
+
addinType: args.addinType,
|
|
337
|
+
readyArgs
|
|
338
|
+
}));
|
|
339
|
+
ready(withInferredModalStyle(readyArgs, resolution.inferredModalStyle));
|
|
340
|
+
};
|
|
341
|
+
return args;
|
|
342
|
+
}
|
|
343
|
+
getHostedSurfaceMode(context) {
|
|
344
|
+
return this.#addinClientConfigService?.getHostedSurfaceMode?.(context) ?? "automatic";
|
|
345
|
+
}
|
|
346
|
+
navigate(args) {
|
|
347
|
+
this.addinClient.navigate(args);
|
|
348
|
+
}
|
|
349
|
+
openHelp(args) {
|
|
350
|
+
this.addinClient.openHelp(args);
|
|
351
|
+
}
|
|
352
|
+
getUserIdentityToken() {
|
|
353
|
+
return from(this.addinClient.getUserIdentityToken());
|
|
354
|
+
}
|
|
355
|
+
getAuthToken() {
|
|
356
|
+
return from(this.addinClient.getUserIdentityToken());
|
|
357
|
+
}
|
|
358
|
+
showToast(args) {
|
|
359
|
+
this.addinClient.showToast(args);
|
|
360
|
+
}
|
|
361
|
+
showFlyout(args) {
|
|
362
|
+
const flyoutReturn = this.addinClient.showFlyout(args);
|
|
363
|
+
return from(flyoutReturn.flyoutClosed);
|
|
364
|
+
}
|
|
365
|
+
closeFlyout() {
|
|
366
|
+
this.addinClient.closeFlyout();
|
|
367
|
+
}
|
|
368
|
+
showConfirm(args) {
|
|
369
|
+
return from(this.addinClient.showConfirm(args));
|
|
370
|
+
}
|
|
371
|
+
showError(args) {
|
|
372
|
+
this.addinClient.showError(args);
|
|
373
|
+
}
|
|
374
|
+
showWait() {
|
|
375
|
+
this.addinClient.showWait();
|
|
376
|
+
}
|
|
377
|
+
hideWait() {
|
|
378
|
+
this.addinClient.hideWait();
|
|
379
|
+
}
|
|
380
|
+
addEventHandler(eventType) {
|
|
381
|
+
let eventHandlerInstance = new AddinEventHandlerInstance();
|
|
382
|
+
const eventCallback = (context, done) => {
|
|
383
|
+
eventHandlerInstance.addinEvent.emit({
|
|
384
|
+
context,
|
|
385
|
+
done
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
this.addinClient.addEventHandler(eventType, eventCallback);
|
|
389
|
+
return eventHandlerInstance;
|
|
390
|
+
}
|
|
391
|
+
sendEvent(args) {
|
|
392
|
+
return from(this.addinClient.sendEvent(args));
|
|
393
|
+
}
|
|
394
|
+
initializeTheme(themeSettings) {
|
|
395
|
+
if (!themeSettings || !this.supportsHostTheme(themeSettings)) return;
|
|
396
|
+
this.initializeTheme_(AddinClientService.toSkyThemeSettings(themeSettings));
|
|
397
|
+
}
|
|
398
|
+
initializeTheme_(themeSettings) {
|
|
399
|
+
this.#themeService.init(document.body, this.#rendererFactory.createRenderer(null, null), themeSettings);
|
|
400
|
+
}
|
|
401
|
+
setTheme(settings) {
|
|
402
|
+
if (!settings || !this.supportsHostTheme(settings)) return;
|
|
403
|
+
this.#themeService.setTheme(AddinClientService.toSkyThemeSettings(settings));
|
|
404
|
+
}
|
|
405
|
+
supportsHostTheme(settings) {
|
|
406
|
+
if (!this.#config) return true;
|
|
407
|
+
const supportedThemes = this.#config.skyux.app?.theming?.supportedThemes;
|
|
408
|
+
return !!supportedThemes && supportedThemes.indexOf(settings.theme) !== -1;
|
|
409
|
+
}
|
|
410
|
+
static toSkyThemeSettings(settings) {
|
|
411
|
+
if (settings.skyThemeSettings) return SkyThemeSettings.deserialize(settings.skyThemeSettings);
|
|
412
|
+
return new SkyThemeSettings(AddinClientService.toSkyTheme(settings.theme), AddinClientService.toSkyThemeMode(settings.mode));
|
|
413
|
+
}
|
|
414
|
+
static toSkyTheme(theme) {
|
|
415
|
+
switch (theme) {
|
|
416
|
+
case "modern": return SkyTheme.presets.modern;
|
|
417
|
+
default: return SkyTheme.presets.default;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
static toSkyThemeMode(mode) {
|
|
421
|
+
switch (mode) {
|
|
422
|
+
case "dark": return SkyThemeMode.presets.dark;
|
|
423
|
+
default: return SkyThemeMode.presets.light;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
static {
|
|
427
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
428
|
+
minVersion: "12.0.0",
|
|
429
|
+
version: "22.1.2",
|
|
430
|
+
ngImport: i0,
|
|
431
|
+
type: AddinClientService,
|
|
432
|
+
deps: [],
|
|
433
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
static {
|
|
437
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
438
|
+
minVersion: "12.0.0",
|
|
439
|
+
version: "22.1.2",
|
|
440
|
+
ngImport: i0,
|
|
441
|
+
type: AddinClientService,
|
|
442
|
+
providedIn: "root"
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
447
|
+
minVersion: "12.0.0",
|
|
448
|
+
version: "22.1.2",
|
|
449
|
+
ngImport: i0,
|
|
450
|
+
type: AddinClientService,
|
|
451
|
+
decorators: [{
|
|
452
|
+
type: Injectable,
|
|
453
|
+
args: [{ providedIn: "root" }]
|
|
454
|
+
}],
|
|
455
|
+
ctorParameters: () => []
|
|
456
|
+
});
|
|
457
|
+
var AddinClientHelpService = class AddinClientHelpService extends SkyHelpService {
|
|
458
|
+
constructor() {
|
|
459
|
+
super(...arguments);
|
|
460
|
+
this.skyAddinClientService = inject(AddinClientService);
|
|
461
|
+
}
|
|
462
|
+
openHelp(args) {
|
|
463
|
+
if (!args) return;
|
|
464
|
+
this.skyAddinClientService.openHelp(args);
|
|
465
|
+
}
|
|
466
|
+
updateHelp() {
|
|
467
|
+
throw new Error("Not implemented");
|
|
468
|
+
}
|
|
469
|
+
static {
|
|
470
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
471
|
+
minVersion: "12.0.0",
|
|
472
|
+
version: "22.1.2",
|
|
473
|
+
ngImport: i0,
|
|
474
|
+
type: AddinClientHelpService,
|
|
475
|
+
deps: null,
|
|
476
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
static {
|
|
480
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
481
|
+
minVersion: "12.0.0",
|
|
482
|
+
version: "22.1.2",
|
|
483
|
+
ngImport: i0,
|
|
484
|
+
type: AddinClientHelpService,
|
|
485
|
+
providedIn: "root"
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
490
|
+
minVersion: "12.0.0",
|
|
491
|
+
version: "22.1.2",
|
|
492
|
+
ngImport: i0,
|
|
493
|
+
type: AddinClientHelpService,
|
|
494
|
+
decorators: [{
|
|
495
|
+
type: Injectable,
|
|
496
|
+
args: [{ providedIn: "root" }]
|
|
497
|
+
}]
|
|
498
|
+
});
|
|
335
499
|
function provideAddinClientHelp() {
|
|
336
|
-
|
|
500
|
+
return [{
|
|
501
|
+
provide: SkyHelpService,
|
|
502
|
+
useClass: AddinClientHelpService
|
|
503
|
+
}];
|
|
337
504
|
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Generated bundle index. Do not edit.
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
505
|
export { AddinClientConfigService, AddinClientHelpService, AddinClientService, AddinEvent, AddinEventHandlerInstance, provideAddinClientHelp };
|
|
344
|
-
|
|
506
|
+
|
|
507
|
+
//# sourceMappingURL=blackbaud-skyux-lib-addin-client.mjs.map
|