@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
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthGuard component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, effect, ElementRef, inject, Renderer2, ViewChild, } from '@angular/core';
|
|
7
|
+
import { useAuth, useRouter, useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { hasNodes, SlotWrapper } from './button.component.js';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
const _c0 = ["defaultLoading"];
|
|
11
|
+
const _c1 = ["fallbackWrap"];
|
|
12
|
+
const _c2 = ["childrenWrap"];
|
|
13
|
+
const _c3 = [[["", "slot", "loadingfallback"]], "*"];
|
|
14
|
+
const _c4 = ["[slot=loadingFallback]", "*"];
|
|
15
|
+
/**
|
|
16
|
+
* The pathname part of a login path (`/login?next=x` → `/login`).
|
|
17
|
+
*
|
|
18
|
+
* @param loginPath - The guard's `loginPath`.
|
|
19
|
+
* @returns Its pathname.
|
|
20
|
+
*/
|
|
21
|
+
const loginPathname = (loginPath) => loginPath.split(/[?#]/)[0] || '/';
|
|
22
|
+
/**
|
|
23
|
+
* Route-element guard for authenticated sections of a routing tree.
|
|
24
|
+
*
|
|
25
|
+
* While the auth status is `'loading'` it renders the `loadingFallback` slot
|
|
26
|
+
* (or the default `data-mol-id="auth-guard-loading"` tag); while
|
|
27
|
+
* `'unauthenticated'` off the login path it renders nothing and redirects to
|
|
28
|
+
* `loginPath` (state `from` carries the attempted location); otherwise it
|
|
29
|
+
* renders the projected children. The host is unwrapped by the DOM normalizer
|
|
30
|
+
* (`data-parity-unwrap`) and `display: contents` keeps it fragment-like —
|
|
31
|
+
* React's root is a fragment. On the login path itself the guard renders its
|
|
32
|
+
* children, so a guard wrapping the whole route tree does not redirect in a
|
|
33
|
+
* loop.
|
|
34
|
+
*
|
|
35
|
+
* The projected children need one stable capture point, so they live in an
|
|
36
|
+
* always-mounted wrapper the guard moves into (or out of) the host itself:
|
|
37
|
+
* React renders them bare, never inside a wrapper element, and renders
|
|
38
|
+
* nothing at all while redirecting.
|
|
39
|
+
*/
|
|
40
|
+
export class AuthGuard {
|
|
41
|
+
/**
|
|
42
|
+
* i18n key for the default loading-tag text (default `common.loading`).
|
|
43
|
+
* Ignored when a `loadingFallback` slot is projected.
|
|
44
|
+
*/
|
|
45
|
+
loadingKey;
|
|
46
|
+
/** Fallback text if the i18n key is missing (default `Loading...`). */
|
|
47
|
+
loadingDefault;
|
|
48
|
+
/** Path to redirect to when unauthenticated (default `/login`). */
|
|
49
|
+
loginPath;
|
|
50
|
+
/** Fired when `isAuthenticated` becomes true (also when true at mount). */
|
|
51
|
+
onAuthenticated;
|
|
52
|
+
/** The default loading tag. */
|
|
53
|
+
defaultLoading;
|
|
54
|
+
/** The `loadingFallback` slot capture (always mounted). */
|
|
55
|
+
fallbackWrap;
|
|
56
|
+
/** The children capture; its nodes are moved bare into the host to render. */
|
|
57
|
+
childrenWrap;
|
|
58
|
+
/** Auth state, read in the component's injection context. */
|
|
59
|
+
auth = useAuth();
|
|
60
|
+
/** Router state and actions, read in the component's injection context. */
|
|
61
|
+
router = useRouter();
|
|
62
|
+
/**
|
|
63
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
64
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
65
|
+
* does not).
|
|
66
|
+
*/
|
|
67
|
+
i18n = useTranslation();
|
|
68
|
+
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
69
|
+
host = inject(ElementRef);
|
|
70
|
+
hasFallback = false;
|
|
71
|
+
lastAuthenticated = false;
|
|
72
|
+
/** The login path the guard navigated to for the current redirect state. */
|
|
73
|
+
redirectedTo = null;
|
|
74
|
+
/** The children nodes currently adopted into the host. */
|
|
75
|
+
adopted = [];
|
|
76
|
+
/**
|
|
77
|
+
* Runs the first reconciliation after the view init (slot detection) and
|
|
78
|
+
* again whenever the auth status or the location changes — the effect
|
|
79
|
+
* tracks both signals directly, so the guard re-evaluates even though no
|
|
80
|
+
* template binding reads them.
|
|
81
|
+
*/
|
|
82
|
+
guardEffect = effect(() => {
|
|
83
|
+
this.auth.status();
|
|
84
|
+
this.router.location();
|
|
85
|
+
this.reconcile();
|
|
86
|
+
}, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "guardEffect" }] : /* istanbul ignore next */ []));
|
|
88
|
+
/**
|
|
89
|
+
* Detects the `loadingFallback` slot presence (view queries resolve only by
|
|
90
|
+
* view init).
|
|
91
|
+
*/
|
|
92
|
+
ngAfterViewInit() {
|
|
93
|
+
this.hasFallback = hasNodes(this.fallbackWrap?.nativeElement);
|
|
94
|
+
this.reconcile();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Applies React's branch for the current auth status and location, fires
|
|
98
|
+
* `onAuthenticated` on its rising edge, and redirects once per entry into
|
|
99
|
+
* the redirect state.
|
|
100
|
+
*/
|
|
101
|
+
reconcile() {
|
|
102
|
+
const status = this.auth.status();
|
|
103
|
+
const authenticated = this.auth.isAuthenticated();
|
|
104
|
+
if (this.onAuthenticated && authenticated && !this.lastAuthenticated)
|
|
105
|
+
this.onAuthenticated();
|
|
106
|
+
this.lastAuthenticated = authenticated;
|
|
107
|
+
const pathname = this.router.location().pathname;
|
|
108
|
+
const target = this.loginPath ?? '/login';
|
|
109
|
+
const redirecting = status === 'unauthenticated' && pathname !== loginPathname(target);
|
|
110
|
+
if (redirecting) {
|
|
111
|
+
if (this.redirectedTo !== target) {
|
|
112
|
+
this.redirectedTo = target;
|
|
113
|
+
this.router.navigate(target, {
|
|
114
|
+
replace: true,
|
|
115
|
+
state: { from: { ...this.router.location() } },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.redirectedTo = null;
|
|
121
|
+
}
|
|
122
|
+
const branch = status === 'loading' ? 'loading' : redirecting ? 'redirect' : 'children';
|
|
123
|
+
this.renderBranch(branch);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Shows exactly one branch's content, the way React's early returns do.
|
|
127
|
+
*
|
|
128
|
+
* @param branch - The branch to render.
|
|
129
|
+
*/
|
|
130
|
+
renderBranch(branch) {
|
|
131
|
+
const host = this.host.nativeElement;
|
|
132
|
+
const wrap = this.childrenWrap?.nativeElement;
|
|
133
|
+
if (wrap) {
|
|
134
|
+
if (branch === 'children') {
|
|
135
|
+
while (wrap.firstChild) {
|
|
136
|
+
const node = wrap.firstChild;
|
|
137
|
+
host.appendChild(node);
|
|
138
|
+
this.adopted.push(node);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
for (const node of this.adopted) {
|
|
143
|
+
if (node.parentElement === host)
|
|
144
|
+
wrap.appendChild(node);
|
|
145
|
+
}
|
|
146
|
+
this.adopted = [];
|
|
147
|
+
}
|
|
148
|
+
// The capture span itself never renders (React's children are bare).
|
|
149
|
+
this.sync.sync(this.childrenWrap?.nativeElement, false);
|
|
150
|
+
}
|
|
151
|
+
this.sync.sync(this.defaultLoading?.nativeElement, branch === 'loading' && !this.hasFallback);
|
|
152
|
+
this.sync.sync(this.fallbackWrap?.nativeElement, branch === 'loading' && this.hasFallback);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The localized default loading text.
|
|
156
|
+
* @returns The translated text.
|
|
157
|
+
*/
|
|
158
|
+
loadingText() {
|
|
159
|
+
return this.i18n.t(this.loadingKey ?? 'common.loading', {}, {
|
|
160
|
+
defaultValue: this.loadingDefault ?? 'Loading...',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
static ɵfac = function AuthGuard_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AuthGuard)(); };
|
|
164
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthGuard, selectors: [["mol-auth-guard"]], viewQuery: function AuthGuard_Query(rf, ctx) { if (rf & 1) {
|
|
165
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5);
|
|
166
|
+
} if (rf & 2) {
|
|
167
|
+
let _t;
|
|
168
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.defaultLoading = _t.first);
|
|
169
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.fallbackWrap = _t.first);
|
|
170
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childrenWrap = _t.first);
|
|
171
|
+
} }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { loadingKey: "loadingKey", loadingDefault: "loadingDefault", loginPath: "loginPath", onAuthenticated: "onAuthenticated" }, ngContentSelectors: _c4, decls: 9, vars: 1, consts: [["defaultLoading", ""], ["fallbackWrap", ""], ["childrenWrap", ""], ["data-mol-id", "auth-guard-loading"]], template: function AuthGuard_Template(rf, ctx) { if (rf & 1) {
|
|
172
|
+
i0.ɵɵprojectionDef(_c3);
|
|
173
|
+
i0.ɵɵdomElementStart(0, "div", 3, 0);
|
|
174
|
+
i0.ɵɵtext(2);
|
|
175
|
+
i0.ɵɵdomElementEnd();
|
|
176
|
+
i0.ɵɵdomElementStart(3, "span", null, 1);
|
|
177
|
+
i0.ɵɵprojection(5);
|
|
178
|
+
i0.ɵɵdomElementEnd();
|
|
179
|
+
i0.ɵɵdomElementStart(6, "span", null, 2);
|
|
180
|
+
i0.ɵɵprojection(8, 1);
|
|
181
|
+
i0.ɵɵdomElementEnd();
|
|
182
|
+
} if (rf & 2) {
|
|
183
|
+
i0.ɵɵadvance(2);
|
|
184
|
+
i0.ɵɵtextInterpolate(ctx.loadingText());
|
|
185
|
+
} }, encapsulation: 2 });
|
|
186
|
+
}
|
|
187
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGuard, [{
|
|
188
|
+
type: Component,
|
|
189
|
+
args: [{
|
|
190
|
+
selector: 'mol-auth-guard',
|
|
191
|
+
standalone: true,
|
|
192
|
+
inputs: ['loadingKey', 'loadingDefault', 'loginPath', 'onAuthenticated'],
|
|
193
|
+
host: {
|
|
194
|
+
'data-parity-unwrap': '',
|
|
195
|
+
style: 'display: contents',
|
|
196
|
+
},
|
|
197
|
+
template: `<div data-mol-id="auth-guard-loading" #defaultLoading>{{ loadingText() }}</div>
|
|
198
|
+
<span #fallbackWrap><ng-content select="[slot=loadingFallback]"></ng-content></span>
|
|
199
|
+
<span #childrenWrap><ng-content></ng-content></span>`,
|
|
200
|
+
}]
|
|
201
|
+
}], null, { defaultLoading: [{
|
|
202
|
+
type: ViewChild,
|
|
203
|
+
args: ['defaultLoading']
|
|
204
|
+
}], fallbackWrap: [{
|
|
205
|
+
type: ViewChild,
|
|
206
|
+
args: ['fallbackWrap']
|
|
207
|
+
}], childrenWrap: [{
|
|
208
|
+
type: ViewChild,
|
|
209
|
+
args: ['childrenWrap']
|
|
210
|
+
}] }); })();
|
|
211
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AuthGuard, { className: "AuthGuard", filePath: "components/auth-guard.component.ts", lineNumber: 59 }); })();
|
|
212
|
+
//# sourceMappingURL=auth-guard.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-guard.component.js","sourceRoot":"","sources":["../../src/components/auth-guard.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EACT,MAAM,EACN,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE1E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;;;;;;;AAE7D;;;;;GAKG;AACH,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAA;AAEtF;;;;;;;;;;;;;;;;;GAiBG;AAaH,MAAM,OAAO,SAAS;IACpB;;;OAGG;IACH,UAAU,CAAS;IACnB,uEAAuE;IACvE,cAAc,CAAS;IACvB,mEAAmE;IACnE,SAAS,CAAS;IAClB,2EAA2E;IAC3E,eAAe,CAAa;IAE5B,+BAA+B;IACF,cAAc,CAA6B;IACxE,2DAA2D;IAChC,YAAY,CAA8B;IACrE,8EAA8E;IACnD,YAAY,CAA8B;IAErE,6DAA6D;IACpD,IAAI,GAAG,OAAO,EAAE,CAAA;IACzB,2EAA2E;IAClE,MAAM,GAAG,SAAS,EAAE,CAAA;IAE7B;;;;OAIG;IACc,IAAI,GAAG,cAAc,EAAE,CAAA;IAEvB,IAAI,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IAC7D,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;IAClC,WAAW,GAAG,KAAK,CAAA;IACnB,iBAAiB,GAAG,KAAK,CAAA;IACjC,4EAA4E;IACpE,YAAY,GAAkB,IAAI,CAAA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AAC,cAAc,EAAE,aAAa,EAAE,MAAM,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC7F,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,CAAA;IAC5F,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAChB,IAAI,CAAC,UAAU,IAAI,gBAAgB,EACnC,EAAE,EACF;YACE,YAAY,EAAE,IAAI,CAAC,cAAc,IAAI,YAAY;SAClD,CACF,CAAA;IACH,CAAC;mGApIU,SAAS;6DAAT,SAAS;;;;;;;;;YAJT,oCAAsD;YAAA,YAAmB;YAAA,oBAAM;YACxF,wCAAoB;YAAA,kBAAyD;YAAA,oBAAO;YACpF,wCAAoB;YAAA,qBAAyB;YAAA,oBAAO;;YAFW,eAAmB;YAAnB,uCAAmB;;;iFAIzE,SAAS;cAZrB,SAAS;eAAC;gBACT,QAAQ,EAAE,gBAAgB;gBAC1B,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,CAAC;gBACxE,IAAI,EAAE;oBACJ,oBAAoB,EAAE,EAAE;oBACxB,KAAK,EAAE,mBAAmB;iBAC3B;gBACD,QAAQ,EAAE;;yDAE6C;aACxD;;kBAeE,SAAS;mBAAC,gBAAgB;;kBAE1B,SAAS;mBAAC,cAAc;;kBAExB,SAAS;mBAAC,cAAc;;kFAlBd,SAAS"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avatar component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type AfterViewChecked, ElementRef } from '@angular/core';
|
|
7
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
8
|
+
import { type ResolvedIcon } from '../utilities/render-icon.js';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
/**
|
|
11
|
+
* Avatar component.
|
|
12
|
+
*
|
|
13
|
+
* Renders the image while it loads; an image error (or no `src`) swaps to the
|
|
14
|
+
* fallback: projected `[slot=fallback]` content, the name's initials, or a
|
|
15
|
+
* user glyph. The image/fallback swap is a signal-driven `@if` (an error
|
|
16
|
+
* re-renders); the three fallback variants are always-mounted capture points
|
|
17
|
+
* detached from the DOM per React's ternary, since projected-content presence
|
|
18
|
+
* is only knowable at view init ({@link SlotWrapper}).
|
|
19
|
+
*/
|
|
20
|
+
export declare class Avatar implements AfterViewChecked {
|
|
21
|
+
/** Image source. */
|
|
22
|
+
src?: string;
|
|
23
|
+
/** Image alt text. */
|
|
24
|
+
alt?: string;
|
|
25
|
+
/** Display name (drives the initials fallback and default alt). */
|
|
26
|
+
name?: string;
|
|
27
|
+
/** Avatar size preset or an exact pixel size. */
|
|
28
|
+
size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number;
|
|
29
|
+
/** Whether the avatar is fully rounded (default true). */
|
|
30
|
+
rounded: boolean;
|
|
31
|
+
/** Extra classes. */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Inline style object (React camelCase). */
|
|
34
|
+
style?: Record<string, unknown>;
|
|
35
|
+
/** `data-testid`. */
|
|
36
|
+
testId?: string;
|
|
37
|
+
/** Set when the image fails to load. */
|
|
38
|
+
readonly imageError: import("@angular/core").WritableSignal<boolean>;
|
|
39
|
+
/** The fallback container (React renders it only on the fallback branch). */
|
|
40
|
+
fallbackEl?: ElementRef<HTMLDivElement>;
|
|
41
|
+
/** The initials span (detached unless the fallback branch picks it). */
|
|
42
|
+
initialsEl?: ElementRef<HTMLSpanElement>;
|
|
43
|
+
/** The user glyph (detached unless the fallback branch picks it). */
|
|
44
|
+
userGlyph?: ElementRef<SVGSVGElement>;
|
|
45
|
+
/**
|
|
46
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
47
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
48
|
+
* does not).
|
|
49
|
+
*/
|
|
50
|
+
private readonly i18n;
|
|
51
|
+
private readonly sync;
|
|
52
|
+
/**
|
|
53
|
+
* The current class map.
|
|
54
|
+
* @returns The UIClassMap.
|
|
55
|
+
*/
|
|
56
|
+
cm(): UIClassMap;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the fallback branch renders.
|
|
59
|
+
* @returns True without a src or after an image error.
|
|
60
|
+
*/
|
|
61
|
+
showFallback(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The image alt text (name or the localized default).
|
|
64
|
+
* @returns The alt text.
|
|
65
|
+
*/
|
|
66
|
+
altText(): string;
|
|
67
|
+
/**
|
|
68
|
+
* The initials for the given name.
|
|
69
|
+
* @returns Up to two uppercase characters.
|
|
70
|
+
*/
|
|
71
|
+
initials(): string;
|
|
72
|
+
/**
|
|
73
|
+
* The fallback user glyph.
|
|
74
|
+
* @returns The resolved icon.
|
|
75
|
+
*/
|
|
76
|
+
userIcon(): ResolvedIcon;
|
|
77
|
+
/**
|
|
78
|
+
* Computes the avatar class list.
|
|
79
|
+
* @returns The class string.
|
|
80
|
+
*/
|
|
81
|
+
classes(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Serializes the merged inline style (an exact pixel size inline).
|
|
84
|
+
* @returns The style attribute text.
|
|
85
|
+
*/
|
|
86
|
+
hostStyle(): string | null;
|
|
87
|
+
/**
|
|
88
|
+
* Applies React's fallback ternary (`fallback ? fallback : name ? initials
|
|
89
|
+
* : glyph`) after view queries have resolved for this pass. Projected
|
|
90
|
+
* fallback nodes are exactly the container's children that are not the two
|
|
91
|
+
* always-mounted template children.
|
|
92
|
+
*/
|
|
93
|
+
ngAfterViewChecked(): void;
|
|
94
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Avatar, never>;
|
|
95
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Avatar, "div[mol-avatar]", never, { "src": { "alias": "src"; "required": false; }; "alt": { "alias": "alt"; "required": false; }; "name": { "alias": "name"; "required": false; }; "size": { "alias": "size"; "required": false; }; "rounded": { "alias": "rounded"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; }, {}, never, ["[slot=fallback]"], true, never>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=avatar.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.component.d.ts","sourceRoot":"","sources":["../../src/components/avatar.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,gBAAgB,EAErB,UAAU,EAKX,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,EAAc,KAAK,YAAY,EAAe,MAAM,6BAA6B,CAAA;;AAIxF;;;;;;;;;GASG;AACH,qBAyBa,MAAO,YAAW,gBAAgB;IAC7C,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,sBAAsB;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iDAAiD;IACjD,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAO;IACtD,0DAA0D;IAC1D,OAAO,UAAO;IACd,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,qBAAqB;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,wCAAwC;IACxC,QAAQ,CAAC,UAAU,kDAAgB;IAEnC,6EAA6E;IACpD,UAAU,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAA;IAChE,wEAAwE;IAC/C,UAAU,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IACjE,qEAAqE;IACvB,SAAS,CAAC,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IAEnF;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IAExC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyD;IAE9E;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,YAAY,IAAI,OAAO;IAIvB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAMjB;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,QAAQ,IAAI,YAAY;IAIxB;;;OAGG;IACH,OAAO,IAAI,MAAM;IASjB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAM1B;;;;;OAKG;IACH,kBAAkB,IAAI,IAAI;yCA5Gf,MAAM;2CAAN,MAAM;CAwHlB"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avatar component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Component, ElementRef, inject, Renderer2, signal, ViewChild, } from '@angular/core';
|
|
7
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
8
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { getInitials } from '../utilities/initials.js';
|
|
10
|
+
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
11
|
+
import { styleText } from '../utilities/style.js';
|
|
12
|
+
import { SlotWrapper } from './button.component.js';
|
|
13
|
+
import * as i0 from "@angular/core";
|
|
14
|
+
const _c0 = ["fallbackEl"];
|
|
15
|
+
const _c1 = ["initialsEl"];
|
|
16
|
+
const _c2 = ["userGlyph"];
|
|
17
|
+
const _c3 = [[["", "slot", "fallback"]]];
|
|
18
|
+
const _c4 = ["[slot=fallback]"];
|
|
19
|
+
function Avatar_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
20
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
21
|
+
i0.ɵɵelementStart(0, "img", 5);
|
|
22
|
+
i0.ɵɵlistener("error", function Avatar_Conditional_0_Template_img_error_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.imageError.set(true)); });
|
|
23
|
+
i0.ɵɵelementEnd();
|
|
24
|
+
} if (rf & 2) {
|
|
25
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
26
|
+
i0.ɵɵclassMap(ctx_r1.cm().avatarImage);
|
|
27
|
+
i0.ɵɵproperty("src", ctx_r1.src);
|
|
28
|
+
i0.ɵɵattribute("alt", ctx_r1.altText());
|
|
29
|
+
} }
|
|
30
|
+
function Avatar_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
31
|
+
i0.ɵɵelementStart(0, "div", null, 0);
|
|
32
|
+
i0.ɵɵprojection(2);
|
|
33
|
+
i0.ɵɵelementStart(3, "span", null, 1);
|
|
34
|
+
i0.ɵɵtext(5);
|
|
35
|
+
i0.ɵɵelementEnd();
|
|
36
|
+
i0.ɵɵnamespaceSVG();
|
|
37
|
+
i0.ɵɵelement(6, "svg", 6, 2);
|
|
38
|
+
i0.ɵɵelementEnd();
|
|
39
|
+
} if (rf & 2) {
|
|
40
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
41
|
+
i0.ɵɵclassMap(ctx_r1.cm().avatarFallback);
|
|
42
|
+
i0.ɵɵadvance(3);
|
|
43
|
+
i0.ɵɵclassMap(ctx_r1.cm().avatarInitials);
|
|
44
|
+
i0.ɵɵadvance(2);
|
|
45
|
+
i0.ɵɵtextInterpolate(ctx_r1.initials());
|
|
46
|
+
i0.ɵɵadvance();
|
|
47
|
+
i0.ɵɵproperty("data", ctx_r1.userIcon());
|
|
48
|
+
} }
|
|
49
|
+
/**
|
|
50
|
+
* Avatar component.
|
|
51
|
+
*
|
|
52
|
+
* Renders the image while it loads; an image error (or no `src`) swaps to the
|
|
53
|
+
* fallback: projected `[slot=fallback]` content, the name's initials, or a
|
|
54
|
+
* user glyph. The image/fallback swap is a signal-driven `@if` (an error
|
|
55
|
+
* re-renders); the three fallback variants are always-mounted capture points
|
|
56
|
+
* detached from the DOM per React's ternary, since projected-content presence
|
|
57
|
+
* is only knowable at view init ({@link SlotWrapper}).
|
|
58
|
+
*/
|
|
59
|
+
export class Avatar {
|
|
60
|
+
/** Image source. */
|
|
61
|
+
src;
|
|
62
|
+
/** Image alt text. */
|
|
63
|
+
alt;
|
|
64
|
+
/** Display name (drives the initials fallback and default alt). */
|
|
65
|
+
name;
|
|
66
|
+
/** Avatar size preset or an exact pixel size. */
|
|
67
|
+
size = 'md';
|
|
68
|
+
/** Whether the avatar is fully rounded (default true). */
|
|
69
|
+
rounded = true;
|
|
70
|
+
/** Extra classes. */
|
|
71
|
+
className;
|
|
72
|
+
/** Inline style object (React camelCase). */
|
|
73
|
+
style;
|
|
74
|
+
/** `data-testid`. */
|
|
75
|
+
testId;
|
|
76
|
+
/** Set when the image fails to load. */
|
|
77
|
+
imageError = signal(false, /* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [{ debugName: "imageError" }] : /* istanbul ignore next */ []));
|
|
79
|
+
/** The fallback container (React renders it only on the fallback branch). */
|
|
80
|
+
fallbackEl;
|
|
81
|
+
/** The initials span (detached unless the fallback branch picks it). */
|
|
82
|
+
initialsEl;
|
|
83
|
+
/** The user glyph (detached unless the fallback branch picks it). */
|
|
84
|
+
userGlyph;
|
|
85
|
+
/**
|
|
86
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
87
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
88
|
+
* does not).
|
|
89
|
+
*/
|
|
90
|
+
i18n = useTranslation();
|
|
91
|
+
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
92
|
+
/**
|
|
93
|
+
* The current class map.
|
|
94
|
+
* @returns The UIClassMap.
|
|
95
|
+
*/
|
|
96
|
+
cm() {
|
|
97
|
+
return getClassMap();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Whether the fallback branch renders.
|
|
101
|
+
* @returns True without a src or after an image error.
|
|
102
|
+
*/
|
|
103
|
+
showFallback() {
|
|
104
|
+
return !this.src || this.imageError();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The image alt text (name or the localized default).
|
|
108
|
+
* @returns The alt text.
|
|
109
|
+
*/
|
|
110
|
+
altText() {
|
|
111
|
+
return (this.alt || this.name || this.i18n.t('ui.avatar.alt', undefined, { defaultValue: 'Avatar' }));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The initials for the given name.
|
|
115
|
+
* @returns Up to two uppercase characters.
|
|
116
|
+
*/
|
|
117
|
+
initials() {
|
|
118
|
+
return getInitials(this.name);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The fallback user glyph.
|
|
122
|
+
* @returns The resolved icon.
|
|
123
|
+
*/
|
|
124
|
+
userIcon() {
|
|
125
|
+
return resolveIcon('user', this.cm().avatarFallbackIcon);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Computes the avatar class list.
|
|
129
|
+
* @returns The class string.
|
|
130
|
+
*/
|
|
131
|
+
classes() {
|
|
132
|
+
const avatarSize = typeof this.size === 'number' ? undefined : this.size;
|
|
133
|
+
return this.cm().cn(this.cm().avatar({ size: avatarSize }), !this.rounded && this.cm().avatarSquare, this.className);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Serializes the merged inline style (an exact pixel size inline).
|
|
137
|
+
* @returns The style attribute text.
|
|
138
|
+
*/
|
|
139
|
+
hostStyle() {
|
|
140
|
+
const customSize = typeof this.size === 'number' ? { width: this.size, height: this.size } : undefined;
|
|
141
|
+
return styleText({ ...this.style, ...customSize });
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Applies React's fallback ternary (`fallback ? fallback : name ? initials
|
|
145
|
+
* : glyph`) after view queries have resolved for this pass. Projected
|
|
146
|
+
* fallback nodes are exactly the container's children that are not the two
|
|
147
|
+
* always-mounted template children.
|
|
148
|
+
*/
|
|
149
|
+
ngAfterViewChecked() {
|
|
150
|
+
const fallbackHost = this.fallbackEl?.nativeElement;
|
|
151
|
+
if (!fallbackHost)
|
|
152
|
+
return;
|
|
153
|
+
const projected = Array.from(fallbackHost.childNodes).some((node) => node !== this.initialsEl?.nativeElement &&
|
|
154
|
+
node !== this.userGlyph?.nativeElement &&
|
|
155
|
+
(node.nodeType === 1 || (node.nodeType === 3 && (node.textContent ?? '').trim())));
|
|
156
|
+
this.sync.sync(this.initialsEl?.nativeElement, !projected && !!this.name, fallbackHost);
|
|
157
|
+
this.sync.sync(this.userGlyph?.nativeElement, !projected && !this.name, fallbackHost);
|
|
158
|
+
}
|
|
159
|
+
static ɵfac = function Avatar_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Avatar)(); };
|
|
160
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Avatar, selectors: [["div", "mol-avatar", ""]], viewQuery: function Avatar_Query(rf, ctx) { if (rf & 1) {
|
|
161
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5, ElementRef);
|
|
162
|
+
} if (rf & 2) {
|
|
163
|
+
let _t;
|
|
164
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.fallbackEl = _t.first);
|
|
165
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.initialsEl = _t.first);
|
|
166
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.userGlyph = _t.first);
|
|
167
|
+
} }, hostVars: 5, hostBindings: function Avatar_HostBindings(rf, ctx) { if (rf & 2) {
|
|
168
|
+
i0.ɵɵattribute("data-testid", ctx.testId);
|
|
169
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
170
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
171
|
+
} }, inputs: { src: "src", alt: "alt", name: "name", size: "size", rounded: "rounded", className: "className", style: "style", testId: "testId" }, ngContentSelectors: _c4, decls: 2, vars: 1, consts: [["fallbackEl", ""], ["initialsEl", ""], ["userGlyph", ""], [3, "src", "class"], [3, "class"], [3, "error", "src"], ["mol-icon", "", 3, "data"]], template: function Avatar_Template(rf, ctx) { if (rf & 1) {
|
|
172
|
+
i0.ɵɵprojectionDef(_c3);
|
|
173
|
+
i0.ɵɵconditionalCreate(0, Avatar_Conditional_0_Template, 1, 4, "img", 3)(1, Avatar_Conditional_1_Template, 8, 6, "div", 4);
|
|
174
|
+
} if (rf & 2) {
|
|
175
|
+
i0.ɵɵconditional(!ctx.showFallback() ? 0 : 1);
|
|
176
|
+
} }, dependencies: [MolIconSvg], encapsulation: 2 });
|
|
177
|
+
}
|
|
178
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Avatar, [{
|
|
179
|
+
type: Component,
|
|
180
|
+
args: [{
|
|
181
|
+
selector: 'div[mol-avatar]',
|
|
182
|
+
standalone: true,
|
|
183
|
+
imports: [MolIconSvg],
|
|
184
|
+
inputs: ['src', 'alt', 'name', 'size', 'rounded', 'className', 'style', 'testId'],
|
|
185
|
+
host: {
|
|
186
|
+
'[class]': 'classes()',
|
|
187
|
+
'[style]': 'hostStyle()',
|
|
188
|
+
'[attr.data-testid]': 'testId',
|
|
189
|
+
},
|
|
190
|
+
template: `@if (!showFallback()) {
|
|
191
|
+
<img
|
|
192
|
+
[src]="src"
|
|
193
|
+
[attr.alt]="altText()"
|
|
194
|
+
[class]="cm().avatarImage"
|
|
195
|
+
(error)="imageError.set(true)"
|
|
196
|
+
/>
|
|
197
|
+
} @else {
|
|
198
|
+
<div [class]="cm().avatarFallback" #fallbackEl>
|
|
199
|
+
<ng-content select="[slot=fallback]"></ng-content>
|
|
200
|
+
<span [class]="cm().avatarInitials" #initialsEl>{{ initials() }}</span>
|
|
201
|
+
<svg mol-icon [data]="userIcon()" #userGlyph />
|
|
202
|
+
</div>
|
|
203
|
+
}`,
|
|
204
|
+
}]
|
|
205
|
+
}], null, { fallbackEl: [{
|
|
206
|
+
type: ViewChild,
|
|
207
|
+
args: ['fallbackEl']
|
|
208
|
+
}], initialsEl: [{
|
|
209
|
+
type: ViewChild,
|
|
210
|
+
args: ['initialsEl']
|
|
211
|
+
}], userGlyph: [{
|
|
212
|
+
type: ViewChild,
|
|
213
|
+
args: ['userGlyph', { read: ElementRef }]
|
|
214
|
+
}] }); })();
|
|
215
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Avatar, { className: "Avatar", filePath: "components/avatar.component.ts", lineNumber: 61 }); })();
|
|
216
|
+
//# sourceMappingURL=avatar.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.component.js","sourceRoot":"","sources":["../../src/components/avatar.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EACT,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAqB,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;;;;;;;;;IAuB7C,8BAKE;IADA,uKAAS,sBAAe,IAAI,CAAC,KAAC;IAJhC,iBAKE;;;IAFA,sCAA0B;IAF1B,gCAAW;;;;IAMb,oCAA+C;IAC7C,kBAAkD;IAClD,qCAA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{ ColorVariant, Size } from '@molecule/app-ui';
|
|
1
|
+
import type { ColorVariant, Size, UIClassMap } from '@molecule/app-ui';
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Badge component.
|
|
5
|
+
*
|
|
6
|
+
* The host element is the `<span>` React renders (`span[mol-badge]`); the
|
|
7
|
+
* color variant maps to `badge({ variant })` exactly as React's `Badge`.
|
|
5
8
|
*/
|
|
6
|
-
export declare class
|
|
9
|
+
export declare class Badge {
|
|
10
|
+
/** Named color variant (`primary`, `success`, …). */
|
|
7
11
|
color: ColorVariant;
|
|
12
|
+
/** Visual style (kept for React prop parity; the class map keys off `color`). */
|
|
8
13
|
variant: 'solid' | 'outline' | 'subtle';
|
|
14
|
+
/** Badge size. */
|
|
9
15
|
size?: Size;
|
|
16
|
+
/** Whether the badge is fully rounded (default) or square. */
|
|
10
17
|
rounded: boolean;
|
|
18
|
+
/** Extra classes joined onto the badge classes. */
|
|
11
19
|
className?: string;
|
|
12
|
-
style
|
|
20
|
+
/** Inline style object (React camelCase). */
|
|
21
|
+
style?: Record<string, unknown>;
|
|
22
|
+
/** `data-testid` for the badge. */
|
|
13
23
|
testId?: string;
|
|
14
24
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @returns The UIClassMap
|
|
25
|
+
* The current class map.
|
|
26
|
+
* @returns The UIClassMap.
|
|
17
27
|
*/
|
|
18
|
-
|
|
28
|
+
cm(): UIClassMap;
|
|
19
29
|
/**
|
|
20
|
-
* Computes the
|
|
21
|
-
* @returns The
|
|
30
|
+
* Computes the badge class list.
|
|
31
|
+
* @returns The class string.
|
|
22
32
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
classes(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Serializes the inline style.
|
|
36
|
+
* @returns The style attribute text.
|
|
37
|
+
*/
|
|
38
|
+
hostStyle(): string | null;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Badge, never>;
|
|
40
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Badge, "span[mol-badge]", never, { "color": { "alias": "color"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "size": { "alias": "size"; "required": false; }; "rounded": { "alias": "rounded"; "required": false; }; "className": { "alias": "className"; "required": false; }; "style": { "alias": "style"; "required": false; }; "testId": { "alias": "testId"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
26
41
|
}
|
|
27
42
|
//# sourceMappingURL=badge.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.component.d.ts","sourceRoot":"","sources":["../../src/components/badge.component.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"badge.component.d.ts","sourceRoot":"","sources":["../../src/components/badge.component.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAKtE;;;;;GAKG;AACH,qBAWa,KAAK;IAChB,qDAAqD;IACrD,KAAK,EAAE,YAAY,CAAY;IAC/B,iFAAiF;IACjF,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAU;IACjD,kBAAkB;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,8DAA8D;IAC9D,OAAO,UAAO;IACd,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;OAGG;IACH,OAAO,IAAI,MAAM;IAQjB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;yCAxCf,KAAK;2CAAL,KAAK;CA2CjB"}
|