@molecule/app-ui-angular 1.0.6 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11710 -1117
- 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 +97 -29
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +222 -117
- 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/controlled-checked.directive.d.ts +45 -0
- package/dist/components/controlled-checked.directive.d.ts.map +1 -0
- package/dist/components/controlled-checked.directive.js +74 -0
- package/dist/components/controlled-checked.directive.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 +157 -134
- 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 +168 -95
- 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 +6 -4
|
@@ -0,0 +1,1144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResponsiveAppShell family (React parity): the shell root plus its TopBar,
|
|
3
|
+
* Sidebar, Drawer and Content sub-components.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { Component, effect, ElementRef, inject, Renderer2, signal, ViewChild, } from '@angular/core';
|
|
8
|
+
import { useRouter, useTranslation } from '@molecule/app-angular';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { useIsDesktop } from '../hooks/use-is-desktop.js';
|
|
11
|
+
import { findDomContext, provideDomContext, removeDomContext } from '../utilities/dom-context.js';
|
|
12
|
+
import { createScrollLock, getFocusableElements } from '../utilities/focus.js';
|
|
13
|
+
import { nextInstanceId } from '../utilities/ids.js';
|
|
14
|
+
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
15
|
+
import { styleText } from '../utilities/style.js';
|
|
16
|
+
import { hasNodes, SlotWrapper } from './button.component.js';
|
|
17
|
+
import * as i0 from "@angular/core";
|
|
18
|
+
const _c0 = ["*"];
|
|
19
|
+
const _c1 = ["brandSlot"];
|
|
20
|
+
const _c2 = ["actionsSlot"];
|
|
21
|
+
const _c3 = [[["", "slot", "brand"]], [["", "slot", "actions"]]];
|
|
22
|
+
const _c4 = ["[slot=brand]", "[slot=actions]"];
|
|
23
|
+
const _c5 = () => ({ align: "center", gap: "sm" });
|
|
24
|
+
function ResponsiveAppShellTopBar_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
25
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
26
|
+
i0.ɵɵelementStart(0, "button", 3);
|
|
27
|
+
i0.ɵɵlistener("click", function ResponsiveAppShellTopBar_Conditional_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.shell().openDrawer()); });
|
|
28
|
+
i0.ɵɵnamespaceSVG();
|
|
29
|
+
i0.ɵɵelement(1, "svg", 4);
|
|
30
|
+
i0.ɵɵelementEnd();
|
|
31
|
+
} if (rf & 2) {
|
|
32
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
33
|
+
i0.ɵɵstyleMap(ctx_r1.triggerStyle());
|
|
34
|
+
i0.ɵɵclassMap(ctx_r1.triggerClasses());
|
|
35
|
+
i0.ɵɵattribute("aria-label", ctx_r1.triggerLabel())("aria-expanded", ctx_r1.shell().drawerOpen ? "true" : "false")("aria-controls", ctx_r1.shell().drawerId);
|
|
36
|
+
i0.ɵɵadvance();
|
|
37
|
+
i0.ɵɵproperty("data", ctx_r1.menuIcon());
|
|
38
|
+
} }
|
|
39
|
+
const _c6 = ["footerSlot"];
|
|
40
|
+
const _c7 = ["*", [["", "slot", "footer"]]];
|
|
41
|
+
const _c8 = ["*", "[slot=footer]"];
|
|
42
|
+
const _c9 = () => ({ align: "center", justify: "between", gap: "sm" });
|
|
43
|
+
const _c10 = ["overlay"];
|
|
44
|
+
const _c11 = ["wrapper"];
|
|
45
|
+
const _c12 = ["panel"];
|
|
46
|
+
const _c13 = ["headerRow"];
|
|
47
|
+
const _c14 = ["headerSlot"];
|
|
48
|
+
const _c15 = [[["", "slot", "header"]], "*", [["", "slot", "footer"]]];
|
|
49
|
+
const _c16 = ["[slot=header]", "*", "[slot=footer]"];
|
|
50
|
+
const _c17 = () => ({ direction: "col", gap: "sm" });
|
|
51
|
+
function ResponsiveAppShellDrawer_Conditional_11_Template(rf, ctx) { if (rf & 1) {
|
|
52
|
+
i0.ɵɵelement(0, "span", 6);
|
|
53
|
+
} }
|
|
54
|
+
function ResponsiveAppShellDrawer_Conditional_12_Template(rf, ctx) { if (rf & 1) {
|
|
55
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
56
|
+
i0.ɵɵelementStart(0, "button", 10);
|
|
57
|
+
i0.ɵɵlistener("click", function ResponsiveAppShellDrawer_Conditional_12_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.shell().closeDrawer()); });
|
|
58
|
+
i0.ɵɵnamespaceSVG();
|
|
59
|
+
i0.ɵɵelement(1, "svg", 11);
|
|
60
|
+
i0.ɵɵelementEnd();
|
|
61
|
+
} if (rf & 2) {
|
|
62
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
63
|
+
i0.ɵɵclassMap(ctx_r1.closeClasses());
|
|
64
|
+
i0.ɵɵattribute("aria-label", ctx_r1.closeLabel())("data-mol-id", ctx_r1.closeDataMolId);
|
|
65
|
+
i0.ɵɵadvance();
|
|
66
|
+
i0.ɵɵproperty("data", ctx_r1.closeIcon());
|
|
67
|
+
} }
|
|
68
|
+
/** Pixel widths for the sidebar presets. */
|
|
69
|
+
const SIDEBAR_WIDTH_PX = { sm: 208, md: 240, lg: 256 };
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the sidebar/drawer pixel width.
|
|
72
|
+
* @param width - The preset or an exact pixel number.
|
|
73
|
+
* @returns The width in pixels (md by default).
|
|
74
|
+
*/
|
|
75
|
+
function resolveWidthPx(width) {
|
|
76
|
+
if (typeof width === 'number')
|
|
77
|
+
return width;
|
|
78
|
+
if (width)
|
|
79
|
+
return SIDEBAR_WIDTH_PX[width];
|
|
80
|
+
return SIDEBAR_WIDTH_PX.md;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Root of the responsive app shell: owns the breakpoint and drawer state,
|
|
84
|
+
* closes the drawer on navigation and on desktop-crossing resizes, and
|
|
85
|
+
* provides everything to the sub-components through the DOM-ancestor
|
|
86
|
+
* context (React's context provider renders no DOM).
|
|
87
|
+
*/
|
|
88
|
+
export class ResponsiveAppShell {
|
|
89
|
+
/** Sidebar (and drawer) width: `sm`/`md`/`lg` or an exact pixel number. */
|
|
90
|
+
sidebarWidth;
|
|
91
|
+
/** Extra classes on the root flex container. */
|
|
92
|
+
className;
|
|
93
|
+
/** `data-mol-id` for the root (default `shell-root`). */
|
|
94
|
+
dataMolId = 'shell-root';
|
|
95
|
+
/** Whether the viewport is at the desktop breakpoint. */
|
|
96
|
+
isDesktop = useIsDesktop();
|
|
97
|
+
/** Whether the mobile drawer is open. */
|
|
98
|
+
drawerOpen = signal(false, /* @ts-ignore */
|
|
99
|
+
...(ngDevMode ? [{ debugName: "drawerOpen" }] : /* istanbul ignore next */ []));
|
|
100
|
+
/** Whether a Drawer sub-component is composed. */
|
|
101
|
+
hasDrawer = signal(false, /* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [{ debugName: "hasDrawer" }] : /* istanbul ignore next */ []));
|
|
103
|
+
/** The drawer panel's DOM id. */
|
|
104
|
+
drawerId = nextInstanceId();
|
|
105
|
+
/** Router state: navigation closes the drawer. */
|
|
106
|
+
router = useRouter();
|
|
107
|
+
host = inject(ElementRef);
|
|
108
|
+
lastRoute = null;
|
|
109
|
+
routeEffect = effect(() => {
|
|
110
|
+
const location = this.router.location();
|
|
111
|
+
const key = `${location.pathname}${location.search}${location.hash ?? ''}`;
|
|
112
|
+
if (this.lastRoute === key)
|
|
113
|
+
return;
|
|
114
|
+
this.lastRoute = key;
|
|
115
|
+
// React's effect runs on mount too; closing a closed drawer is a no-op.
|
|
116
|
+
this.drawerOpen.set(false);
|
|
117
|
+
}, /* @ts-ignore */
|
|
118
|
+
...(ngDevMode ? [{ debugName: "routeEffect" }] : /* istanbul ignore next */ []));
|
|
119
|
+
desktopEffect = effect(() => {
|
|
120
|
+
if (this.isDesktop())
|
|
121
|
+
this.drawerOpen.set(false);
|
|
122
|
+
}, /* @ts-ignore */
|
|
123
|
+
...(ngDevMode ? [{ debugName: "desktopEffect" }] : /* istanbul ignore next */ []));
|
|
124
|
+
/** Registers the shell context on the host before any projected child resolves it. */
|
|
125
|
+
constructor() {
|
|
126
|
+
provideDomContext(this.host.nativeElement, new ShellContextValueImpl(this));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The current class map.
|
|
130
|
+
* @returns The UIClassMap.
|
|
131
|
+
*/
|
|
132
|
+
cm() {
|
|
133
|
+
return getClassMap();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The root class list.
|
|
137
|
+
* @returns The class string.
|
|
138
|
+
*/
|
|
139
|
+
classes() {
|
|
140
|
+
return this.cm().cn(this.cm().flex({}), this.cm().page, this.cm().minH('screen'), this.className);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The root's inline style (row on desktop, column below the breakpoint).
|
|
144
|
+
* @returns The style attribute text.
|
|
145
|
+
*/
|
|
146
|
+
rootStyle() {
|
|
147
|
+
return styleText({ flexDirection: this.isDesktop() ? 'row' : 'column' });
|
|
148
|
+
}
|
|
149
|
+
/** Keeps a plain-field drawer width change in sync with the sub-components. */
|
|
150
|
+
ngDoCheck() {
|
|
151
|
+
// Nothing to reconcile: every value is read through the context getters.
|
|
152
|
+
}
|
|
153
|
+
/** Removes the context registration (unmount). */
|
|
154
|
+
ngOnDestroy() {
|
|
155
|
+
removeDomContext(this.host.nativeElement);
|
|
156
|
+
}
|
|
157
|
+
static ɵfac = function ResponsiveAppShell_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ResponsiveAppShell)(); };
|
|
158
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResponsiveAppShell, selectors: [["div", "mol-responsive-app-shell", ""]], hostVars: 5, hostBindings: function ResponsiveAppShell_HostBindings(rf, ctx) { if (rf & 2) {
|
|
159
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId);
|
|
160
|
+
i0.ɵɵstyleMap(ctx.rootStyle());
|
|
161
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
162
|
+
} }, inputs: { sidebarWidth: "sidebarWidth", className: "className", dataMolId: "dataMolId" }, ngContentSelectors: _c0, decls: 1, vars: 0, template: function ResponsiveAppShell_Template(rf, ctx) { if (rf & 1) {
|
|
163
|
+
i0.ɵɵprojectionDef();
|
|
164
|
+
i0.ɵɵprojection(0);
|
|
165
|
+
} }, encapsulation: 2 });
|
|
166
|
+
}
|
|
167
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResponsiveAppShell, [{
|
|
168
|
+
type: Component,
|
|
169
|
+
args: [{
|
|
170
|
+
selector: 'div[mol-responsive-app-shell]',
|
|
171
|
+
standalone: true,
|
|
172
|
+
inputs: ['sidebarWidth', 'className', 'dataMolId'],
|
|
173
|
+
host: {
|
|
174
|
+
'[class]': 'classes()',
|
|
175
|
+
'[style]': 'rootStyle()',
|
|
176
|
+
'[attr.data-mol-id]': 'dataMolId',
|
|
177
|
+
},
|
|
178
|
+
template: `<ng-content></ng-content>`,
|
|
179
|
+
}]
|
|
180
|
+
}], () => [], null); })();
|
|
181
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResponsiveAppShell, { className: "ResponsiveAppShell", filePath: "components/responsive-app-shell.component.ts", lineNumber: 91 }); })();
|
|
182
|
+
/** The shell context a `ResponsiveAppShell` root registers. */
|
|
183
|
+
class ShellContextValueImpl {
|
|
184
|
+
root;
|
|
185
|
+
/**
|
|
186
|
+
* Creates the context for a shell root.
|
|
187
|
+
*
|
|
188
|
+
* @param root - The owning shell root.
|
|
189
|
+
*/
|
|
190
|
+
constructor(root) {
|
|
191
|
+
this.root = root;
|
|
192
|
+
}
|
|
193
|
+
/** Whether the desktop shell is mounted. */
|
|
194
|
+
get isDesktop() {
|
|
195
|
+
return this.root.isDesktop();
|
|
196
|
+
}
|
|
197
|
+
/** The resolved sidebar/drawer width in pixels. */
|
|
198
|
+
get sidebarWidthPx() {
|
|
199
|
+
return resolveWidthPx(this.root.sidebarWidth);
|
|
200
|
+
}
|
|
201
|
+
/** Whether the mobile drawer is open. */
|
|
202
|
+
get drawerOpen() {
|
|
203
|
+
return this.root.drawerOpen();
|
|
204
|
+
}
|
|
205
|
+
/** Opens the drawer. */
|
|
206
|
+
openDrawer() {
|
|
207
|
+
this.root.drawerOpen.set(true);
|
|
208
|
+
}
|
|
209
|
+
/** Closes the drawer. */
|
|
210
|
+
closeDrawer() {
|
|
211
|
+
this.root.drawerOpen.set(false);
|
|
212
|
+
}
|
|
213
|
+
/** The drawer panel's DOM id. */
|
|
214
|
+
get drawerId() {
|
|
215
|
+
return this.root.drawerId;
|
|
216
|
+
}
|
|
217
|
+
/** Whether a Drawer sub-component is composed. */
|
|
218
|
+
get hasDrawer() {
|
|
219
|
+
return this.root.hasDrawer();
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Registers the drawer's presence.
|
|
223
|
+
* @param present - Whether a drawer mounted.
|
|
224
|
+
*/
|
|
225
|
+
registerDrawer(present) {
|
|
226
|
+
this.root.hasDrawer.set(present);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The shell's `<header>` landmark: the drawer menu trigger (mobile, when a
|
|
231
|
+
* Drawer is composed), the brand, and trailing actions.
|
|
232
|
+
*/
|
|
233
|
+
export class ResponsiveAppShellTopBar {
|
|
234
|
+
/** Render the top bar only below the breakpoint (no dead DOM on desktop). */
|
|
235
|
+
mobileOnly = false;
|
|
236
|
+
/** Extra classes on the `<header>`. */
|
|
237
|
+
className;
|
|
238
|
+
/** `data-mol-id` (default `shell-topbar`). */
|
|
239
|
+
dataMolId = 'shell-topbar';
|
|
240
|
+
/** `data-testid`. */
|
|
241
|
+
testId;
|
|
242
|
+
/** The brand wrapper (detached when no brand is given). */
|
|
243
|
+
brandSlot;
|
|
244
|
+
/** The actions wrapper (detached when no actions are given). */
|
|
245
|
+
actionsSlot;
|
|
246
|
+
host = inject(ElementRef);
|
|
247
|
+
/**
|
|
248
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
249
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
250
|
+
* does not).
|
|
251
|
+
*/
|
|
252
|
+
i18n = useTranslation();
|
|
253
|
+
renderer = inject(Renderer2);
|
|
254
|
+
sync = new SlotWrapper(this.host, this.renderer);
|
|
255
|
+
brandParent = null;
|
|
256
|
+
actionsParent = null;
|
|
257
|
+
hasBrand = false;
|
|
258
|
+
hasActions = false;
|
|
259
|
+
detachedParent = null;
|
|
260
|
+
detachedAnchor = null;
|
|
261
|
+
/**
|
|
262
|
+
* The nearest shell context.
|
|
263
|
+
* @returns The context (null outside the shell).
|
|
264
|
+
*/
|
|
265
|
+
shell() {
|
|
266
|
+
// Cached: a detached (mobileOnly) header loses its DOM ancestors, so the
|
|
267
|
+
// lookup must not be repeated after the element leaves the tree.
|
|
268
|
+
this.context ??= contextOrDefault(this.host.nativeElement);
|
|
269
|
+
return this.context;
|
|
270
|
+
}
|
|
271
|
+
/** The resolved shell context. */
|
|
272
|
+
context = null;
|
|
273
|
+
/**
|
|
274
|
+
* The current class map.
|
|
275
|
+
* @returns The UIClassMap.
|
|
276
|
+
*/
|
|
277
|
+
cm() {
|
|
278
|
+
return getClassMap();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The header class list.
|
|
282
|
+
* @returns The class string.
|
|
283
|
+
*/
|
|
284
|
+
classes() {
|
|
285
|
+
return this.cm().cn(this.cm().flex({ align: 'center', justify: 'between', gap: 'sm' }), this.cm().sp('px', 4), this.cm().h(14), this.cm().surface, this.cm().borderB, this.cm().position('sticky'), this.className);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The header's inline style (sticky offset and z-index below the drawer).
|
|
289
|
+
* @returns The style attribute text.
|
|
290
|
+
*/
|
|
291
|
+
hostStyle() {
|
|
292
|
+
return styleText({ top: 0, zIndex: 20 });
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The drawer trigger's class list.
|
|
296
|
+
* @returns The class string.
|
|
297
|
+
*/
|
|
298
|
+
triggerClasses() {
|
|
299
|
+
return this.cm().cn(this.cm().flex({ align: 'center', justify: 'center' }), this.cm().shrink0, this.cm().roundedFull, this.cm().cursorPointer);
|
|
300
|
+
}
|
|
301
|
+
/** The drawer trigger's inline size (44px minimum tap target). */
|
|
302
|
+
triggerStyle() {
|
|
303
|
+
return styleText({ width: 44, height: 44 });
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The trigger's accessible label.
|
|
307
|
+
* @returns The label text.
|
|
308
|
+
*/
|
|
309
|
+
triggerLabel() {
|
|
310
|
+
return this.i18n.t('appShell.openMenu', {}, { defaultValue: 'Open navigation menu' });
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The menu glyph.
|
|
314
|
+
* @returns The resolved icon.
|
|
315
|
+
*/
|
|
316
|
+
menuIcon() {
|
|
317
|
+
return resolveIcon('menu', this.cm().iconMd);
|
|
318
|
+
}
|
|
319
|
+
/** Reads slot presence and applies the `mobileOnly` mount condition. */
|
|
320
|
+
ngAfterViewInit() {
|
|
321
|
+
this.brandParent = this.brandSlot?.nativeElement.parentElement ?? null;
|
|
322
|
+
this.actionsParent = this.actionsSlot?.nativeElement.parentElement ?? null;
|
|
323
|
+
this.hasBrand = hasNodes(this.brandSlot?.nativeElement);
|
|
324
|
+
this.hasActions = hasNodes(this.actionsSlot?.nativeElement);
|
|
325
|
+
this.syncWrappers();
|
|
326
|
+
this.syncVisibility();
|
|
327
|
+
}
|
|
328
|
+
/** Re-reconciles the wrappers and the mount condition. */
|
|
329
|
+
ngDoCheck() {
|
|
330
|
+
this.syncWrappers();
|
|
331
|
+
this.syncVisibility();
|
|
332
|
+
}
|
|
333
|
+
/** Restores a detached header (unmount). */
|
|
334
|
+
ngOnDestroy() {
|
|
335
|
+
this.reattach();
|
|
336
|
+
}
|
|
337
|
+
/** Applies React's `{mobileOnly && isDesktop ? null : <header>}`. */
|
|
338
|
+
syncVisibility() {
|
|
339
|
+
const hidden = this.mobileOnly && this.shell().isDesktop;
|
|
340
|
+
const host = this.host.nativeElement;
|
|
341
|
+
if (hidden && host.isConnected) {
|
|
342
|
+
this.detachedParent = host.parentNode;
|
|
343
|
+
this.detachedAnchor = host.nextSibling;
|
|
344
|
+
host.parentNode?.removeChild(host);
|
|
345
|
+
}
|
|
346
|
+
else if (!hidden && !host.isConnected && this.detachedParent) {
|
|
347
|
+
this.detachedParent.insertBefore(host, this.detachedAnchor);
|
|
348
|
+
this.detachedParent = null;
|
|
349
|
+
this.detachedAnchor = null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/** Restores the header into its parent (Angular's removal needs it there). */
|
|
353
|
+
reattach() {
|
|
354
|
+
const host = this.host.nativeElement;
|
|
355
|
+
if (!host.isConnected && this.detachedParent) {
|
|
356
|
+
this.detachedParent.insertBefore(host, this.detachedAnchor);
|
|
357
|
+
this.detachedParent = null;
|
|
358
|
+
this.detachedAnchor = null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/** Applies React's conditional brand/actions wrappers. */
|
|
362
|
+
syncWrappers() {
|
|
363
|
+
// While the header is detached (mobileOnly on desktop) every node reads as
|
|
364
|
+
// disconnected; attempting a re-attach would append it in the wrong place.
|
|
365
|
+
if (!this.host.nativeElement.isConnected)
|
|
366
|
+
return;
|
|
367
|
+
this.sync.sync(this.brandSlot?.nativeElement, this.hasBrand, this.brandParent ?? undefined);
|
|
368
|
+
this.sync.sync(this.actionsSlot?.nativeElement, this.hasActions, this.actionsParent ?? undefined);
|
|
369
|
+
}
|
|
370
|
+
static ɵfac = function ResponsiveAppShellTopBar_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ResponsiveAppShellTopBar)(); };
|
|
371
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResponsiveAppShellTopBar, selectors: [["header", "mol-responsive-app-shell-topbar", ""]], viewQuery: function ResponsiveAppShellTopBar_Query(rf, ctx) { if (rf & 1) {
|
|
372
|
+
i0.ɵɵviewQuery(_c1, 5)(_c2, 5);
|
|
373
|
+
} if (rf & 2) {
|
|
374
|
+
let _t;
|
|
375
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.brandSlot = _t.first);
|
|
376
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.actionsSlot = _t.first);
|
|
377
|
+
} }, hostVars: 6, hostBindings: function ResponsiveAppShellTopBar_HostBindings(rf, ctx) { if (rf & 2) {
|
|
378
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId)("data-testid", ctx.testId);
|
|
379
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
380
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
381
|
+
} }, inputs: { mobileOnly: "mobileOnly", className: "className", dataMolId: "dataMolId", testId: "testId" }, ngContentSelectors: _c4, decls: 8, vars: 11, consts: [["brandSlot", ""], ["actionsSlot", ""], ["type", "button", "data-mol-id", "shell-drawer-open", 3, "class", "style"], ["type", "button", "data-mol-id", "shell-drawer-open", 3, "click"], ["mol-icon", "", 3, "data"]], template: function ResponsiveAppShellTopBar_Template(rf, ctx) { if (rf & 1) {
|
|
382
|
+
i0.ɵɵprojectionDef(_c3);
|
|
383
|
+
i0.ɵɵelementStart(0, "div");
|
|
384
|
+
i0.ɵɵconditionalCreate(1, ResponsiveAppShellTopBar_Conditional_1_Template, 2, 8, "button", 2);
|
|
385
|
+
i0.ɵɵelementStart(2, "div", null, 0);
|
|
386
|
+
i0.ɵɵprojection(4);
|
|
387
|
+
i0.ɵɵelementEnd()();
|
|
388
|
+
i0.ɵɵelementStart(5, "div", null, 1);
|
|
389
|
+
i0.ɵɵprojection(7, 1);
|
|
390
|
+
i0.ɵɵelementEnd();
|
|
391
|
+
} if (rf & 2) {
|
|
392
|
+
i0.ɵɵstyleMap("min-width: 0px");
|
|
393
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex(i0.ɵɵpureFunction0(9, _c5))));
|
|
394
|
+
i0.ɵɵadvance();
|
|
395
|
+
i0.ɵɵconditional(ctx.shell().hasDrawer && !ctx.shell().isDesktop ? 1 : -1);
|
|
396
|
+
i0.ɵɵadvance();
|
|
397
|
+
i0.ɵɵstyleMap("min-width: 0px");
|
|
398
|
+
i0.ɵɵadvance(3);
|
|
399
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex(i0.ɵɵpureFunction0(10, _c5)), ctx.cm().shrink0));
|
|
400
|
+
} }, dependencies: [MolIconSvg], encapsulation: 2 });
|
|
401
|
+
}
|
|
402
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResponsiveAppShellTopBar, [{
|
|
403
|
+
type: Component,
|
|
404
|
+
args: [{
|
|
405
|
+
selector: 'header[mol-responsive-app-shell-topbar]',
|
|
406
|
+
standalone: true,
|
|
407
|
+
imports: [MolIconSvg],
|
|
408
|
+
inputs: ['mobileOnly', 'className', 'dataMolId', 'testId'],
|
|
409
|
+
host: {
|
|
410
|
+
'[class]': 'classes()',
|
|
411
|
+
'[style]': 'hostStyle()',
|
|
412
|
+
'[attr.data-mol-id]': 'dataMolId',
|
|
413
|
+
'[attr.data-testid]': 'testId',
|
|
414
|
+
},
|
|
415
|
+
template: `<div
|
|
416
|
+
[class]="cm().cn(cm().flex({ align: 'center', gap: 'sm' }))"
|
|
417
|
+
[style]="'min-width: 0px'"
|
|
418
|
+
>
|
|
419
|
+
@if (shell().hasDrawer && !shell().isDesktop) {
|
|
420
|
+
<button
|
|
421
|
+
type="button"
|
|
422
|
+
(click)="shell().openDrawer()"
|
|
423
|
+
[attr.aria-label]="triggerLabel()"
|
|
424
|
+
[attr.aria-expanded]="shell().drawerOpen ? 'true' : 'false'"
|
|
425
|
+
[attr.aria-controls]="shell().drawerId"
|
|
426
|
+
data-mol-id="shell-drawer-open"
|
|
427
|
+
[class]="triggerClasses()"
|
|
428
|
+
[style]="triggerStyle()"
|
|
429
|
+
>
|
|
430
|
+
<svg mol-icon [data]="menuIcon()" />
|
|
431
|
+
</button>
|
|
432
|
+
}
|
|
433
|
+
<div #brandSlot [style]="'min-width: 0px'">
|
|
434
|
+
<ng-content select="[slot=brand]"></ng-content>
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
<div #actionsSlot [class]="cm().cn(cm().flex({ align: 'center', gap: 'sm' }), cm().shrink0)">
|
|
438
|
+
<ng-content select="[slot=actions]"></ng-content>
|
|
439
|
+
</div>`,
|
|
440
|
+
}]
|
|
441
|
+
}], null, { brandSlot: [{
|
|
442
|
+
type: ViewChild,
|
|
443
|
+
args: ['brandSlot']
|
|
444
|
+
}], actionsSlot: [{
|
|
445
|
+
type: ViewChild,
|
|
446
|
+
args: ['actionsSlot']
|
|
447
|
+
}] }); })();
|
|
448
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResponsiveAppShellTopBar, { className: "ResponsiveAppShellTopBar", filePath: "components/responsive-app-shell.component.ts", lineNumber: 263 }); })();
|
|
449
|
+
/**
|
|
450
|
+
* The desktop sidebar (`<aside>` + `<nav>` landmarks); renders nothing below
|
|
451
|
+
* the breakpoint (the Drawer carries the nav there).
|
|
452
|
+
*/
|
|
453
|
+
export class ResponsiveAppShellSidebar {
|
|
454
|
+
/** Accessible name for the `<nav>` landmark. */
|
|
455
|
+
navLabel;
|
|
456
|
+
/** Extra classes on the `<aside>`. */
|
|
457
|
+
className;
|
|
458
|
+
/** `data-mol-id` (default `shell-sidebar`). */
|
|
459
|
+
dataMolId = 'shell-sidebar';
|
|
460
|
+
/** `data-testid`. */
|
|
461
|
+
testId;
|
|
462
|
+
/** The footer wrapper (detached when no footer is given). */
|
|
463
|
+
footerSlot;
|
|
464
|
+
host = inject(ElementRef);
|
|
465
|
+
/**
|
|
466
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
467
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
468
|
+
* does not).
|
|
469
|
+
*/
|
|
470
|
+
i18n = useTranslation();
|
|
471
|
+
renderer = inject(Renderer2);
|
|
472
|
+
sync = new SlotWrapper(this.host, this.renderer);
|
|
473
|
+
footerParent = null;
|
|
474
|
+
hasFooter = false;
|
|
475
|
+
detachedParent = null;
|
|
476
|
+
detachedAnchor = null;
|
|
477
|
+
/**
|
|
478
|
+
* The nearest shell context.
|
|
479
|
+
* @returns The context (defaults outside the shell).
|
|
480
|
+
*/
|
|
481
|
+
shell() {
|
|
482
|
+
// Cached: a detached (mobile) sidebar loses its DOM ancestors.
|
|
483
|
+
this.context ??= contextOrDefault(this.host.nativeElement);
|
|
484
|
+
return this.context;
|
|
485
|
+
}
|
|
486
|
+
/** The resolved shell context. */
|
|
487
|
+
context = null;
|
|
488
|
+
/**
|
|
489
|
+
* The current class map.
|
|
490
|
+
* @returns The UIClassMap.
|
|
491
|
+
*/
|
|
492
|
+
cm() {
|
|
493
|
+
return getClassMap();
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* The aside class list.
|
|
497
|
+
* @returns The class string.
|
|
498
|
+
*/
|
|
499
|
+
classes() {
|
|
500
|
+
return this.cm().cn(this.cm().flex({ direction: 'col' }), this.cm().shrink0, this.cm().surface, this.cm().borderR, this.cm().h('screen'), this.cm().position('sticky'), this.className);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* The aside's inline style (exact width, sticky top, internal scroll).
|
|
504
|
+
* @returns The style attribute text.
|
|
505
|
+
*/
|
|
506
|
+
hostStyle() {
|
|
507
|
+
return styleText({ top: 0, width: this.shell().sidebarWidthPx, overflowY: 'auto' });
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* The nav's accessible label.
|
|
511
|
+
* @returns The label text.
|
|
512
|
+
*/
|
|
513
|
+
navLabelText() {
|
|
514
|
+
return (this.navLabel ??
|
|
515
|
+
this.i18n.t('appShell.primaryNav', {}, { defaultValue: 'Primary navigation' }));
|
|
516
|
+
}
|
|
517
|
+
/** Applies the initial mount condition and footer presence. */
|
|
518
|
+
ngAfterViewInit() {
|
|
519
|
+
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null;
|
|
520
|
+
this.hasFooter = hasNodes(this.footerSlot?.nativeElement);
|
|
521
|
+
this.syncWrapper();
|
|
522
|
+
this.syncVisibility();
|
|
523
|
+
}
|
|
524
|
+
/** Re-reconciles the mount condition and the footer wrapper. */
|
|
525
|
+
ngDoCheck() {
|
|
526
|
+
this.syncWrapper();
|
|
527
|
+
this.syncVisibility();
|
|
528
|
+
}
|
|
529
|
+
/** Restores a detached aside (unmount). */
|
|
530
|
+
ngOnDestroy() {
|
|
531
|
+
this.reattach();
|
|
532
|
+
}
|
|
533
|
+
/** Applies React's `{!isDesktop ? null : <aside>}`. */
|
|
534
|
+
syncVisibility() {
|
|
535
|
+
const hidden = !this.shell().isDesktop;
|
|
536
|
+
const host = this.host.nativeElement;
|
|
537
|
+
if (hidden && host.isConnected) {
|
|
538
|
+
this.detachedParent = host.parentNode;
|
|
539
|
+
this.detachedAnchor = host.nextSibling;
|
|
540
|
+
host.parentNode?.removeChild(host);
|
|
541
|
+
}
|
|
542
|
+
else if (!hidden && !host.isConnected && this.detachedParent) {
|
|
543
|
+
this.detachedParent.insertBefore(host, this.detachedAnchor);
|
|
544
|
+
this.detachedParent = null;
|
|
545
|
+
this.detachedAnchor = null;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
/** Restores the aside into its parent. */
|
|
549
|
+
reattach() {
|
|
550
|
+
const host = this.host.nativeElement;
|
|
551
|
+
if (!host.isConnected && this.detachedParent) {
|
|
552
|
+
this.detachedParent.insertBefore(host, this.detachedAnchor);
|
|
553
|
+
this.detachedParent = null;
|
|
554
|
+
this.detachedAnchor = null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
/** Applies React's conditional footer wrapper. */
|
|
558
|
+
syncWrapper() {
|
|
559
|
+
// While the aside is detached (mobile) every node reads as disconnected.
|
|
560
|
+
if (!this.host.nativeElement.isConnected)
|
|
561
|
+
return;
|
|
562
|
+
this.sync.sync(this.footerSlot?.nativeElement, this.hasFooter, this.footerParent ?? undefined);
|
|
563
|
+
}
|
|
564
|
+
static ɵfac = function ResponsiveAppShellSidebar_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ResponsiveAppShellSidebar)(); };
|
|
565
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResponsiveAppShellSidebar, selectors: [["aside", "mol-responsive-app-shell-sidebar", ""]], viewQuery: function ResponsiveAppShellSidebar_Query(rf, ctx) { if (rf & 1) {
|
|
566
|
+
i0.ɵɵviewQuery(_c6, 5);
|
|
567
|
+
} if (rf & 2) {
|
|
568
|
+
let _t;
|
|
569
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.footerSlot = _t.first);
|
|
570
|
+
} }, hostVars: 6, hostBindings: function ResponsiveAppShellSidebar_HostBindings(rf, ctx) { if (rf & 2) {
|
|
571
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId)("data-testid", ctx.testId);
|
|
572
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
573
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
574
|
+
} }, inputs: { navLabel: "navLabel", className: "className", dataMolId: "dataMolId", testId: "testId" }, ngContentSelectors: _c8, decls: 5, vars: 6, consts: [["footerSlot", ""]], template: function ResponsiveAppShellSidebar_Template(rf, ctx) { if (rf & 1) {
|
|
575
|
+
i0.ɵɵprojectionDef(_c7);
|
|
576
|
+
i0.ɵɵdomElementStart(0, "nav");
|
|
577
|
+
i0.ɵɵprojection(1);
|
|
578
|
+
i0.ɵɵdomElementEnd();
|
|
579
|
+
i0.ɵɵdomElementStart(2, "div", null, 0);
|
|
580
|
+
i0.ɵɵprojection(4, 1);
|
|
581
|
+
i0.ɵɵdomElementEnd();
|
|
582
|
+
} if (rf & 2) {
|
|
583
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex1, ctx.cm().stack(1)));
|
|
584
|
+
i0.ɵɵattribute("aria-label", ctx.navLabelText());
|
|
585
|
+
i0.ɵɵadvance(2);
|
|
586
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex(i0.ɵɵpureFunction0(5, _c9)), ctx.cm().borderT, ctx.cm().sp("p", 3), ctx.cm().shrink0));
|
|
587
|
+
} }, encapsulation: 2 });
|
|
588
|
+
}
|
|
589
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResponsiveAppShellSidebar, [{
|
|
590
|
+
type: Component,
|
|
591
|
+
args: [{
|
|
592
|
+
selector: 'aside[mol-responsive-app-shell-sidebar]',
|
|
593
|
+
standalone: true,
|
|
594
|
+
inputs: ['navLabel', 'className', 'dataMolId', 'testId'],
|
|
595
|
+
host: {
|
|
596
|
+
'[class]': 'classes()',
|
|
597
|
+
'[style]': 'hostStyle()',
|
|
598
|
+
'[attr.data-mol-id]': 'dataMolId',
|
|
599
|
+
'[attr.data-testid]': 'testId',
|
|
600
|
+
},
|
|
601
|
+
template: `<nav [attr.aria-label]="navLabelText()" [class]="cm().cn(cm().flex1, cm().stack(1))">
|
|
602
|
+
<ng-content></ng-content>
|
|
603
|
+
</nav>
|
|
604
|
+
<div
|
|
605
|
+
#footerSlot
|
|
606
|
+
[class]="
|
|
607
|
+
cm().cn(
|
|
608
|
+
cm().flex({ align: 'center', justify: 'between', gap: 'sm' }),
|
|
609
|
+
cm().borderT,
|
|
610
|
+
cm().sp('p', 3),
|
|
611
|
+
cm().shrink0
|
|
612
|
+
)
|
|
613
|
+
"
|
|
614
|
+
>
|
|
615
|
+
<ng-content select="[slot=footer]"></ng-content>
|
|
616
|
+
</div>`,
|
|
617
|
+
}]
|
|
618
|
+
}], null, { footerSlot: [{
|
|
619
|
+
type: ViewChild,
|
|
620
|
+
args: ['footerSlot']
|
|
621
|
+
}] }); })();
|
|
622
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResponsiveAppShellSidebar, { className: "ResponsiveAppShellSidebar", filePath: "components/responsive-app-shell.component.ts", lineNumber: 467 }); })();
|
|
623
|
+
/**
|
|
624
|
+
* The mobile nav drawer (<768px): a left-anchored dialog panel over a
|
|
625
|
+
* backdrop, portaled into `document.body`.
|
|
626
|
+
*/
|
|
627
|
+
export class ResponsiveAppShellDrawer {
|
|
628
|
+
/** Accessible name for the dialog and nav landmark. */
|
|
629
|
+
navLabel;
|
|
630
|
+
/** Whether the panel shows a close (X) button (default true). */
|
|
631
|
+
showCloseButton = true;
|
|
632
|
+
/** Extra classes on the dialog panel. */
|
|
633
|
+
className;
|
|
634
|
+
/** `data-mol-id` for the panel (default `shell-drawer`). */
|
|
635
|
+
dataMolId = 'shell-drawer';
|
|
636
|
+
/** `data-mol-id` for the close button (default `shell-drawer-close`). */
|
|
637
|
+
closeDataMolId = 'shell-drawer-close';
|
|
638
|
+
/** `data-testid` for the panel. */
|
|
639
|
+
testId;
|
|
640
|
+
/** The backdrop element. */
|
|
641
|
+
overlay;
|
|
642
|
+
/** The fixed wrapper. */
|
|
643
|
+
wrapper;
|
|
644
|
+
/** The dialog panel. */
|
|
645
|
+
panel;
|
|
646
|
+
/** The header row (detached when React renders neither header nor close button). */
|
|
647
|
+
headerRow;
|
|
648
|
+
/** The header wrapper (detached when no header is given). */
|
|
649
|
+
headerSlot;
|
|
650
|
+
/** The footer wrapper (detached when no footer is given). */
|
|
651
|
+
footerSlot;
|
|
652
|
+
/** Whether the header slot carries nodes (a signal: read after view init). */
|
|
653
|
+
headerPresent = signal(false, /* @ts-ignore */
|
|
654
|
+
...(ngDevMode ? [{ debugName: "headerPresent" }] : /* istanbul ignore next */ []));
|
|
655
|
+
host = inject(ElementRef);
|
|
656
|
+
/**
|
|
657
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
658
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
659
|
+
* does not).
|
|
660
|
+
*/
|
|
661
|
+
i18n = useTranslation();
|
|
662
|
+
renderer = inject(Renderer2);
|
|
663
|
+
sync = new SlotWrapper(this.host, this.renderer);
|
|
664
|
+
scrollLock = createScrollLock();
|
|
665
|
+
hasFooter = false;
|
|
666
|
+
footerParent = null;
|
|
667
|
+
headerParent = null;
|
|
668
|
+
headerRowParent = null;
|
|
669
|
+
attached = false;
|
|
670
|
+
locked = false;
|
|
671
|
+
lastOpen = false;
|
|
672
|
+
previouslyFocused = null;
|
|
673
|
+
listeners = [];
|
|
674
|
+
/**
|
|
675
|
+
* The nearest shell context.
|
|
676
|
+
* @returns The context (defaults outside the shell).
|
|
677
|
+
*/
|
|
678
|
+
shell() {
|
|
679
|
+
this.context ??= contextOrDefault(this.host.nativeElement);
|
|
680
|
+
return this.context;
|
|
681
|
+
}
|
|
682
|
+
/** The resolved shell context. */
|
|
683
|
+
context = null;
|
|
684
|
+
/**
|
|
685
|
+
* The current class map.
|
|
686
|
+
* @returns The UIClassMap.
|
|
687
|
+
*/
|
|
688
|
+
cm() {
|
|
689
|
+
return getClassMap();
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* The panel class list.
|
|
693
|
+
* @returns The class string.
|
|
694
|
+
*/
|
|
695
|
+
panelClasses() {
|
|
696
|
+
return this.cm().cn(this.cm().flex({ direction: 'col' }), this.cm().surface, this.className);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* The panel's inline geometry (exact width, at most 85vw, internal scroll).
|
|
700
|
+
* @returns The style attribute text.
|
|
701
|
+
*/
|
|
702
|
+
panelStyle() {
|
|
703
|
+
return styleText({
|
|
704
|
+
width: this.shell().sidebarWidthPx,
|
|
705
|
+
maxWidth: '85vw',
|
|
706
|
+
overflowY: 'auto',
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
/** The wrapper's inline style (stacking above the backdrop). */
|
|
710
|
+
wrapperStyle() {
|
|
711
|
+
return styleText({ zIndex: 41 });
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* The close button's class list.
|
|
715
|
+
* @returns The class string.
|
|
716
|
+
*/
|
|
717
|
+
closeClasses() {
|
|
718
|
+
return this.cm().cn(this.cm().flex({ align: 'center', justify: 'center' }), this.cm().w(10), this.cm().h(10), this.cm().shrink0, this.cm().roundedFull, this.cm().cursorPointer, this.cm().textMuted);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* The nav/dialog accessible label.
|
|
722
|
+
* @returns The label text.
|
|
723
|
+
*/
|
|
724
|
+
navLabelText() {
|
|
725
|
+
return (this.navLabel ??
|
|
726
|
+
this.i18n.t('appShell.primaryNav', {}, { defaultValue: 'Primary navigation' }));
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* The close button's accessible label.
|
|
730
|
+
* @returns The label text.
|
|
731
|
+
*/
|
|
732
|
+
closeLabel() {
|
|
733
|
+
return this.i18n.t('appShell.closeMenu', {}, { defaultValue: 'Close navigation menu' });
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* The close glyph.
|
|
737
|
+
* @returns The resolved icon.
|
|
738
|
+
*/
|
|
739
|
+
closeIcon() {
|
|
740
|
+
return resolveIcon('x-mark', this.cm().iconMd);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Stops a click inside the panel from reaching the backdrop handler.
|
|
744
|
+
*
|
|
745
|
+
* @param event - The click event.
|
|
746
|
+
*/
|
|
747
|
+
stopPropagation(event) {
|
|
748
|
+
event.stopPropagation();
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Closes when the click is on the wrapper itself (the backdrop area).
|
|
752
|
+
*
|
|
753
|
+
* @param event - The click event.
|
|
754
|
+
*/
|
|
755
|
+
handleBackdropClick(event) {
|
|
756
|
+
if (event.target === event.currentTarget)
|
|
757
|
+
this.shell().closeDrawer();
|
|
758
|
+
}
|
|
759
|
+
/** Registers the drawer, reads slots and applies the initial open state. */
|
|
760
|
+
ngAfterViewInit() {
|
|
761
|
+
this.shell().registerDrawer(true);
|
|
762
|
+
this.headerParent = this.headerSlot?.nativeElement.parentElement ?? null;
|
|
763
|
+
this.headerRowParent = this.headerRow?.nativeElement.parentElement ?? null;
|
|
764
|
+
this.footerParent = this.footerSlot?.nativeElement.parentElement ?? null;
|
|
765
|
+
this.headerPresent.set(hasNodes(this.headerSlot?.nativeElement));
|
|
766
|
+
this.hasFooter = hasNodes(this.footerSlot?.nativeElement);
|
|
767
|
+
this.syncWrappers();
|
|
768
|
+
const open = this.shell().drawerOpen && !this.shell().isDesktop;
|
|
769
|
+
this.lastOpen = open;
|
|
770
|
+
if (open)
|
|
771
|
+
this.openPanel();
|
|
772
|
+
else
|
|
773
|
+
this.detachPortal();
|
|
774
|
+
}
|
|
775
|
+
/** Reconciles the open state, the wrappers and the drawer registration. */
|
|
776
|
+
ngDoCheck() {
|
|
777
|
+
this.hasFooter = hasNodes(this.footerSlot?.nativeElement);
|
|
778
|
+
this.syncWrappers();
|
|
779
|
+
this.syncOpen();
|
|
780
|
+
}
|
|
781
|
+
/** Unregisters the drawer, unlocks scroll and restores the portal nodes. */
|
|
782
|
+
ngOnDestroy() {
|
|
783
|
+
this.shell().registerDrawer(false);
|
|
784
|
+
this.removeListeners();
|
|
785
|
+
if (this.locked) {
|
|
786
|
+
this.scrollLock.unlock();
|
|
787
|
+
this.locked = false;
|
|
788
|
+
}
|
|
789
|
+
const host = this.host.nativeElement;
|
|
790
|
+
if (this.attached) {
|
|
791
|
+
const overlay = this.overlay?.nativeElement;
|
|
792
|
+
const wrapper = this.wrapper?.nativeElement;
|
|
793
|
+
if (overlay?.parentNode === document.body)
|
|
794
|
+
host.appendChild(overlay);
|
|
795
|
+
if (wrapper?.parentNode === document.body)
|
|
796
|
+
host.appendChild(wrapper);
|
|
797
|
+
this.attached = false;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
/** Applies React's conditional header/footer wrappers. */
|
|
801
|
+
syncWrappers() {
|
|
802
|
+
// The whole panel lives in a detached portal while the drawer is closed;
|
|
803
|
+
// a "re-attach" there would append the wrapper at the panel's end.
|
|
804
|
+
if (!this.attached)
|
|
805
|
+
return;
|
|
806
|
+
this.sync.sync(this.headerRow?.nativeElement, this.headerPresent() || this.showCloseButton, this.headerRowParent ?? undefined);
|
|
807
|
+
this.sync.sync(this.headerSlot?.nativeElement, this.headerPresent(), this.headerParent ?? undefined);
|
|
808
|
+
this.sync.sync(this.footerSlot?.nativeElement, this.hasFooter, this.footerParent ?? undefined);
|
|
809
|
+
}
|
|
810
|
+
/** Applies the open transition (portal mounting, focus, scroll lock). */
|
|
811
|
+
syncOpen() {
|
|
812
|
+
const open = this.shell().drawerOpen && !this.shell().isDesktop;
|
|
813
|
+
if (open === this.lastOpen)
|
|
814
|
+
return;
|
|
815
|
+
this.lastOpen = open;
|
|
816
|
+
if (open) {
|
|
817
|
+
this.openPanel();
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
this.removeListeners();
|
|
821
|
+
this.detachPortal();
|
|
822
|
+
if (this.locked) {
|
|
823
|
+
this.scrollLock.unlock();
|
|
824
|
+
this.locked = false;
|
|
825
|
+
}
|
|
826
|
+
const toRestore = this.previouslyFocused;
|
|
827
|
+
if (toRestore && document.contains(toRestore))
|
|
828
|
+
toRestore.focus();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
/** Mounts the open panel: portal, focus into the panel, scroll lock, keys. */
|
|
832
|
+
openPanel() {
|
|
833
|
+
this.previouslyFocused = document.activeElement ?? null;
|
|
834
|
+
this.attachPortal();
|
|
835
|
+
// The wrappers could not be reconciled while the portal was detached
|
|
836
|
+
// (every node read as disconnected); apply them now that it is mounted.
|
|
837
|
+
this.syncWrappers();
|
|
838
|
+
const panel = this.panel?.nativeElement;
|
|
839
|
+
if (panel) {
|
|
840
|
+
const focusables = getFocusableElements(panel);
|
|
841
|
+
(focusables[0] ?? panel).focus();
|
|
842
|
+
}
|
|
843
|
+
this.scrollLock.lock();
|
|
844
|
+
this.locked = true;
|
|
845
|
+
this.addListeners();
|
|
846
|
+
}
|
|
847
|
+
/** Moves the portal nodes into `document.body`. */
|
|
848
|
+
attachPortal() {
|
|
849
|
+
const overlay = this.overlay?.nativeElement;
|
|
850
|
+
const wrapper = this.wrapper?.nativeElement;
|
|
851
|
+
if (!overlay || !wrapper)
|
|
852
|
+
return;
|
|
853
|
+
document.body.appendChild(overlay);
|
|
854
|
+
document.body.appendChild(wrapper);
|
|
855
|
+
this.attached = true;
|
|
856
|
+
}
|
|
857
|
+
/** Removes the portal nodes (React renders null). */
|
|
858
|
+
detachPortal() {
|
|
859
|
+
this.overlay?.nativeElement.remove();
|
|
860
|
+
this.wrapper?.nativeElement.remove();
|
|
861
|
+
this.attached = false;
|
|
862
|
+
}
|
|
863
|
+
/** Adds Escape and the Tab focus trap while open. */
|
|
864
|
+
addListeners() {
|
|
865
|
+
this.removeListeners();
|
|
866
|
+
const onKeyDown = (event) => this.handleKeyDown(event);
|
|
867
|
+
document.addEventListener('keydown', onKeyDown);
|
|
868
|
+
this.listeners.push(() => document.removeEventListener('keydown', onKeyDown));
|
|
869
|
+
}
|
|
870
|
+
/** Removes the document listeners. */
|
|
871
|
+
removeListeners() {
|
|
872
|
+
for (const off of this.listeners)
|
|
873
|
+
off();
|
|
874
|
+
this.listeners = [];
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Escape closes the drawer; Tab wraps inside the panel.
|
|
878
|
+
*
|
|
879
|
+
* @param event - The key event.
|
|
880
|
+
*/
|
|
881
|
+
handleKeyDown(event) {
|
|
882
|
+
if (event.key === 'Escape') {
|
|
883
|
+
this.shell().closeDrawer();
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
if (event.key !== 'Tab')
|
|
887
|
+
return;
|
|
888
|
+
const el = this.panel?.nativeElement;
|
|
889
|
+
if (!el)
|
|
890
|
+
return;
|
|
891
|
+
const focusables = getFocusableElements(el);
|
|
892
|
+
if (focusables.length === 0) {
|
|
893
|
+
event.preventDefault();
|
|
894
|
+
el.focus();
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const first = focusables[0];
|
|
898
|
+
const last = focusables[focusables.length - 1];
|
|
899
|
+
const active = document.activeElement;
|
|
900
|
+
if (event.shiftKey) {
|
|
901
|
+
if (active === first || !el.contains(active)) {
|
|
902
|
+
event.preventDefault();
|
|
903
|
+
last.focus();
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
else if (active === last || !el.contains(active)) {
|
|
907
|
+
event.preventDefault();
|
|
908
|
+
first.focus();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
static ɵfac = function ResponsiveAppShellDrawer_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ResponsiveAppShellDrawer)(); };
|
|
912
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResponsiveAppShellDrawer, selectors: [["mol-responsive-app-shell-drawer"]], viewQuery: function ResponsiveAppShellDrawer_Query(rf, ctx) { if (rf & 1) {
|
|
913
|
+
i0.ɵɵviewQuery(_c10, 5)(_c11, 5)(_c12, 5)(_c13, 5)(_c14, 5)(_c6, 5);
|
|
914
|
+
} if (rf & 2) {
|
|
915
|
+
let _t;
|
|
916
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.overlay = _t.first);
|
|
917
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.wrapper = _t.first);
|
|
918
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.panel = _t.first);
|
|
919
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.headerRow = _t.first);
|
|
920
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.headerSlot = _t.first);
|
|
921
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.footerSlot = _t.first);
|
|
922
|
+
} }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], hostVars: 1, hostBindings: function ResponsiveAppShellDrawer_HostBindings(rf, ctx) { if (rf & 2) {
|
|
923
|
+
i0.ɵɵattribute("data-open", ctx.shell().drawerOpen ? "true" : null);
|
|
924
|
+
} }, inputs: { navLabel: "navLabel", showCloseButton: "showCloseButton", className: "className", dataMolId: "dataMolId", closeDataMolId: "closeDataMolId", testId: "testId" }, ngContentSelectors: _c16, decls: 18, vars: 27, consts: [["overlay", ""], ["wrapper", ""], ["panel", ""], ["headerRow", ""], ["headerSlot", ""], ["footerSlot", ""], ["aria-hidden", "true"], [3, "click"], ["role", "dialog", "aria-modal", "true", "tabindex", "-1", 3, "click", "id"], ["type", "button", 3, "class"], ["type", "button", 3, "click"], ["mol-icon", "", 3, "data"]], template: function ResponsiveAppShellDrawer_Template(rf, ctx) { if (rf & 1) {
|
|
925
|
+
i0.ɵɵprojectionDef(_c15);
|
|
926
|
+
i0.ɵɵelement(0, "div", 6, 0);
|
|
927
|
+
i0.ɵɵelementStart(2, "div", 7, 1);
|
|
928
|
+
i0.ɵɵlistener("click", function ResponsiveAppShellDrawer_Template_div_click_2_listener($event) { return ctx.handleBackdropClick($event); });
|
|
929
|
+
i0.ɵɵelementStart(4, "div", 8, 2);
|
|
930
|
+
i0.ɵɵlistener("click", function ResponsiveAppShellDrawer_Template_div_click_4_listener($event) { return ctx.stopPropagation($event); });
|
|
931
|
+
i0.ɵɵelementStart(6, "div", null, 3)(8, "div", null, 4);
|
|
932
|
+
i0.ɵɵprojection(10);
|
|
933
|
+
i0.ɵɵelementEnd();
|
|
934
|
+
i0.ɵɵconditionalCreate(11, ResponsiveAppShellDrawer_Conditional_11_Template, 1, 0, "span", 6);
|
|
935
|
+
i0.ɵɵconditionalCreate(12, ResponsiveAppShellDrawer_Conditional_12_Template, 2, 5, "button", 9);
|
|
936
|
+
i0.ɵɵelementEnd();
|
|
937
|
+
i0.ɵɵelementStart(13, "nav");
|
|
938
|
+
i0.ɵɵprojection(14, 1);
|
|
939
|
+
i0.ɵɵelementEnd();
|
|
940
|
+
i0.ɵɵelementStart(15, "div", null, 5);
|
|
941
|
+
i0.ɵɵprojection(17, 2);
|
|
942
|
+
i0.ɵɵelementEnd()()();
|
|
943
|
+
} if (rf & 2) {
|
|
944
|
+
i0.ɵɵclassMap(ctx.cm().overlay);
|
|
945
|
+
i0.ɵɵadvance(2);
|
|
946
|
+
i0.ɵɵstyleMap(ctx.wrapperStyle());
|
|
947
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().position("fixed"), ctx.cm().inset0));
|
|
948
|
+
i0.ɵɵadvance(2);
|
|
949
|
+
i0.ɵɵstyleMap(ctx.panelStyle());
|
|
950
|
+
i0.ɵɵclassMap(ctx.panelClasses());
|
|
951
|
+
i0.ɵɵproperty("id", ctx.shell().drawerId);
|
|
952
|
+
i0.ɵɵattribute("aria-label", ctx.navLabelText())("data-mol-id", ctx.dataMolId)("data-testid", ctx.testId);
|
|
953
|
+
i0.ɵɵadvance(2);
|
|
954
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex(i0.ɵɵpureFunction0(25, _c9)), ctx.cm().sp("p", 3), ctx.cm().shrink0));
|
|
955
|
+
i0.ɵɵadvance(2);
|
|
956
|
+
i0.ɵɵstyleMap("min-width: 0px");
|
|
957
|
+
i0.ɵɵadvance(3);
|
|
958
|
+
i0.ɵɵconditional(!ctx.headerPresent() ? 11 : -1);
|
|
959
|
+
i0.ɵɵadvance();
|
|
960
|
+
i0.ɵɵconditional(ctx.showCloseButton ? 12 : -1);
|
|
961
|
+
i0.ɵɵadvance();
|
|
962
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex1, ctx.cm().stack(1)));
|
|
963
|
+
i0.ɵɵattribute("aria-label", ctx.navLabelText());
|
|
964
|
+
i0.ɵɵadvance(2);
|
|
965
|
+
i0.ɵɵclassMap(ctx.cm().cn(ctx.cm().flex(i0.ɵɵpureFunction0(26, _c17)), ctx.cm().borderT, ctx.cm().sp("p", 3), ctx.cm().shrink0));
|
|
966
|
+
} }, dependencies: [MolIconSvg], encapsulation: 2 });
|
|
967
|
+
}
|
|
968
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResponsiveAppShellDrawer, [{
|
|
969
|
+
type: Component,
|
|
970
|
+
args: [{
|
|
971
|
+
selector: 'mol-responsive-app-shell-drawer',
|
|
972
|
+
standalone: true,
|
|
973
|
+
imports: [MolIconSvg],
|
|
974
|
+
inputs: ['navLabel', 'showCloseButton', 'className', 'dataMolId', 'closeDataMolId', 'testId'],
|
|
975
|
+
host: {
|
|
976
|
+
'data-parity-unwrap': '',
|
|
977
|
+
style: 'display: contents',
|
|
978
|
+
'[attr.data-open]': 'shell().drawerOpen ? "true" : null',
|
|
979
|
+
},
|
|
980
|
+
template: `<div #overlay [class]="cm().overlay" aria-hidden="true"></div>
|
|
981
|
+
<div
|
|
982
|
+
#wrapper
|
|
983
|
+
[class]="cm().cn(cm().position('fixed'), cm().inset0)"
|
|
984
|
+
[style]="wrapperStyle()"
|
|
985
|
+
(click)="handleBackdropClick($event)"
|
|
986
|
+
>
|
|
987
|
+
<div
|
|
988
|
+
#panel
|
|
989
|
+
[id]="shell().drawerId"
|
|
990
|
+
role="dialog"
|
|
991
|
+
aria-modal="true"
|
|
992
|
+
[attr.aria-label]="navLabelText()"
|
|
993
|
+
tabindex="-1"
|
|
994
|
+
[class]="panelClasses()"
|
|
995
|
+
[style]="panelStyle()"
|
|
996
|
+
[attr.data-mol-id]="dataMolId"
|
|
997
|
+
[attr.data-testid]="testId"
|
|
998
|
+
(click)="stopPropagation($event)"
|
|
999
|
+
>
|
|
1000
|
+
<div
|
|
1001
|
+
#headerRow
|
|
1002
|
+
[class]="
|
|
1003
|
+
cm().cn(
|
|
1004
|
+
cm().flex({ align: 'center', justify: 'between', gap: 'sm' }),
|
|
1005
|
+
cm().sp('p', 3),
|
|
1006
|
+
cm().shrink0
|
|
1007
|
+
)
|
|
1008
|
+
"
|
|
1009
|
+
>
|
|
1010
|
+
<div #headerSlot [style]="'min-width: 0px'">
|
|
1011
|
+
<ng-content select="[slot=header]"></ng-content>
|
|
1012
|
+
</div>
|
|
1013
|
+
@if (!headerPresent()) {
|
|
1014
|
+
<span aria-hidden="true"></span>
|
|
1015
|
+
}
|
|
1016
|
+
@if (showCloseButton) {
|
|
1017
|
+
<button
|
|
1018
|
+
type="button"
|
|
1019
|
+
(click)="shell().closeDrawer()"
|
|
1020
|
+
[attr.aria-label]="closeLabel()"
|
|
1021
|
+
[attr.data-mol-id]="closeDataMolId"
|
|
1022
|
+
[class]="closeClasses()"
|
|
1023
|
+
>
|
|
1024
|
+
<svg mol-icon [data]="closeIcon()" />
|
|
1025
|
+
</button>
|
|
1026
|
+
}
|
|
1027
|
+
</div>
|
|
1028
|
+
<nav [attr.aria-label]="navLabelText()" [class]="cm().cn(cm().flex1, cm().stack(1))">
|
|
1029
|
+
<ng-content></ng-content>
|
|
1030
|
+
</nav>
|
|
1031
|
+
<div
|
|
1032
|
+
#footerSlot
|
|
1033
|
+
[class]="
|
|
1034
|
+
cm().cn(
|
|
1035
|
+
cm().flex({ direction: 'col', gap: 'sm' }),
|
|
1036
|
+
cm().borderT,
|
|
1037
|
+
cm().sp('p', 3),
|
|
1038
|
+
cm().shrink0
|
|
1039
|
+
)
|
|
1040
|
+
"
|
|
1041
|
+
>
|
|
1042
|
+
<ng-content select="[slot=footer]"></ng-content>
|
|
1043
|
+
</div>
|
|
1044
|
+
</div>
|
|
1045
|
+
</div>`,
|
|
1046
|
+
}]
|
|
1047
|
+
}], null, { overlay: [{
|
|
1048
|
+
type: ViewChild,
|
|
1049
|
+
args: ['overlay']
|
|
1050
|
+
}], wrapper: [{
|
|
1051
|
+
type: ViewChild,
|
|
1052
|
+
args: ['wrapper']
|
|
1053
|
+
}], panel: [{
|
|
1054
|
+
type: ViewChild,
|
|
1055
|
+
args: ['panel']
|
|
1056
|
+
}], headerRow: [{
|
|
1057
|
+
type: ViewChild,
|
|
1058
|
+
args: ['headerRow']
|
|
1059
|
+
}], headerSlot: [{
|
|
1060
|
+
type: ViewChild,
|
|
1061
|
+
args: ['headerSlot']
|
|
1062
|
+
}], footerSlot: [{
|
|
1063
|
+
type: ViewChild,
|
|
1064
|
+
args: ['footerSlot']
|
|
1065
|
+
}] }); })();
|
|
1066
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResponsiveAppShellDrawer, { className: "ResponsiveAppShellDrawer", filePath: "components/responsive-app-shell.component.ts", lineNumber: 685 }); })();
|
|
1067
|
+
/**
|
|
1068
|
+
* The shell's `<main>` landmark.
|
|
1069
|
+
*/
|
|
1070
|
+
export class ResponsiveAppShellContent {
|
|
1071
|
+
/** Extra classes on the `<main>`. */
|
|
1072
|
+
className;
|
|
1073
|
+
/** Inline styles on the `<main>`. */
|
|
1074
|
+
style;
|
|
1075
|
+
/** `data-mol-id` (default `shell-content`). */
|
|
1076
|
+
dataMolId = 'shell-content';
|
|
1077
|
+
/** `data-testid`. */
|
|
1078
|
+
testId;
|
|
1079
|
+
/**
|
|
1080
|
+
* The current class map.
|
|
1081
|
+
* @returns The UIClassMap.
|
|
1082
|
+
*/
|
|
1083
|
+
cm() {
|
|
1084
|
+
return getClassMap();
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* The main class list.
|
|
1088
|
+
* @returns The class string.
|
|
1089
|
+
*/
|
|
1090
|
+
classes() {
|
|
1091
|
+
return this.cm().cn(this.cm().flex1, this.className);
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* The main's inline style (`min-width: 0` plus the caller's style).
|
|
1095
|
+
* @returns The style attribute text.
|
|
1096
|
+
*/
|
|
1097
|
+
hostStyle() {
|
|
1098
|
+
return styleText({ minWidth: 0, ...this.style });
|
|
1099
|
+
}
|
|
1100
|
+
static ɵfac = function ResponsiveAppShellContent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ResponsiveAppShellContent)(); };
|
|
1101
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ResponsiveAppShellContent, selectors: [["main", "mol-responsive-app-shell-content", ""]], hostVars: 6, hostBindings: function ResponsiveAppShellContent_HostBindings(rf, ctx) { if (rf & 2) {
|
|
1102
|
+
i0.ɵɵattribute("data-mol-id", ctx.dataMolId)("data-testid", ctx.testId);
|
|
1103
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
1104
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
1105
|
+
} }, inputs: { className: "className", style: "style", dataMolId: "dataMolId", testId: "testId" }, ngContentSelectors: _c0, decls: 1, vars: 0, template: function ResponsiveAppShellContent_Template(rf, ctx) { if (rf & 1) {
|
|
1106
|
+
i0.ɵɵprojectionDef();
|
|
1107
|
+
i0.ɵɵprojection(0);
|
|
1108
|
+
} }, encapsulation: 2 });
|
|
1109
|
+
}
|
|
1110
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ResponsiveAppShellContent, [{
|
|
1111
|
+
type: Component,
|
|
1112
|
+
args: [{
|
|
1113
|
+
selector: 'main[mol-responsive-app-shell-content]',
|
|
1114
|
+
standalone: true,
|
|
1115
|
+
inputs: ['className', 'style', 'dataMolId', 'testId'],
|
|
1116
|
+
host: {
|
|
1117
|
+
'[class]': 'classes()',
|
|
1118
|
+
'[style]': 'hostStyle()',
|
|
1119
|
+
'[attr.data-mol-id]': 'dataMolId',
|
|
1120
|
+
'[attr.data-testid]': 'testId',
|
|
1121
|
+
},
|
|
1122
|
+
template: `<ng-content></ng-content>`,
|
|
1123
|
+
}]
|
|
1124
|
+
}], null, null); })();
|
|
1125
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ResponsiveAppShellContent, { className: "ResponsiveAppShellContent", filePath: "components/responsive-app-shell.component.ts", lineNumber: 1017 }); })();
|
|
1126
|
+
/**
|
|
1127
|
+
* The nearest shell context, or a safe default outside the shell.
|
|
1128
|
+
*
|
|
1129
|
+
* @param element - The reading element.
|
|
1130
|
+
* @returns The context.
|
|
1131
|
+
*/
|
|
1132
|
+
function contextOrDefault(element) {
|
|
1133
|
+
return (findDomContext(element) ?? {
|
|
1134
|
+
isDesktop: false,
|
|
1135
|
+
sidebarWidthPx: SIDEBAR_WIDTH_PX.md,
|
|
1136
|
+
drawerOpen: false,
|
|
1137
|
+
openDrawer: () => undefined,
|
|
1138
|
+
closeDrawer: () => undefined,
|
|
1139
|
+
drawerId: '',
|
|
1140
|
+
hasDrawer: false,
|
|
1141
|
+
registerDrawer: () => undefined,
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
//# sourceMappingURL=responsive-app-shell.component.js.map
|