@molecule/app-ui-angular 1.0.5 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11742 -1145
- package/dist/components/accordion.component.d.ts +114 -0
- package/dist/components/accordion.component.d.ts.map +1 -0
- package/dist/components/accordion.component.js +286 -0
- package/dist/components/accordion.component.js.map +1 -0
- package/dist/components/alert.component.d.ts +81 -37
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +232 -146
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +94 -0
- package/dist/components/auth-guard.component.d.ts.map +1 -0
- package/dist/components/auth-guard.component.js +212 -0
- package/dist/components/auth-guard.component.js.map +1 -0
- package/dist/components/avatar.component.d.ts +97 -0
- package/dist/components/avatar.component.d.ts.map +1 -0
- package/dist/components/avatar.component.js +216 -0
- package/dist/components/avatar.component.js.map +1 -0
- package/dist/components/badge.component.d.ts +27 -12
- package/dist/components/badge.component.d.ts.map +1 -1
- package/dist/components/badge.component.js +47 -47
- package/dist/components/badge.component.js.map +1 -1
- package/dist/components/button.component.d.ts +96 -14
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +232 -87
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/card.component.d.ts +135 -0
- package/dist/components/card.component.d.ts.map +1 -0
- package/dist/components/card.component.js +291 -0
- package/dist/components/card.component.js.map +1 -0
- package/dist/components/checkbox.component.d.ts +102 -29
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +222 -113
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +130 -0
- package/dist/components/confirm-button.component.d.ts.map +1 -0
- package/dist/components/confirm-button.component.js +322 -0
- package/dist/components/confirm-button.component.js.map +1 -0
- package/dist/components/confirm-dialog.component.d.ts +60 -0
- package/dist/components/confirm-dialog.component.d.ts.map +1 -0
- package/dist/components/confirm-dialog.component.js +152 -0
- package/dist/components/confirm-dialog.component.js.map +1 -0
- package/dist/components/dropdown.component.d.ts +313 -0
- package/dist/components/dropdown.component.d.ts.map +1 -0
- package/dist/components/dropdown.component.js +919 -0
- package/dist/components/dropdown.component.js.map +1 -0
- package/dist/components/empty-state.component.d.ts +73 -0
- package/dist/components/empty-state.component.d.ts.map +1 -0
- package/dist/components/empty-state.component.js +180 -0
- package/dist/components/empty-state.component.js.map +1 -0
- package/dist/components/floating-input.component.d.ts +86 -0
- package/dist/components/floating-input.component.d.ts.map +1 -0
- package/dist/components/floating-input.component.js +167 -0
- package/dist/components/floating-input.component.js.map +1 -0
- package/dist/components/form-field.component.d.ts +111 -0
- package/dist/components/form-field.component.d.ts.map +1 -0
- package/dist/components/form-field.component.js +300 -0
- package/dist/components/form-field.component.js.map +1 -0
- package/dist/components/form.component.d.ts +77 -0
- package/dist/components/form.component.d.ts.map +1 -0
- package/dist/components/form.component.js +222 -0
- package/dist/components/form.component.js.map +1 -0
- package/dist/components/icon.component.d.ts +85 -0
- package/dist/components/icon.component.d.ts.map +1 -0
- package/dist/components/icon.component.js +187 -0
- package/dist/components/icon.component.js.map +1 -0
- package/dist/components/index.d.ts +49 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +49 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.component.d.ts +157 -54
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +437 -222
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/label.component.d.ts +29 -0
- package/dist/components/label.component.d.ts.map +1 -0
- package/dist/components/label.component.js +60 -0
- package/dist/components/label.component.js.map +1 -0
- package/dist/components/language-picker.component.d.ts +124 -0
- package/dist/components/language-picker.component.d.ts.map +1 -0
- package/dist/components/language-picker.component.js +305 -0
- package/dist/components/language-picker.component.js.map +1 -0
- package/dist/components/layout.component.d.ts +167 -0
- package/dist/components/layout.component.d.ts.map +1 -0
- package/dist/components/layout.component.js +364 -0
- package/dist/components/layout.component.js.map +1 -0
- package/dist/components/load-error-banner.component.d.ts +103 -0
- package/dist/components/load-error-banner.component.d.ts.map +1 -0
- package/dist/components/load-error-banner.component.js +263 -0
- package/dist/components/load-error-banner.component.js.map +1 -0
- package/dist/components/modal.component.d.ts +125 -95
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +458 -271
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/alert.component.d.ts +77 -0
- package/dist/components/molecule/alert.component.d.ts.map +1 -0
- package/dist/components/molecule/alert.component.js +229 -0
- package/dist/components/molecule/alert.component.js.map +1 -0
- package/dist/components/molecule/badge.component.d.ts +27 -0
- package/dist/components/molecule/badge.component.d.ts.map +1 -0
- package/dist/components/molecule/badge.component.js +79 -0
- package/dist/components/molecule/badge.component.js.map +1 -0
- package/dist/components/molecule/button.component.d.ts +38 -0
- package/dist/components/molecule/button.component.d.ts.map +1 -0
- package/dist/components/molecule/button.component.js +137 -0
- package/dist/components/molecule/button.component.js.map +1 -0
- package/dist/components/molecule/checkbox.component.d.ts +53 -0
- package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
- package/dist/components/molecule/checkbox.component.js +166 -0
- package/dist/components/molecule/checkbox.component.js.map +1 -0
- package/dist/components/molecule/index.d.ts +18 -0
- package/dist/components/molecule/index.d.ts.map +1 -0
- package/dist/components/molecule/index.js +18 -0
- package/dist/components/molecule/index.js.map +1 -0
- package/dist/components/molecule/input.component.d.ts +93 -0
- package/dist/components/molecule/input.component.d.ts.map +1 -0
- package/dist/components/molecule/input.component.js +314 -0
- package/dist/components/molecule/input.component.js.map +1 -0
- package/dist/components/molecule/modal.component.d.ts +148 -0
- package/dist/components/molecule/modal.component.d.ts.map +1 -0
- package/dist/components/molecule/modal.component.js +382 -0
- package/dist/components/molecule/modal.component.js.map +1 -0
- package/dist/components/molecule/radio-group.component.d.ts +63 -0
- package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
- package/dist/components/molecule/radio-group.component.js +208 -0
- package/dist/components/molecule/radio-group.component.js.map +1 -0
- package/dist/components/molecule/select.component.d.ts +72 -0
- package/dist/components/molecule/select.component.d.ts.map +1 -0
- package/dist/components/molecule/select.component.js +274 -0
- package/dist/components/molecule/select.component.js.map +1 -0
- package/dist/components/molecule/spinner.component.d.ts +42 -0
- package/dist/components/molecule/spinner.component.d.ts.map +1 -0
- package/dist/components/molecule/spinner.component.js +122 -0
- package/dist/components/molecule/spinner.component.js.map +1 -0
- package/dist/components/molecule/switch.component.d.ts +54 -0
- package/dist/components/molecule/switch.component.d.ts.map +1 -0
- package/dist/components/molecule/switch.component.js +148 -0
- package/dist/components/molecule/switch.component.js.map +1 -0
- package/dist/components/molecule/toast.component.d.ts +98 -0
- package/dist/components/molecule/toast.component.d.ts.map +1 -0
- package/dist/components/molecule/toast.component.js +305 -0
- package/dist/components/molecule/toast.component.js.map +1 -0
- package/dist/components/molecule/tooltip.component.d.ts +77 -0
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
- package/dist/components/molecule/tooltip.component.js +316 -0
- package/dist/components/molecule/tooltip.component.js.map +1 -0
- package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
- package/dist/components/optimistic-toggle-button.component.js +296 -0
- package/dist/components/optimistic-toggle-button.component.js.map +1 -0
- package/dist/components/page-header.component.d.ts +77 -0
- package/dist/components/page-header.component.d.ts.map +1 -0
- package/dist/components/page-header.component.js +225 -0
- package/dist/components/page-header.component.js.map +1 -0
- package/dist/components/page-shell.component.d.ts +101 -0
- package/dist/components/page-shell.component.d.ts.map +1 -0
- package/dist/components/page-shell.component.js +221 -0
- package/dist/components/page-shell.component.js.map +1 -0
- package/dist/components/pagination.component.d.ts +137 -0
- package/dist/components/pagination.component.d.ts.map +1 -0
- package/dist/components/pagination.component.js +419 -0
- package/dist/components/pagination.component.js.map +1 -0
- package/dist/components/panel-close.component.d.ts +43 -0
- package/dist/components/panel-close.component.d.ts.map +1 -0
- package/dist/components/panel-close.component.js +75 -0
- package/dist/components/panel-close.component.js.map +1 -0
- package/dist/components/progress.component.d.ts +84 -0
- package/dist/components/progress.component.d.ts.map +1 -0
- package/dist/components/progress.component.js +219 -0
- package/dist/components/progress.component.js.map +1 -0
- package/dist/components/prompt-dialog.component.d.ts +121 -0
- package/dist/components/prompt-dialog.component.d.ts.map +1 -0
- package/dist/components/prompt-dialog.component.js +332 -0
- package/dist/components/prompt-dialog.component.js.map +1 -0
- package/dist/components/radio-group.component.d.ts +66 -34
- package/dist/components/radio-group.component.d.ts.map +1 -1
- package/dist/components/radio-group.component.js +146 -125
- package/dist/components/radio-group.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +408 -0
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
- package/dist/components/responsive-app-shell.component.js +1144 -0
- package/dist/components/responsive-app-shell.component.js.map +1 -0
- package/dist/components/select.component.d.ts +135 -38
- package/dist/components/select.component.d.ts.map +1 -1
- package/dist/components/select.component.js +373 -181
- package/dist/components/select.component.js.map +1 -1
- package/dist/components/separator.component.d.ts +39 -0
- package/dist/components/separator.component.d.ts.map +1 -0
- package/dist/components/separator.component.js +73 -0
- package/dist/components/separator.component.js.map +1 -0
- package/dist/components/sidebar-user-card.component.d.ts +106 -0
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
- package/dist/components/sidebar-user-card.component.js +277 -0
- package/dist/components/sidebar-user-card.component.js.map +1 -0
- package/dist/components/skeleton.component.d.ts +100 -0
- package/dist/components/skeleton.component.d.ts.map +1 -0
- package/dist/components/skeleton.component.js +214 -0
- package/dist/components/skeleton.component.js.map +1 -0
- package/dist/components/spinner.component.d.ts +36 -19
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.component.js +69 -71
- package/dist/components/spinner.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +72 -29
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +163 -91
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +193 -0
- package/dist/components/table.component.d.ts.map +1 -0
- package/dist/components/table.component.js +550 -0
- package/dist/components/table.component.js.map +1 -0
- package/dist/components/tabs.component.d.ts +140 -0
- package/dist/components/tabs.component.d.ts.map +1 -0
- package/dist/components/tabs.component.js +390 -0
- package/dist/components/tabs.component.js.map +1 -0
- package/dist/components/template-outlet.directive.d.ts +50 -0
- package/dist/components/template-outlet.directive.d.ts.map +1 -0
- package/dist/components/template-outlet.directive.js +81 -0
- package/dist/components/template-outlet.directive.js.map +1 -0
- package/dist/components/textarea.component.d.ts +151 -0
- package/dist/components/textarea.component.d.ts.map +1 -0
- package/dist/components/textarea.component.js +340 -0
- package/dist/components/textarea.component.js.map +1 -0
- package/dist/components/theme-toggle.component.d.ts +58 -0
- package/dist/components/theme-toggle.component.d.ts.map +1 -0
- package/dist/components/theme-toggle.component.js +124 -0
- package/dist/components/theme-toggle.component.js.map +1 -0
- package/dist/components/toast.component.d.ts +237 -49
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +636 -201
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +95 -45
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +372 -221
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +283 -0
- package/dist/components/user-menu-popover.component.d.ts.map +1 -0
- package/dist/components/user-menu-popover.component.js +646 -0
- package/dist/components/user-menu-popover.component.js.map +1 -0
- package/dist/components/user-menu.component.d.ts +95 -0
- package/dist/components/user-menu.component.d.ts.map +1 -0
- package/dist/components/user-menu.component.js +218 -0
- package/dist/components/user-menu.component.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-is-desktop.d.ts +22 -0
- package/dist/hooks/use-is-desktop.d.ts.map +1 -0
- package/dist/hooks/use-is-desktop.js +37 -0
- package/dist/hooks/use-is-desktop.js.map +1 -0
- package/dist/index.d.ts +32 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/dom-context.d.ts +42 -0
- package/dist/utilities/dom-context.d.ts.map +1 -0
- package/dist/utilities/dom-context.js +66 -0
- package/dist/utilities/dom-context.js.map +1 -0
- package/dist/utilities/focus.d.ts +32 -0
- package/dist/utilities/focus.d.ts.map +1 -0
- package/dist/utilities/focus.js +47 -0
- package/dist/utilities/focus.js.map +1 -0
- package/dist/utilities/form-field-context.d.ts +34 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -0
- package/dist/utilities/form-field-context.js +28 -0
- package/dist/utilities/form-field-context.js.map +1 -0
- package/dist/utilities/form-submit-error.d.ts +17 -0
- package/dist/utilities/form-submit-error.d.ts.map +1 -0
- package/dist/utilities/form-submit-error.js +42 -0
- package/dist/utilities/form-submit-error.js.map +1 -0
- package/dist/utilities/icon-markup.d.ts +17 -0
- package/dist/utilities/icon-markup.d.ts.map +1 -0
- package/dist/utilities/icon-markup.js +46 -0
- package/dist/utilities/icon-markup.js.map +1 -0
- package/dist/utilities/ids.d.ts +15 -0
- package/dist/utilities/ids.d.ts.map +1 -0
- package/dist/utilities/ids.js +19 -0
- package/dist/utilities/ids.js.map +1 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +11 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/initials.d.ts +13 -0
- package/dist/utilities/initials.d.ts.map +1 -0
- package/dist/utilities/initials.js +23 -0
- package/dist/utilities/initials.js.map +1 -0
- package/dist/utilities/node-value.d.ts +31 -0
- package/dist/utilities/node-value.d.ts.map +1 -0
- package/dist/utilities/node-value.js +37 -0
- package/dist/utilities/node-value.js.map +1 -0
- package/dist/utilities/optimistic-value.d.ts +81 -0
- package/dist/utilities/optimistic-value.d.ts.map +1 -0
- package/dist/utilities/optimistic-value.js +154 -0
- package/dist/utilities/optimistic-value.js.map +1 -0
- package/dist/utilities/render-icon.d.ts +77 -7
- package/dist/utilities/render-icon.d.ts.map +1 -1
- package/dist/utilities/render-icon.js +123 -33
- package/dist/utilities/render-icon.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +21 -0
- package/dist/utilities/rest-attrs.d.ts.map +1 -0
- package/dist/utilities/rest-attrs.js +37 -0
- package/dist/utilities/rest-attrs.js.map +1 -0
- package/dist/utilities/style.d.ts +23 -0
- package/dist/utilities/style.d.ts.map +1 -0
- package/dist/utilities/style.js +86 -0
- package/dist/utilities/style.js.map +1 -0
- package/package.json +10 -5
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Alert component (React parity).
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Component, ElementRef, EventEmitter, inject, Output, Renderer2, ViewChild, } from '@angular/core';
|
|
7
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
8
8
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
-
import {
|
|
9
|
+
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
10
|
+
import { styleText } from '../utilities/style.js';
|
|
11
|
+
import { SlotWrapper } from './button.component.js';
|
|
10
12
|
import * as i0 from "@angular/core";
|
|
11
|
-
const _c0 = ["
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const ctx_r0 = i0.ɵɵnextContext();
|
|
18
|
-
i0.ɵɵclassMap(ctx_r0.cm.alertIconWrapper);
|
|
19
|
-
i0.ɵɵadvance();
|
|
20
|
-
i0.ɵɵdomProperty("innerHTML", ctx_r0.statusIconSvg, i0.ɵɵsanitizeHtml);
|
|
21
|
-
} }
|
|
22
|
-
function MoleculeAlert_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
23
|
-
i0.ɵɵdomElementStart(0, "h5");
|
|
13
|
+
const _c0 = ["iconSlot"];
|
|
14
|
+
const _c1 = ["defaultGlyph"];
|
|
15
|
+
const _c2 = [[["", "slot", "icon"]], "*"];
|
|
16
|
+
const _c3 = ["[slot=icon]", "*"];
|
|
17
|
+
function Alert_Conditional_6_Template(rf, ctx) { if (rf & 1) {
|
|
18
|
+
i0.ɵɵelementStart(0, "h5");
|
|
24
19
|
i0.ɵɵtext(1);
|
|
25
|
-
i0.ɵɵ
|
|
20
|
+
i0.ɵɵelementEnd();
|
|
26
21
|
} if (rf & 2) {
|
|
27
22
|
const ctx_r0 = i0.ɵɵnextContext();
|
|
28
|
-
i0.ɵɵclassMap(ctx_r0.
|
|
23
|
+
i0.ɵɵclassMap(ctx_r0.cm().alertTitle);
|
|
29
24
|
i0.ɵɵadvance();
|
|
30
25
|
i0.ɵɵtextInterpolate(ctx_r0.title);
|
|
31
26
|
} }
|
|
32
|
-
function
|
|
27
|
+
function Alert_Conditional_9_Template(rf, ctx) { if (rf & 1) {
|
|
33
28
|
const _r2 = i0.ɵɵgetCurrentView();
|
|
34
|
-
i0.ɵɵ
|
|
35
|
-
i0.ɵɵ
|
|
36
|
-
i0.ɵɵ
|
|
37
|
-
i0.ɵɵ
|
|
29
|
+
i0.ɵɵelementStart(0, "button", 5);
|
|
30
|
+
i0.ɵɵlistener("click", function Alert_Conditional_9_Template_button_click_0_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.dismiss.emit($event)); });
|
|
31
|
+
i0.ɵɵnamespaceSVG();
|
|
32
|
+
i0.ɵɵelement(1, "svg", 2);
|
|
33
|
+
i0.ɵɵelementEnd();
|
|
38
34
|
} if (rf & 2) {
|
|
39
35
|
const ctx_r0 = i0.ɵɵnextContext();
|
|
40
|
-
i0.ɵɵclassMap(ctx_r0.cm.alertDismiss);
|
|
41
|
-
i0.ɵɵattribute("aria-label", ctx_r0.
|
|
36
|
+
i0.ɵɵclassMap(ctx_r0.cm().alertDismiss);
|
|
37
|
+
i0.ɵɵattribute("aria-label", ctx_r0.dismissText());
|
|
42
38
|
i0.ɵɵadvance();
|
|
43
|
-
i0.ɵɵ
|
|
39
|
+
i0.ɵɵproperty("data", ctx_r0.closeIcon());
|
|
44
40
|
} }
|
|
45
|
-
|
|
41
|
+
/** Alert status → class-map variant. */
|
|
42
|
+
const STATUS_VARIANT = {
|
|
46
43
|
primary: 'default',
|
|
47
44
|
secondary: 'default',
|
|
48
45
|
success: 'success',
|
|
@@ -50,173 +47,262 @@ const statusVariantMap = {
|
|
|
50
47
|
error: 'error',
|
|
51
48
|
info: 'info',
|
|
52
49
|
};
|
|
50
|
+
/** Alert variant → default status glyph (none for `default`). */
|
|
51
|
+
const STATUS_ICON = {
|
|
52
|
+
info: 'info-circle',
|
|
53
|
+
success: 'check-circle',
|
|
54
|
+
warning: 'exclamation-triangle',
|
|
55
|
+
error: 'x-circle',
|
|
56
|
+
};
|
|
53
57
|
/**
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
+
* Alert component.
|
|
59
|
+
*
|
|
60
|
+
* `role` follows `live` (assertive `alert` by default, polite `status` for a
|
|
61
|
+
* banner that is part of the page's normal content).
|
|
62
|
+
*
|
|
63
|
+
* React renders `{(icon || defaultIcon) && <span className={alertIconWrapper}>…}`:
|
|
64
|
+
* the icon wrapper span exists only when a custom icon is given or the status
|
|
65
|
+
* has a default glyph, and its content is the custom icon XOR the default
|
|
66
|
+
* glyph. Here the span and the default glyph both always exist in the
|
|
67
|
+
* template (projection capture points) and are detached from the DOM when
|
|
68
|
+
* React would not render them ({@link SlotWrapper}); the decision is made at
|
|
69
|
+
* view init, when view queries resolve.
|
|
58
70
|
*/
|
|
59
|
-
export class
|
|
71
|
+
export class Alert {
|
|
72
|
+
/** Alert title. */
|
|
60
73
|
title;
|
|
74
|
+
/** Status color. */
|
|
61
75
|
status = 'info';
|
|
76
|
+
/** Visual variant. */
|
|
62
77
|
variant;
|
|
63
|
-
|
|
78
|
+
/** Whether the alert announces assertively (default true). */
|
|
79
|
+
live = true;
|
|
80
|
+
/** Whether a dismiss button renders. */
|
|
81
|
+
dismissible;
|
|
82
|
+
/** Accessible label for the dismiss button. */
|
|
64
83
|
dismissLabel;
|
|
84
|
+
/** Extra classes. */
|
|
65
85
|
className;
|
|
86
|
+
/** Inline style object (React camelCase). */
|
|
66
87
|
style;
|
|
88
|
+
/** `data-testid`. */
|
|
67
89
|
testId;
|
|
90
|
+
/** Fires the raw click event when the dismiss button is pressed. */
|
|
68
91
|
dismiss = new EventEmitter();
|
|
92
|
+
/** The icon wrapper span (projection capture point). */
|
|
93
|
+
iconSlot;
|
|
94
|
+
/** The default status glyph (detached when a custom icon is projected). */
|
|
95
|
+
defaultGlyph;
|
|
96
|
+
hasCustomIcon = false;
|
|
97
|
+
/**
|
|
98
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
99
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
100
|
+
* does not).
|
|
101
|
+
*/
|
|
102
|
+
i18n = useTranslation();
|
|
103
|
+
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
69
104
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @returns The UIClassMap
|
|
105
|
+
* The current class map.
|
|
106
|
+
* @returns The UIClassMap.
|
|
72
107
|
*/
|
|
73
|
-
|
|
108
|
+
cm() {
|
|
74
109
|
return getClassMap();
|
|
75
110
|
}
|
|
76
111
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @returns The
|
|
112
|
+
* The class-map variant for the status.
|
|
113
|
+
* @returns The mapped variant.
|
|
114
|
+
*/
|
|
115
|
+
get alertVariant() {
|
|
116
|
+
return STATUS_VARIANT[this.status] || 'default';
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The default status glyph (none for the `default` variant, matching
|
|
120
|
+
* React's `statusIconMap` gap).
|
|
121
|
+
* @returns The resolved icon, or null when the variant has no glyph.
|
|
79
122
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
123
|
+
defaultIcon() {
|
|
124
|
+
const name = STATUS_ICON[this.alertVariant];
|
|
125
|
+
return name ? resolveIcon(name, this.cm().iconMd) : null;
|
|
82
126
|
}
|
|
83
127
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
128
|
+
* A non-null glyph to bind (an empty resolved icon when the variant has
|
|
129
|
+
* none; that svg is detached from the DOM anyway).
|
|
130
|
+
* @returns The resolved icon data.
|
|
86
131
|
*/
|
|
87
|
-
|
|
88
|
-
return this.
|
|
132
|
+
resolvedDefaultIcon() {
|
|
133
|
+
return (this.defaultIcon() ?? {
|
|
134
|
+
icon: { paths: [] },
|
|
135
|
+
className: '',
|
|
136
|
+
stroked: false,
|
|
137
|
+
viewBox: '0 0 20 20',
|
|
138
|
+
});
|
|
89
139
|
}
|
|
90
140
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @returns The
|
|
141
|
+
* The dismiss button's X glyph.
|
|
142
|
+
* @returns The resolved icon.
|
|
93
143
|
*/
|
|
94
|
-
|
|
95
|
-
return this.cm.
|
|
144
|
+
closeIcon() {
|
|
145
|
+
return resolveIcon('x-mark', this.cm().iconSm);
|
|
96
146
|
}
|
|
97
147
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @returns The
|
|
148
|
+
* The dismiss button's accessible label.
|
|
149
|
+
* @returns The label text.
|
|
100
150
|
*/
|
|
101
|
-
|
|
102
|
-
return
|
|
151
|
+
dismissText() {
|
|
152
|
+
return (this.dismissLabel ?? this.i18n.t('ui.alert.dismiss', undefined, { defaultValue: 'Dismiss' }));
|
|
103
153
|
}
|
|
104
154
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @returns
|
|
155
|
+
* Computes the alert class list.
|
|
156
|
+
* @returns The class string.
|
|
107
157
|
*/
|
|
108
|
-
|
|
109
|
-
return this.
|
|
158
|
+
classes() {
|
|
159
|
+
return this.cm().cn(this.cm().alert({ variant: this.alertVariant }), this.variant === 'left-accent' && this.cm().alertLeftAccent({ variant: this.alertVariant }), this.className);
|
|
110
160
|
}
|
|
111
|
-
statusIconMap = {
|
|
112
|
-
info: 'info-circle',
|
|
113
|
-
success: 'check-circle',
|
|
114
|
-
warning: 'exclamation-triangle',
|
|
115
|
-
error: 'x-circle',
|
|
116
|
-
};
|
|
117
161
|
/**
|
|
118
|
-
*
|
|
119
|
-
* @returns The
|
|
162
|
+
* Serializes the inline style.
|
|
163
|
+
* @returns The style attribute text.
|
|
120
164
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return name ? getIconSvg(name, this.cm.iconMd) : '';
|
|
165
|
+
hostStyle() {
|
|
166
|
+
return styleText(this.style);
|
|
124
167
|
}
|
|
125
168
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
169
|
+
* Decides icon presence at view init (view queries resolve only then) and
|
|
170
|
+
* applies React's conditions.
|
|
128
171
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
172
|
+
ngAfterViewInit() {
|
|
173
|
+
const span = this.iconSlot?.nativeElement;
|
|
174
|
+
const glyph = this.defaultGlyph?.nativeElement;
|
|
175
|
+
// Projected nodes are the span's children other than the default glyph.
|
|
176
|
+
this.hasCustomIcon = !!span && hasNodesExcept(span, glyph);
|
|
177
|
+
this.syncIcon();
|
|
131
178
|
}
|
|
132
179
|
/**
|
|
133
|
-
*
|
|
134
|
-
* @returns The alert container class name string.
|
|
180
|
+
* Re-reconciles on later passes.
|
|
135
181
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return this.cm.cn(this.cm.alert({ variant: cmVariant }), this.className);
|
|
182
|
+
ngDoCheck() {
|
|
183
|
+
this.syncIcon();
|
|
139
184
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
i0.ɵɵ
|
|
151
|
-
i0.ɵɵdomElementEnd();
|
|
185
|
+
/**
|
|
186
|
+
* Applies React's `{(icon || defaultIcon) && <span>{icon || defaultIcon}</span>}`.
|
|
187
|
+
*/
|
|
188
|
+
syncIcon() {
|
|
189
|
+
const span = this.iconSlot?.nativeElement;
|
|
190
|
+
this.sync.sync(this.defaultGlyph?.nativeElement, !this.hasCustomIcon && this.defaultIcon() !== null, span);
|
|
191
|
+
this.sync.sync(span, this.hasCustomIcon || this.defaultIcon() !== null);
|
|
192
|
+
}
|
|
193
|
+
static ɵfac = function Alert_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Alert)(); };
|
|
194
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Alert, selectors: [["div", "mol-alert", ""]], viewQuery: function Alert_Query(rf, ctx) { if (rf & 1) {
|
|
195
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5, ElementRef);
|
|
152
196
|
} if (rf & 2) {
|
|
153
|
-
|
|
154
|
-
i0.ɵɵ
|
|
155
|
-
i0.ɵɵ
|
|
156
|
-
|
|
157
|
-
i0.ɵɵ
|
|
158
|
-
i0.ɵɵ
|
|
159
|
-
i0.ɵɵclassMap(ctx.
|
|
197
|
+
let _t;
|
|
198
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.iconSlot = _t.first);
|
|
199
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.defaultGlyph = _t.first);
|
|
200
|
+
} }, hostVars: 6, hostBindings: function Alert_HostBindings(rf, ctx) { if (rf & 2) {
|
|
201
|
+
i0.ɵɵattribute("role", ctx.live ? "alert" : "status")("data-testid", ctx.testId);
|
|
202
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
203
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
204
|
+
} }, inputs: { title: "title", status: "status", variant: "variant", live: "live", dismissible: "dismissible", dismissLabel: "dismissLabel", className: "className", style: "style", testId: "testId" }, 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) {
|
|
205
|
+
i0.ɵɵprojectionDef(_c2);
|
|
206
|
+
i0.ɵɵelementStart(0, "span", null, 0);
|
|
207
|
+
i0.ɵɵnamespaceSVG();
|
|
208
|
+
i0.ɵɵelement(2, "svg", 2, 1);
|
|
209
|
+
i0.ɵɵprojection(4);
|
|
210
|
+
i0.ɵɵelementEnd();
|
|
211
|
+
i0.ɵɵnamespaceHTML();
|
|
212
|
+
i0.ɵɵelementStart(5, "div");
|
|
213
|
+
i0.ɵɵconditionalCreate(6, Alert_Conditional_6_Template, 2, 3, "h5", 3);
|
|
214
|
+
i0.ɵɵelementStart(7, "div");
|
|
215
|
+
i0.ɵɵprojection(8, 1);
|
|
216
|
+
i0.ɵɵelementEnd()();
|
|
217
|
+
i0.ɵɵconditionalCreate(9, Alert_Conditional_9_Template, 2, 4, "button", 4);
|
|
218
|
+
} if (rf & 2) {
|
|
219
|
+
i0.ɵɵclassMap(ctx.cm().alertIconWrapper);
|
|
220
|
+
i0.ɵɵadvance(2);
|
|
221
|
+
i0.ɵɵproperty("data", ctx.resolvedDefaultIcon());
|
|
222
|
+
i0.ɵɵadvance(3);
|
|
223
|
+
i0.ɵɵclassMap(ctx.cm().alertContent);
|
|
160
224
|
i0.ɵɵadvance();
|
|
161
|
-
i0.ɵɵconditional(ctx.title ?
|
|
225
|
+
i0.ɵɵconditional(ctx.title ? 6 : -1);
|
|
162
226
|
i0.ɵɵadvance();
|
|
163
|
-
i0.ɵɵclassMap(ctx.
|
|
227
|
+
i0.ɵɵclassMap(ctx.cm().alertDescription);
|
|
164
228
|
i0.ɵɵadvance(2);
|
|
165
|
-
i0.ɵɵconditional(ctx.dismissible ?
|
|
166
|
-
} }, encapsulation: 2 });
|
|
229
|
+
i0.ɵɵconditional(ctx.dismissible ? 9 : -1);
|
|
230
|
+
} }, dependencies: [MolIconSvg], encapsulation: 2 });
|
|
167
231
|
}
|
|
168
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(
|
|
232
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Alert, [{
|
|
169
233
|
type: Component,
|
|
170
234
|
args: [{
|
|
171
|
-
selector: 'mol-alert',
|
|
235
|
+
selector: 'div[mol-alert]',
|
|
172
236
|
standalone: true,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
237
|
+
imports: [MolIconSvg],
|
|
238
|
+
inputs: [
|
|
239
|
+
'title',
|
|
240
|
+
'status',
|
|
241
|
+
'variant',
|
|
242
|
+
'live',
|
|
243
|
+
'dismissible',
|
|
244
|
+
'dismissLabel',
|
|
245
|
+
'className',
|
|
246
|
+
'style',
|
|
247
|
+
'testId',
|
|
248
|
+
],
|
|
249
|
+
outputs: ['dismiss'],
|
|
250
|
+
host: {
|
|
251
|
+
'[attr.role]': 'live ? "alert" : "status"',
|
|
252
|
+
'[class]': 'classes()',
|
|
253
|
+
'[style]': 'hostStyle()',
|
|
254
|
+
'[attr.data-testid]': 'testId',
|
|
255
|
+
},
|
|
256
|
+
template: `<span [class]="cm().alertIconWrapper" #iconSlot>
|
|
257
|
+
<svg mol-icon [data]="resolvedDefaultIcon()" #defaultGlyph />
|
|
258
|
+
<ng-content select="[slot=icon]"></ng-content>
|
|
259
|
+
</span>
|
|
260
|
+
<div [class]="cm().alertContent">
|
|
261
|
+
@if (title) {
|
|
262
|
+
<h5 [class]="cm().alertTitle">{{ title }}</h5>
|
|
198
263
|
}
|
|
264
|
+
<div [class]="cm().alertDescription"><ng-content></ng-content></div>
|
|
199
265
|
</div>
|
|
200
|
-
|
|
266
|
+
@if (dismissible) {
|
|
267
|
+
<button
|
|
268
|
+
type="button"
|
|
269
|
+
[class]="cm().alertDismiss"
|
|
270
|
+
[attr.aria-label]="dismissText()"
|
|
271
|
+
(click)="dismiss.emit($event)"
|
|
272
|
+
>
|
|
273
|
+
<svg mol-icon [data]="closeIcon()" />
|
|
274
|
+
</button>
|
|
275
|
+
}`,
|
|
201
276
|
}]
|
|
202
|
-
}], null, {
|
|
203
|
-
type: Input
|
|
204
|
-
}], status: [{
|
|
205
|
-
type: Input
|
|
206
|
-
}], variant: [{
|
|
207
|
-
type: Input
|
|
208
|
-
}], dismissible: [{
|
|
209
|
-
type: Input
|
|
210
|
-
}], dismissLabel: [{
|
|
211
|
-
type: Input
|
|
212
|
-
}], className: [{
|
|
213
|
-
type: Input
|
|
214
|
-
}], style: [{
|
|
215
|
-
type: Input
|
|
216
|
-
}], testId: [{
|
|
217
|
-
type: Input
|
|
218
|
-
}], dismiss: [{
|
|
277
|
+
}], null, { dismiss: [{
|
|
219
278
|
type: Output
|
|
279
|
+
}], iconSlot: [{
|
|
280
|
+
type: ViewChild,
|
|
281
|
+
args: ['iconSlot']
|
|
282
|
+
}], defaultGlyph: [{
|
|
283
|
+
type: ViewChild,
|
|
284
|
+
args: ['defaultGlyph', { read: ElementRef }]
|
|
220
285
|
}] }); })();
|
|
221
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(
|
|
286
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Alert, { className: "Alert", filePath: "components/alert.component.ts", lineNumber: 104 }); })();
|
|
287
|
+
/**
|
|
288
|
+
* Whether an element captured any element or text node other than one
|
|
289
|
+
* excluded element (the always-mounted default glyph).
|
|
290
|
+
*
|
|
291
|
+
* @param el - The wrapper element.
|
|
292
|
+
* @param except - The element to ignore.
|
|
293
|
+
* @returns True when at least one other projected node exists.
|
|
294
|
+
*/
|
|
295
|
+
function hasNodesExcept(el, except) {
|
|
296
|
+
if (!el)
|
|
297
|
+
return false;
|
|
298
|
+
for (const node of Array.from(el.childNodes)) {
|
|
299
|
+
if (node === except)
|
|
300
|
+
continue;
|
|
301
|
+
if (node.nodeType === 1)
|
|
302
|
+
return true;
|
|
303
|
+
if (node.nodeType === 3 && (node.textContent ?? '').trim())
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
222
308
|
//# 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,EAEL,SAAS,EAET,UAAU,EACV,YAAY,EACZ,MAAM,EACN,MAAM,EACN,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;;;;;;;IA8D3C,0BAA8B;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CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthGuard component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type AfterViewInit, ElementRef } from '@angular/core';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
/**
|
|
9
|
+
* Route-element guard for authenticated sections of a routing tree.
|
|
10
|
+
*
|
|
11
|
+
* While the auth status is `'loading'` it renders the `loadingFallback` slot
|
|
12
|
+
* (or the default `data-mol-id="auth-guard-loading"` tag); while
|
|
13
|
+
* `'unauthenticated'` off the login path it renders nothing and redirects to
|
|
14
|
+
* `loginPath` (state `from` carries the attempted location); otherwise it
|
|
15
|
+
* renders the projected children. The host is unwrapped by the DOM normalizer
|
|
16
|
+
* (`data-parity-unwrap`) and `display: contents` keeps it fragment-like —
|
|
17
|
+
* React's root is a fragment. On the login path itself the guard renders its
|
|
18
|
+
* children, so a guard wrapping the whole route tree does not redirect in a
|
|
19
|
+
* loop.
|
|
20
|
+
*
|
|
21
|
+
* The projected children need one stable capture point, so they live in an
|
|
22
|
+
* always-mounted wrapper the guard moves into (or out of) the host itself:
|
|
23
|
+
* React renders them bare, never inside a wrapper element, and renders
|
|
24
|
+
* nothing at all while redirecting.
|
|
25
|
+
*/
|
|
26
|
+
export declare class AuthGuard implements AfterViewInit {
|
|
27
|
+
/**
|
|
28
|
+
* i18n key for the default loading-tag text (default `common.loading`).
|
|
29
|
+
* Ignored when a `loadingFallback` slot is projected.
|
|
30
|
+
*/
|
|
31
|
+
loadingKey?: string;
|
|
32
|
+
/** Fallback text if the i18n key is missing (default `Loading...`). */
|
|
33
|
+
loadingDefault?: string;
|
|
34
|
+
/** Path to redirect to when unauthenticated (default `/login`). */
|
|
35
|
+
loginPath?: string;
|
|
36
|
+
/** Fired when `isAuthenticated` becomes true (also when true at mount). */
|
|
37
|
+
onAuthenticated?: () => void;
|
|
38
|
+
/** The default loading tag. */
|
|
39
|
+
defaultLoading?: ElementRef<HTMLDivElement>;
|
|
40
|
+
/** The `loadingFallback` slot capture (always mounted). */
|
|
41
|
+
fallbackWrap?: ElementRef<HTMLSpanElement>;
|
|
42
|
+
/** The children capture; its nodes are moved bare into the host to render. */
|
|
43
|
+
childrenWrap?: ElementRef<HTMLSpanElement>;
|
|
44
|
+
/** Auth state, read in the component's injection context. */
|
|
45
|
+
readonly auth: import("@molecule/app-angular").UseAuthResult<unknown, Record<never, never>>;
|
|
46
|
+
/** Router state and actions, read in the component's injection context. */
|
|
47
|
+
readonly router: import("@molecule/app-angular").UseRouterResult;
|
|
48
|
+
/**
|
|
49
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
50
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
51
|
+
* does not).
|
|
52
|
+
*/
|
|
53
|
+
private readonly i18n;
|
|
54
|
+
private readonly sync;
|
|
55
|
+
private readonly host;
|
|
56
|
+
private hasFallback;
|
|
57
|
+
private lastAuthenticated;
|
|
58
|
+
/** The login path the guard navigated to for the current redirect state. */
|
|
59
|
+
private redirectedTo;
|
|
60
|
+
/** The children nodes currently adopted into the host. */
|
|
61
|
+
private adopted;
|
|
62
|
+
/**
|
|
63
|
+
* Runs the first reconciliation after the view init (slot detection) and
|
|
64
|
+
* again whenever the auth status or the location changes — the effect
|
|
65
|
+
* tracks both signals directly, so the guard re-evaluates even though no
|
|
66
|
+
* template binding reads them.
|
|
67
|
+
*/
|
|
68
|
+
private readonly guardEffect;
|
|
69
|
+
/**
|
|
70
|
+
* Detects the `loadingFallback` slot presence (view queries resolve only by
|
|
71
|
+
* view init).
|
|
72
|
+
*/
|
|
73
|
+
ngAfterViewInit(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Applies React's branch for the current auth status and location, fires
|
|
76
|
+
* `onAuthenticated` on its rising edge, and redirects once per entry into
|
|
77
|
+
* the redirect state.
|
|
78
|
+
*/
|
|
79
|
+
private reconcile;
|
|
80
|
+
/**
|
|
81
|
+
* Shows exactly one branch's content, the way React's early returns do.
|
|
82
|
+
*
|
|
83
|
+
* @param branch - The branch to render.
|
|
84
|
+
*/
|
|
85
|
+
private renderBranch;
|
|
86
|
+
/**
|
|
87
|
+
* The localized default loading text.
|
|
88
|
+
* @returns The translated text.
|
|
89
|
+
*/
|
|
90
|
+
loadingText(): string;
|
|
91
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthGuard, never>;
|
|
92
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AuthGuard, "mol-auth-guard", never, { "loadingKey": { "alias": "loadingKey"; "required": false; }; "loadingDefault": { "alias": "loadingDefault"; "required": false; }; "loginPath": { "alias": "loginPath"; "required": false; }; "onAuthenticated": { "alias": "onAuthenticated"; "required": false; }; }, {}, never, ["[slot=loadingFallback]", "*"], true, never>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=auth-guard.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-guard.component.d.ts","sourceRoot":"","sources":["../../src/components/auth-guard.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,aAAa,EAGlB,UAAU,EAIX,MAAM,eAAe,CAAA;;AActB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAYa,SAAU,YAAW,aAAa;IAC7C;;;OAGG;IACH,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;IAE5B,+BAA+B;IACF,cAAc,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAA;IACxE,2DAA2D;IAChC,YAAY,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IACrE,8EAA8E;IACnD,YAAY,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,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