@molecule/app-ui-angular 1.4.1 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +989 -1103
- package/dist/components/alert.component.d.ts +11 -16
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +22 -51
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +36 -28
- package/dist/components/auth-guard.component.d.ts.map +1 -1
- package/dist/components/auth-guard.component.js +59 -67
- package/dist/components/auth-guard.component.js.map +1 -1
- package/dist/components/avatar.component.d.ts +13 -10
- package/dist/components/avatar.component.d.ts.map +1 -1
- package/dist/components/avatar.component.js +27 -25
- package/dist/components/avatar.component.js.map +1 -1
- package/dist/components/button.component.d.ts +26 -30
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +41 -75
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/checkbox.component.d.ts +5 -4
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +14 -9
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +11 -28
- package/dist/components/confirm-button.component.d.ts.map +1 -1
- package/dist/components/confirm-button.component.js +31 -63
- package/dist/components/confirm-button.component.js.map +1 -1
- package/dist/components/confirm-dialog.component.d.ts +28 -17
- package/dist/components/confirm-dialog.component.d.ts.map +1 -1
- package/dist/components/confirm-dialog.component.js +98 -69
- package/dist/components/confirm-dialog.component.js.map +1 -1
- package/dist/components/dropdown.component.d.ts +29 -16
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.component.js +134 -105
- package/dist/components/dropdown.component.js.map +1 -1
- package/dist/components/empty-state.component.d.ts +10 -15
- package/dist/components/empty-state.component.d.ts.map +1 -1
- package/dist/components/empty-state.component.js +23 -27
- package/dist/components/empty-state.component.js.map +1 -1
- package/dist/components/form-field.component.d.ts +26 -11
- package/dist/components/form-field.component.d.ts.map +1 -1
- package/dist/components/form-field.component.js +86 -25
- package/dist/components/form-field.component.js.map +1 -1
- package/dist/components/input.component.d.ts +20 -23
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +45 -54
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/language-picker.component.d.ts +15 -18
- package/dist/components/language-picker.component.d.ts.map +1 -1
- package/dist/components/language-picker.component.js +25 -35
- package/dist/components/language-picker.component.js.map +1 -1
- package/dist/components/load-error-banner.component.d.ts +14 -26
- package/dist/components/load-error-banner.component.d.ts.map +1 -1
- package/dist/components/load-error-banner.component.js +28 -62
- package/dist/components/load-error-banner.component.js.map +1 -1
- package/dist/components/modal.component.d.ts +25 -21
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +42 -78
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/button.component.d.ts +13 -2
- package/dist/components/molecule/button.component.d.ts.map +1 -1
- package/dist/components/molecule/button.component.js +45 -15
- package/dist/components/molecule/button.component.js.map +1 -1
- package/dist/components/molecule/toast.component.d.ts +2 -1
- package/dist/components/molecule/toast.component.d.ts.map +1 -1
- package/dist/components/molecule/toast.component.js +9 -7
- package/dist/components/molecule/toast.component.js.map +1 -1
- package/dist/components/molecule/tooltip.component.d.ts +4 -2
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -1
- package/dist/components/molecule/tooltip.component.js +19 -14
- package/dist/components/molecule/tooltip.component.js.map +1 -1
- package/dist/components/optimistic-toggle-button.component.d.ts +13 -25
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -1
- package/dist/components/optimistic-toggle-button.component.js +33 -63
- package/dist/components/optimistic-toggle-button.component.js.map +1 -1
- package/dist/components/page-header.component.d.ts +8 -13
- package/dist/components/page-header.component.d.ts.map +1 -1
- package/dist/components/page-header.component.js +16 -24
- package/dist/components/page-header.component.js.map +1 -1
- package/dist/components/page-shell.component.d.ts +8 -14
- package/dist/components/page-shell.component.d.ts.map +1 -1
- package/dist/components/page-shell.component.js +18 -28
- package/dist/components/page-shell.component.js.map +1 -1
- package/dist/components/panel-close.component.d.ts +14 -8
- package/dist/components/panel-close.component.d.ts.map +1 -1
- package/dist/components/panel-close.component.js +28 -17
- package/dist/components/panel-close.component.js.map +1 -1
- package/dist/components/prompt-dialog.component.d.ts +32 -10
- package/dist/components/prompt-dialog.component.d.ts.map +1 -1
- package/dist/components/prompt-dialog.component.js +110 -73
- package/dist/components/prompt-dialog.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +38 -57
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -1
- package/dist/components/responsive-app-shell.component.js +138 -213
- package/dist/components/responsive-app-shell.component.js.map +1 -1
- package/dist/components/sidebar-user-card.component.d.ts +8 -12
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -1
- package/dist/components/sidebar-user-card.component.js +19 -35
- package/dist/components/sidebar-user-card.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +13 -8
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +29 -20
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +22 -14
- package/dist/components/table.component.d.ts.map +1 -1
- package/dist/components/table.component.js +34 -32
- package/dist/components/table.component.js.map +1 -1
- package/dist/components/toast.component.d.ts +34 -37
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +76 -112
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +14 -11
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +47 -47
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +6 -12
- package/dist/components/user-menu-popover.component.d.ts.map +1 -1
- package/dist/components/user-menu-popover.component.js +40 -77
- package/dist/components/user-menu-popover.component.js.map +1 -1
- package/dist/components/user-menu.component.d.ts +8 -11
- package/dist/components/user-menu.component.d.ts.map +1 -1
- package/dist/components/user-menu.component.js +19 -27
- package/dist/components/user-menu.component.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/utilities/dom-context.d.ts +62 -15
- package/dist/utilities/dom-context.d.ts.map +1 -1
- package/dist/utilities/dom-context.js +79 -34
- package/dist/utilities/dom-context.js.map +1 -1
- package/dist/utilities/form-field-context.d.ts +2 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -1
- package/dist/utilities/form-field-context.js +4 -2
- package/dist/utilities/form-field-context.js.map +1 -1
- package/dist/utilities/node-value.d.ts +8 -0
- package/dist/utilities/node-value.d.ts.map +1 -1
- package/dist/utilities/node-value.js +10 -0
- package/dist/utilities/node-value.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +2 -2
- package/dist/utilities/rest-attrs.js +1 -1
- package/package.json +3 -3
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { ElementRef, EventEmitter } from '@angular/core';
|
|
7
7
|
import type { ColorVariant, UIClassMap } from '@molecule/app-ui';
|
|
8
8
|
import { type HasElement } from '../utilities/element.js';
|
|
9
9
|
import type { ResolvedIcon } from '../utilities/render-icon.js';
|
|
10
10
|
import * as i0 from "@angular/core";
|
|
11
|
+
import * as i1 from "@molecule/app-angular";
|
|
11
12
|
/**
|
|
12
13
|
* Alert component.
|
|
13
14
|
*
|
|
@@ -18,11 +19,11 @@ import * as i0 from "@angular/core";
|
|
|
18
19
|
* the icon wrapper span exists only when a custom icon is given or the status
|
|
19
20
|
* has a default glyph, and its content is the custom icon XOR the default
|
|
20
21
|
* glyph. Here the span and the default glyph both always exist in the
|
|
21
|
-
* template (projection capture points) and are
|
|
22
|
-
* React would not render them (
|
|
23
|
-
*
|
|
22
|
+
* template (projection capture points) and are taken out of the DOM when
|
|
23
|
+
* React would not render them (`setElementPresent`); the decision is made in
|
|
24
|
+
* the placement function, where projected content is current.
|
|
24
25
|
*/
|
|
25
|
-
export declare class Alert implements
|
|
26
|
+
export declare class Alert implements HasElement<HTMLDivElement> {
|
|
26
27
|
/** Alert title. */
|
|
27
28
|
title?: string;
|
|
28
29
|
/** Status color. */
|
|
@@ -52,13 +53,14 @@ export declare class Alert implements AfterViewInit, DoCheck, HasElement<HTMLDiv
|
|
|
52
53
|
/** The default status glyph (detached when a custom icon is projected). */
|
|
53
54
|
defaultGlyph?: ElementRef<SVGSVGElement>;
|
|
54
55
|
private hasCustomIcon;
|
|
56
|
+
/** Places the icon wrapper and the default glyph as React renders them. */
|
|
57
|
+
constructor();
|
|
55
58
|
/**
|
|
56
59
|
* Reactive translation, read in the injection context. Its `t` reads the
|
|
57
60
|
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
58
61
|
* does not).
|
|
59
62
|
*/
|
|
60
63
|
private readonly i18n;
|
|
61
|
-
private readonly sync;
|
|
62
64
|
private readonly host;
|
|
63
65
|
/** The element a caller's ref receives: the host `<div>`. */
|
|
64
66
|
readonly element: import("@angular/core").Signal<HTMLDivElement | null>;
|
|
@@ -109,20 +111,13 @@ export declare class Alert implements AfterViewInit, DoCheck, HasElement<HTMLDiv
|
|
|
109
111
|
* @returns The attribute value.
|
|
110
112
|
*/
|
|
111
113
|
molId(): string | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Decides icon presence at view init (view queries resolve only then) and
|
|
114
|
-
* applies React's conditions.
|
|
115
|
-
*/
|
|
116
|
-
ngAfterViewInit(): void;
|
|
117
|
-
/**
|
|
118
|
-
* Re-reconciles on later passes.
|
|
119
|
-
*/
|
|
120
|
-
ngDoCheck(): void;
|
|
121
114
|
/**
|
|
122
115
|
* Applies React's `{(icon || defaultIcon) && <span>{icon || defaultIcon}</span>}`.
|
|
116
|
+
*
|
|
117
|
+
* @param hasContent - Reads whether a slot has content.
|
|
123
118
|
*/
|
|
124
119
|
private syncIcon;
|
|
125
120
|
static ɵfac: i0.ɵɵFactoryDeclaration<Alert, never>;
|
|
126
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<Alert, "div[mol-alert]", never, { "title": { "alias": "title"; "required": false; }; "status": { "alias": "status"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "live": { "alias": "live"; "required": false; }; "dismissible": { "alias": "dismissible"; "required": false; }; "dismissLabel": { "alias": "dismissLabel"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "automationId": { "alias": "automationId"; "required": false; }; "dataMolId": { "alias": "data-mol-id"; "required": false; }; }, { "dismiss": "dismiss"; }, never, ["[slot=icon]", "*"], true,
|
|
121
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Alert, "div[mol-alert]", never, { "title": { "alias": "title"; "required": false; }; "status": { "alias": "status"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "live": { "alias": "live"; "required": false; }; "dismissible": { "alias": "dismissible"; "required": false; }; "dismissLabel": { "alias": "dismissLabel"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; "automationId": { "alias": "automationId"; "required": false; }; "dataMolId": { "alias": "data-mol-id"; "required": false; }; }, { "dismiss": "dismiss"; }, never, ["[slot=icon]", "*"], true, [{ directive: typeof i1.MolPlacement; inputs: {}; outputs: {}; }]>;
|
|
127
122
|
}
|
|
128
123
|
//# sourceMappingURL=alert.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.component.d.ts","sourceRoot":"","sources":["../../src/components/alert.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"alert.component.d.ts","sourceRoot":"","sources":["../../src/components/alert.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,UAAU,EAAE,YAAY,EAA6B,MAAM,eAAe,CAAA;AAU9F,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAk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,UAAU;IAIhB;;;OAGG;IACH,IAAI,YAAY,IAAI,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAEvE;IAED;;;;OAIG;IACH,WAAW,IAAI,YAAY,GAAG,IAAI;IAKlC;;;;OAIG;IACH,mBAAmB,IAAI,YAAY;IAWnC;;;OAGG;IACH,SAAS,IAAI,YAAY;IAIzB;;;OAGG;IACH,WAAW,IAAI,MAAM;IAMrB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAQjB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B;;;OAGG;IACH,KAAK,IAAI,MAAM,GAAG,SAAS;IAS3B;;;;OAIG;IACH,OAAO,CAAC,QAAQ;yCApJL,KAAK;2CAAL,KAAK;CA4JjB"}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { Component, ElementRef, EventEmitter, inject, Output,
|
|
7
|
-
import { useTranslation } from '@molecule/app-angular';
|
|
6
|
+
import { Component, ElementRef, EventEmitter, inject, Output, ViewChild } from '@angular/core';
|
|
7
|
+
import { MolPlacement, setElementPresent, usePlacement, useTranslation, } from '@molecule/app-angular';
|
|
8
8
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
9
|
import { hostElement } from '../utilities/element.js';
|
|
10
10
|
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
11
11
|
import { styleText } from '../utilities/style.js';
|
|
12
|
-
import { SlotWrapper } from './button.component.js';
|
|
13
12
|
import * as i0 from "@angular/core";
|
|
13
|
+
import * as i1 from "@molecule/app-angular";
|
|
14
14
|
const _c0 = ["iconSlot"];
|
|
15
15
|
const _c1 = ["defaultGlyph"];
|
|
16
16
|
const _c2 = [[["", "slot", "icon"]], "*"];
|
|
@@ -65,9 +65,9 @@ const STATUS_ICON = {
|
|
|
65
65
|
* the icon wrapper span exists only when a custom icon is given or the status
|
|
66
66
|
* has a default glyph, and its content is the custom icon XOR the default
|
|
67
67
|
* glyph. Here the span and the default glyph both always exist in the
|
|
68
|
-
* template (projection capture points) and are
|
|
69
|
-
* React would not render them (
|
|
70
|
-
*
|
|
68
|
+
* template (projection capture points) and are taken out of the DOM when
|
|
69
|
+
* React would not render them (`setElementPresent`); the decision is made in
|
|
70
|
+
* the placement function, where projected content is current.
|
|
71
71
|
*/
|
|
72
72
|
export class Alert {
|
|
73
73
|
/** Alert title. */
|
|
@@ -99,13 +99,16 @@ export class Alert {
|
|
|
99
99
|
/** The default status glyph (detached when a custom icon is projected). */
|
|
100
100
|
defaultGlyph;
|
|
101
101
|
hasCustomIcon = false;
|
|
102
|
+
/** Places the icon wrapper and the default glyph as React renders them. */
|
|
103
|
+
constructor() {
|
|
104
|
+
usePlacement((hasContent) => this.syncIcon(hasContent));
|
|
105
|
+
}
|
|
102
106
|
/**
|
|
103
107
|
* Reactive translation, read in the injection context. Its `t` reads the
|
|
104
108
|
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
105
109
|
* does not).
|
|
106
110
|
*/
|
|
107
111
|
i18n = useTranslation();
|
|
108
|
-
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
109
112
|
host = inject(ElementRef);
|
|
110
113
|
/** The element a caller's ref receives: the host `<div>`. */
|
|
111
114
|
element = hostElement(this.host);
|
|
@@ -183,30 +186,18 @@ export class Alert {
|
|
|
183
186
|
this.host.nativeElement.getAttribute('data-mol-id') ??
|
|
184
187
|
undefined);
|
|
185
188
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Decides icon presence at view init (view queries resolve only then) and
|
|
188
|
-
* applies React's conditions.
|
|
189
|
-
*/
|
|
190
|
-
ngAfterViewInit() {
|
|
191
|
-
const span = this.iconSlot?.nativeElement;
|
|
192
|
-
const glyph = this.defaultGlyph?.nativeElement;
|
|
193
|
-
// Projected nodes are the span's children other than the default glyph.
|
|
194
|
-
this.hasCustomIcon = !!span && hasNodesExcept(span, glyph);
|
|
195
|
-
this.syncIcon();
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Re-reconciles on later passes.
|
|
199
|
-
*/
|
|
200
|
-
ngDoCheck() {
|
|
201
|
-
this.syncIcon();
|
|
202
|
-
}
|
|
203
189
|
/**
|
|
204
190
|
* Applies React's `{(icon || defaultIcon) && <span>{icon || defaultIcon}</span>}`.
|
|
191
|
+
*
|
|
192
|
+
* @param hasContent - Reads whether a slot has content.
|
|
205
193
|
*/
|
|
206
|
-
syncIcon() {
|
|
194
|
+
syncIcon(hasContent) {
|
|
207
195
|
const span = this.iconSlot?.nativeElement;
|
|
208
|
-
this.
|
|
209
|
-
|
|
196
|
+
const glyph = this.defaultGlyph?.nativeElement;
|
|
197
|
+
// The capture holds the always-mounted default glyph first, then the slot.
|
|
198
|
+
this.hasCustomIcon = hasContent(span, 1);
|
|
199
|
+
setElementPresent(glyph, !this.hasCustomIcon && this.defaultIcon() !== null);
|
|
200
|
+
setElementPresent(span, this.hasCustomIcon || this.defaultIcon() !== null);
|
|
210
201
|
}
|
|
211
202
|
static ɵfac = function Alert_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Alert)(); };
|
|
212
203
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Alert, selectors: [["div", "mol-alert", ""]], viewQuery: function Alert_Query(rf, ctx) { if (rf & 1) {
|
|
@@ -219,7 +210,7 @@ export class Alert {
|
|
|
219
210
|
i0.ɵɵattribute("title", null)("role", ctx.live ? "alert" : "status")("data-testid", ctx.testId)("data-mol-id", ctx.molId());
|
|
220
211
|
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
221
212
|
i0.ɵɵclassMap(ctx.classes());
|
|
222
|
-
} }, inputs: { title: "title", status: "status", variant: "variant", live: "live", dismissible: "dismissible", dismissLabel: "dismissLabel", className: "className", style: "style", testId: "testId", automationId: "automationId", dataMolId: [0, "data-mol-id", "dataMolId"] }, outputs: { dismiss: "dismiss" }, ngContentSelectors: _c3, decls: 10, vars: 9, consts: [["iconSlot", ""], ["defaultGlyph", ""], ["mol-icon", "", 3, "data"], [3, "class"], ["type", "button", 3, "class"], ["type", "button", 3, "click"]], template: function Alert_Template(rf, ctx) { if (rf & 1) {
|
|
213
|
+
} }, inputs: { title: "title", status: "status", variant: "variant", live: "live", dismissible: "dismissible", dismissLabel: "dismissLabel", className: "className", style: "style", testId: "testId", automationId: "automationId", dataMolId: [0, "data-mol-id", "dataMolId"] }, outputs: { dismiss: "dismiss" }, features: [i0.ɵɵHostDirectivesFeature([i1.MolPlacement])], ngContentSelectors: _c3, decls: 10, vars: 9, consts: [["iconSlot", ""], ["defaultGlyph", ""], ["mol-icon", "", 3, "data"], [3, "class"], ["type", "button", 3, "class"], ["type", "button", 3, "click"]], template: function Alert_Template(rf, ctx) { if (rf & 1) {
|
|
223
214
|
i0.ɵɵprojectionDef(_c2);
|
|
224
215
|
i0.ɵɵelementStart(0, "span", null, 0);
|
|
225
216
|
i0.ɵɵnamespaceSVG();
|
|
@@ -252,6 +243,7 @@ export class Alert {
|
|
|
252
243
|
args: [{
|
|
253
244
|
selector: 'div[mol-alert]',
|
|
254
245
|
standalone: true,
|
|
246
|
+
hostDirectives: [MolPlacement],
|
|
255
247
|
imports: [MolIconSvg],
|
|
256
248
|
inputs: [
|
|
257
249
|
'title',
|
|
@@ -298,7 +290,7 @@ export class Alert {
|
|
|
298
290
|
</button>
|
|
299
291
|
}`,
|
|
300
292
|
}]
|
|
301
|
-
}],
|
|
293
|
+
}], () => [], { dismiss: [{
|
|
302
294
|
type: Output
|
|
303
295
|
}], iconSlot: [{
|
|
304
296
|
type: ViewChild,
|
|
@@ -307,26 +299,5 @@ export class Alert {
|
|
|
307
299
|
type: ViewChild,
|
|
308
300
|
args: ['defaultGlyph', { read: ElementRef }]
|
|
309
301
|
}] }); })();
|
|
310
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Alert, { className: "Alert", filePath: "components/alert.component.ts", lineNumber:
|
|
311
|
-
/**
|
|
312
|
-
* Whether an element captured any element or text node other than one
|
|
313
|
-
* excluded element (the always-mounted default glyph).
|
|
314
|
-
*
|
|
315
|
-
* @param el - The wrapper element.
|
|
316
|
-
* @param except - The element to ignore.
|
|
317
|
-
* @returns True when at least one other projected node exists.
|
|
318
|
-
*/
|
|
319
|
-
function hasNodesExcept(el, except) {
|
|
320
|
-
if (!el)
|
|
321
|
-
return false;
|
|
322
|
-
for (const node of Array.from(el.childNodes)) {
|
|
323
|
-
if (node === except)
|
|
324
|
-
continue;
|
|
325
|
-
if (node.nodeType === 1)
|
|
326
|
-
return true;
|
|
327
|
-
if (node.nodeType === 3 && (node.textContent ?? '').trim())
|
|
328
|
-
return true;
|
|
329
|
-
}
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
302
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Alert, { className: "Alert", filePath: "components/alert.component.ts", lineNumber: 107 }); })();
|
|
332
303
|
//# sourceMappingURL=alert.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.component.js","sourceRoot":"","sources":["../../src/components/alert.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"alert.component.js","sourceRoot":"","sources":["../../src/components/alert.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9F,OAAO,EACL,YAAY,EACZ,iBAAiB,EAEjB,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAmB,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,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Ref } from '@angular/core';
|
|
7
7
|
import { asTemplate, nodeText } from '../utilities/node-value.js';
|
|
8
8
|
import * as i0 from "@angular/core";
|
|
9
|
+
import * as i1 from "@molecule/app-angular";
|
|
9
10
|
/**
|
|
10
11
|
* Props for {@link AuthGuard} (React's `AuthGuardProps`, in Angular's form).
|
|
11
12
|
*
|
|
@@ -35,18 +36,18 @@ export interface AuthGuardProps {
|
|
|
35
36
|
* `loginPath` (state `from` carries the attempted location); otherwise it
|
|
36
37
|
* renders the projected children, or `<mol-routed-view />` without them (the
|
|
37
38
|
* matched child route, through whichever routing bond the app wired; it throws
|
|
38
|
-
* when the bond has none: project the page then).
|
|
39
|
-
* (
|
|
40
|
-
*
|
|
41
|
-
* children, so a guard wrapping the whole route
|
|
42
|
-
* loop.
|
|
39
|
+
* when the bond has none: project the page then). React's root is a fragment
|
|
40
|
+
* (or nothing at all while redirecting), so everything the host holds renders
|
|
41
|
+
* in front of the host and the host itself leaves the page. On the login path
|
|
42
|
+
* itself the guard renders its children, so a guard wrapping the whole route
|
|
43
|
+
* tree does not redirect in a loop.
|
|
43
44
|
*
|
|
44
|
-
* The projected children
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* The projected children (and the loading fallback's content) need one stable
|
|
46
|
+
* capture point, so each lives in an always-mounted wrapper whose content is
|
|
47
|
+
* rendered in its own place and whose element leaves the page: React renders
|
|
48
|
+
* them bare, never inside a wrapper element.
|
|
48
49
|
*/
|
|
49
|
-
export declare class AuthGuard
|
|
50
|
+
export declare class AuthGuard {
|
|
50
51
|
/**
|
|
51
52
|
* Element rendered while the auth status is `loading` (a node value, or the
|
|
52
53
|
* projected `[slot=loadingFallback]`). Overrides the default loading tag.
|
|
@@ -71,9 +72,9 @@ export declare class AuthGuard implements AfterViewInit {
|
|
|
71
72
|
defaultLoading?: ElementRef<HTMLDivElement>;
|
|
72
73
|
/** The node-valued fallback (shown when the input is given). */
|
|
73
74
|
dataFallback?: ElementRef<HTMLSpanElement>;
|
|
74
|
-
/** The `loadingFallback` slot capture (
|
|
75
|
+
/** The `loadingFallback` slot capture (its content renders in its own place). */
|
|
75
76
|
fallbackWrap?: ElementRef<HTMLSpanElement>;
|
|
76
|
-
/** The children capture
|
|
77
|
+
/** The children capture (their content renders in its own place). */
|
|
77
78
|
childrenWrap?: ElementRef<HTMLSpanElement>;
|
|
78
79
|
/** Auth state, read in the component's injection context. */
|
|
79
80
|
readonly auth: import("@molecule/app-angular").UseAuthResult<unknown, Record<never, never>>;
|
|
@@ -85,10 +86,9 @@ export declare class AuthGuard implements AfterViewInit {
|
|
|
85
86
|
* does not).
|
|
86
87
|
*/
|
|
87
88
|
private readonly i18n;
|
|
88
|
-
private readonly sync;
|
|
89
89
|
private readonly host;
|
|
90
90
|
private hasFallback;
|
|
91
|
-
/** Whether the guard was given children to project (
|
|
91
|
+
/** Whether the guard was given children to project (read in the placement function). */
|
|
92
92
|
private hasChildren;
|
|
93
93
|
/** Whether the view queries have resolved, so the children capture can be read. */
|
|
94
94
|
private viewReady;
|
|
@@ -100,38 +100,46 @@ export declare class AuthGuard implements AfterViewInit {
|
|
|
100
100
|
private lastAuthenticated;
|
|
101
101
|
/** The login path the guard navigated to for the current redirect state. */
|
|
102
102
|
private redirectedTo;
|
|
103
|
-
/** The children nodes currently adopted into the host. */
|
|
104
|
-
private adopted;
|
|
105
103
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* tracks
|
|
109
|
-
* template binding reads them.
|
|
104
|
+
* Re-evaluates the guard whenever the auth status, the location or the
|
|
105
|
+
* projected slots change. The placement function reads both signals, so its
|
|
106
|
+
* effect tracks them even though no template binding does.
|
|
110
107
|
*/
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Detects the `loadingFallback` slot and the children (view queries resolve
|
|
114
|
-
* only by view init).
|
|
115
|
-
*/
|
|
116
|
-
ngAfterViewInit(): void;
|
|
108
|
+
constructor();
|
|
117
109
|
/**
|
|
118
110
|
* Applies React's branch for the current auth status and location, fires
|
|
119
111
|
* `onAuthenticated` on its rising edge, and redirects once per entry into
|
|
120
112
|
* the redirect state.
|
|
113
|
+
*
|
|
114
|
+
* @param hasContent - Reads whether a slot has content.
|
|
121
115
|
*/
|
|
122
116
|
private reconcile;
|
|
123
117
|
/**
|
|
124
118
|
* Shows exactly one branch's content, the way React's early returns do.
|
|
125
119
|
*
|
|
120
|
+
* React's branch elements render in front of the host, which leaves the
|
|
121
|
+
* page; each capture that holds projected content renders that content in its
|
|
122
|
+
* own place and leaves the page, so the projected nodes are bare, as React
|
|
123
|
+
* renders them.
|
|
124
|
+
*
|
|
126
125
|
* @param branch - The branch to render.
|
|
127
126
|
*/
|
|
128
127
|
private renderBranch;
|
|
128
|
+
/**
|
|
129
|
+
* Renders a capture's content in the capture's own place while `shown`, and
|
|
130
|
+
* leaves the capture element itself out of the page either way: React
|
|
131
|
+
* renders the content bare, never inside the capture's span.
|
|
132
|
+
*
|
|
133
|
+
* @param capture - The capture element (its own template content, projected or not).
|
|
134
|
+
* @param shown - Whether React would render that content now.
|
|
135
|
+
*/
|
|
136
|
+
private placeSlot;
|
|
129
137
|
/**
|
|
130
138
|
* The localized default loading text.
|
|
131
139
|
* @returns The translated text.
|
|
132
140
|
*/
|
|
133
141
|
loadingText(): string;
|
|
134
142
|
static ɵfac: i0.ɵɵFactoryDeclaration<AuthGuard, never>;
|
|
135
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<AuthGuard, "mol-auth-guard", never, { "loadingFallback": { "alias": "loadingFallback"; "required": false; }; "loadingKey": { "alias": "loadingKey"; "required": false; }; "loadingDefault": { "alias": "loadingDefault"; "required": false; }; "loginPath": { "alias": "loginPath"; "required": false; }; "onAuthenticated": { "alias": "onAuthenticated"; "required": false; }; }, {}, never, ["[slot=loadingFallback]", "*"], true,
|
|
143
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AuthGuard, "mol-auth-guard", never, { "loadingFallback": { "alias": "loadingFallback"; "required": false; }; "loadingKey": { "alias": "loadingKey"; "required": false; }; "loadingDefault": { "alias": "loadingDefault"; "required": false; }; "loginPath": { "alias": "loginPath"; "required": false; }; "onAuthenticated": { "alias": "onAuthenticated"; "required": false; }; }, {}, never, ["[slot=loadingFallback]", "*"], true, [{ directive: typeof i1.MolPlacement; inputs: {}; outputs: {}; }]>;
|
|
136
144
|
}
|
|
137
145
|
//# sourceMappingURL=auth-guard.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-guard.component.d.ts","sourceRoot":"","sources":["../../src/components/auth-guard.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"auth-guard.component.d.ts","sourceRoot":"","sources":["../../src/components/auth-guard.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAa,UAAU,EAAkB,KAAK,WAAW,EAAa,MAAM,eAAe,CAAA;AAelG,OAAO,EAAE,UAAU,EAAW,QAAQ,EAAE,MAAM,4BAA4B,CAAA;;;AAG1E;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IACxD,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;CAC7B;AAUD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAiBa,SAAS;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;IACnD;;;OAGG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;IACzC,uEAAuE;IACvE,cAAc,CAAC,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
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { Component,
|
|
7
|
-
import { RoutedView, useAuth, useRouter, useTranslation } from '@molecule/app-angular';
|
|
6
|
+
import { Component, ElementRef, inject, signal, ViewChild } from '@angular/core';
|
|
7
|
+
import { MolPlacement, placeContent, placeContentBefore, RoutedView, setElementPresent, useAuth, usePlacement, useRouter, useTranslation, } from '@molecule/app-angular';
|
|
8
8
|
import { asTemplate, isGiven, nodeText } from '../utilities/node-value.js';
|
|
9
|
-
import { hasNodes, SlotWrapper } from './button.component.js';
|
|
10
9
|
import { MolTemplateOutlet } from './template-outlet.directive.js';
|
|
11
10
|
import * as i0 from "@angular/core";
|
|
11
|
+
import * as i1 from "@molecule/app-angular";
|
|
12
12
|
const _c0 = ["defaultLoading"];
|
|
13
13
|
const _c1 = ["dataFallback"];
|
|
14
14
|
const _c2 = ["fallbackWrap"];
|
|
@@ -35,16 +35,16 @@ const loginPathname = (loginPath) => loginPath.split(/[?#]/)[0] || '/';
|
|
|
35
35
|
* `loginPath` (state `from` carries the attempted location); otherwise it
|
|
36
36
|
* renders the projected children, or `<mol-routed-view />` without them (the
|
|
37
37
|
* matched child route, through whichever routing bond the app wired; it throws
|
|
38
|
-
* when the bond has none: project the page then).
|
|
39
|
-
* (
|
|
40
|
-
*
|
|
41
|
-
* children, so a guard wrapping the whole route
|
|
42
|
-
* loop.
|
|
38
|
+
* when the bond has none: project the page then). React's root is a fragment
|
|
39
|
+
* (or nothing at all while redirecting), so everything the host holds renders
|
|
40
|
+
* in front of the host and the host itself leaves the page. On the login path
|
|
41
|
+
* itself the guard renders its children, so a guard wrapping the whole route
|
|
42
|
+
* tree does not redirect in a loop.
|
|
43
43
|
*
|
|
44
|
-
* The projected children
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
44
|
+
* The projected children (and the loading fallback's content) need one stable
|
|
45
|
+
* capture point, so each lives in an always-mounted wrapper whose content is
|
|
46
|
+
* rendered in its own place and whose element leaves the page: React renders
|
|
47
|
+
* them bare, never inside a wrapper element.
|
|
48
48
|
*/
|
|
49
49
|
export class AuthGuard {
|
|
50
50
|
/**
|
|
@@ -71,9 +71,9 @@ export class AuthGuard {
|
|
|
71
71
|
defaultLoading;
|
|
72
72
|
/** The node-valued fallback (shown when the input is given). */
|
|
73
73
|
dataFallback;
|
|
74
|
-
/** The `loadingFallback` slot capture (
|
|
74
|
+
/** The `loadingFallback` slot capture (its content renders in its own place). */
|
|
75
75
|
fallbackWrap;
|
|
76
|
-
/** The children capture
|
|
76
|
+
/** The children capture (their content renders in its own place). */
|
|
77
77
|
childrenWrap;
|
|
78
78
|
/** Auth state, read in the component's injection context. */
|
|
79
79
|
auth = useAuth();
|
|
@@ -85,10 +85,9 @@ export class AuthGuard {
|
|
|
85
85
|
* does not).
|
|
86
86
|
*/
|
|
87
87
|
i18n = useTranslation();
|
|
88
|
-
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
89
88
|
host = inject(ElementRef);
|
|
90
89
|
hasFallback = false;
|
|
91
|
-
/** Whether the guard was given children to project (
|
|
90
|
+
/** Whether the guard was given children to project (read in the placement function). */
|
|
92
91
|
hasChildren = false;
|
|
93
92
|
/** Whether the view queries have resolved, so the children capture can be read. */
|
|
94
93
|
viewReady = false;
|
|
@@ -101,36 +100,25 @@ export class AuthGuard {
|
|
|
101
100
|
lastAuthenticated = false;
|
|
102
101
|
/** The login path the guard navigated to for the current redirect state. */
|
|
103
102
|
redirectedTo = null;
|
|
104
|
-
/** The children nodes currently adopted into the host. */
|
|
105
|
-
adopted = [];
|
|
106
103
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* tracks
|
|
110
|
-
* template binding reads them.
|
|
104
|
+
* Re-evaluates the guard whenever the auth status, the location or the
|
|
105
|
+
* projected slots change. The placement function reads both signals, so its
|
|
106
|
+
* effect tracks them even though no template binding does.
|
|
111
107
|
*/
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
this.router.location();
|
|
115
|
-
this.reconcile();
|
|
116
|
-
}, /* @ts-ignore */
|
|
117
|
-
...(ngDevMode ? [{ debugName: "guardEffect" }] : /* istanbul ignore next */ []));
|
|
118
|
-
/**
|
|
119
|
-
* Detects the `loadingFallback` slot and the children (view queries resolve
|
|
120
|
-
* only by view init).
|
|
121
|
-
*/
|
|
122
|
-
ngAfterViewInit() {
|
|
123
|
-
this.hasFallback = hasNodes(this.fallbackWrap?.nativeElement);
|
|
124
|
-
this.hasChildren = hasNodes(this.childrenWrap?.nativeElement);
|
|
125
|
-
this.viewReady = true;
|
|
126
|
-
this.reconcile();
|
|
108
|
+
constructor() {
|
|
109
|
+
usePlacement((hasContent) => this.reconcile(hasContent));
|
|
127
110
|
}
|
|
128
111
|
/**
|
|
129
112
|
* Applies React's branch for the current auth status and location, fires
|
|
130
113
|
* `onAuthenticated` on its rising edge, and redirects once per entry into
|
|
131
114
|
* the redirect state.
|
|
115
|
+
*
|
|
116
|
+
* @param hasContent - Reads whether a slot has content.
|
|
132
117
|
*/
|
|
133
|
-
reconcile() {
|
|
118
|
+
reconcile(hasContent) {
|
|
119
|
+
this.hasFallback = hasContent(this.fallbackWrap?.nativeElement);
|
|
120
|
+
this.hasChildren = hasContent(this.childrenWrap?.nativeElement);
|
|
121
|
+
this.viewReady = this.childrenWrap !== undefined;
|
|
134
122
|
const status = this.auth.status();
|
|
135
123
|
const authenticated = this.auth.isAuthenticated();
|
|
136
124
|
if (this.onAuthenticated && authenticated && !this.lastAuthenticated)
|
|
@@ -157,35 +145,42 @@ export class AuthGuard {
|
|
|
157
145
|
/**
|
|
158
146
|
* Shows exactly one branch's content, the way React's early returns do.
|
|
159
147
|
*
|
|
148
|
+
* React's branch elements render in front of the host, which leaves the
|
|
149
|
+
* page; each capture that holds projected content renders that content in its
|
|
150
|
+
* own place and leaves the page, so the projected nodes are bare, as React
|
|
151
|
+
* renders them.
|
|
152
|
+
*
|
|
160
153
|
* @param branch - The branch to render.
|
|
161
154
|
*/
|
|
162
155
|
renderBranch(branch) {
|
|
163
156
|
const host = this.host.nativeElement;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
while (wrap.firstChild) {
|
|
168
|
-
const node = wrap.firstChild;
|
|
169
|
-
host.appendChild(node);
|
|
170
|
-
this.adopted.push(node);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
for (const node of this.adopted) {
|
|
175
|
-
if (node.parentElement === host)
|
|
176
|
-
wrap.appendChild(node);
|
|
177
|
-
}
|
|
178
|
-
this.adopted = [];
|
|
179
|
-
}
|
|
180
|
-
// The capture span itself never renders (React's children are bare).
|
|
181
|
-
this.sync.sync(this.childrenWrap?.nativeElement, false);
|
|
182
|
-
}
|
|
157
|
+
// React's root is a fragment (or nothing): everything the host holds renders in front of it.
|
|
158
|
+
placeContentBefore(host, host);
|
|
159
|
+
setElementPresent(host, false);
|
|
183
160
|
this.routed.set(this.viewReady && branch === 'children' && !this.hasChildren);
|
|
184
161
|
const loading = branch === 'loading';
|
|
185
162
|
const hasNode = isGiven(this.loadingFallback);
|
|
186
|
-
this.
|
|
187
|
-
this.
|
|
188
|
-
this.
|
|
163
|
+
this.placeSlot(this.childrenWrap?.nativeElement, branch === 'children');
|
|
164
|
+
this.placeSlot(this.fallbackWrap?.nativeElement, loading && !hasNode && this.hasFallback);
|
|
165
|
+
this.placeSlot(this.dataFallback?.nativeElement, loading && hasNode);
|
|
166
|
+
setElementPresent(this.defaultLoading?.nativeElement, loading && !hasNode && !this.hasFallback);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Renders a capture's content in the capture's own place while `shown`, and
|
|
170
|
+
* leaves the capture element itself out of the page either way: React
|
|
171
|
+
* renders the content bare, never inside the capture's span.
|
|
172
|
+
*
|
|
173
|
+
* @param capture - The capture element (its own template content, projected or not).
|
|
174
|
+
* @param shown - Whether React would render that content now.
|
|
175
|
+
*/
|
|
176
|
+
placeSlot(capture, shown) {
|
|
177
|
+
if (!capture)
|
|
178
|
+
return;
|
|
179
|
+
if (shown)
|
|
180
|
+
placeContentBefore(capture, capture);
|
|
181
|
+
else
|
|
182
|
+
placeContent(capture, null);
|
|
183
|
+
setElementPresent(capture, false);
|
|
189
184
|
}
|
|
190
185
|
/**
|
|
191
186
|
* The localized default loading text.
|
|
@@ -205,7 +200,7 @@ export class AuthGuard {
|
|
|
205
200
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dataFallback = _t.first);
|
|
206
201
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.fallbackWrap = _t.first);
|
|
207
202
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childrenWrap = _t.first);
|
|
208
|
-
} },
|
|
203
|
+
} }, inputs: { loadingFallback: "loadingFallback", loadingKey: "loadingKey", loadingDefault: "loadingDefault", loginPath: "loginPath", onAuthenticated: "onAuthenticated" }, features: [i0.ɵɵHostDirectivesFeature([i1.MolPlacement])], ngContentSelectors: _c5, decls: 14, vars: 4, consts: [["defaultLoading", ""], ["dataFallback", ""], ["fallbackWrap", ""], ["childrenWrap", ""], ["data-mol-id", "auth-guard-loading"], [3, "molTemplateOutlet"]], template: function AuthGuard_Template(rf, ctx) { if (rf & 1) {
|
|
209
204
|
i0.ɵɵprojectionDef(_c4);
|
|
210
205
|
i0.ɵɵelementStart(0, "div", 4, 0);
|
|
211
206
|
i0.ɵɵtext(2);
|
|
@@ -237,12 +232,9 @@ export class AuthGuard {
|
|
|
237
232
|
args: [{
|
|
238
233
|
selector: 'mol-auth-guard',
|
|
239
234
|
standalone: true,
|
|
235
|
+
hostDirectives: [MolPlacement],
|
|
240
236
|
imports: [MolTemplateOutlet, RoutedView],
|
|
241
237
|
inputs: ['loadingFallback', 'loadingKey', 'loadingDefault', 'loginPath', 'onAuthenticated'],
|
|
242
|
-
host: {
|
|
243
|
-
'data-parity-unwrap': '',
|
|
244
|
-
style: 'display: contents',
|
|
245
|
-
},
|
|
246
238
|
template: `<div data-mol-id="auth-guard-loading" #defaultLoading>{{ loadingText() }}</div>
|
|
247
239
|
<span #dataFallback
|
|
248
240
|
><ng-container [molTemplateOutlet]="asTemplate(loadingFallback)"></ng-container
|
|
@@ -254,7 +246,7 @@ export class AuthGuard {
|
|
|
254
246
|
<mol-routed-view />
|
|
255
247
|
}`,
|
|
256
248
|
}]
|
|
257
|
-
}],
|
|
249
|
+
}], () => [], { defaultLoading: [{
|
|
258
250
|
type: ViewChild,
|
|
259
251
|
args: ['defaultLoading']
|
|
260
252
|
}], dataFallback: [{
|
|
@@ -267,5 +259,5 @@ export class AuthGuard {
|
|
|
267
259
|
type: ViewChild,
|
|
268
260
|
args: ['childrenWrap']
|
|
269
261
|
}] }); })();
|
|
270
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AuthGuard, { className: "AuthGuard", filePath: "components/auth-guard.component.ts", lineNumber:
|
|
262
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AuthGuard, { className: "AuthGuard", filePath: "components/auth-guard.component.ts", lineNumber: 91 }); })();
|
|
271
263
|
//# sourceMappingURL=auth-guard.component.js.map
|