@nanahoshi/mona-ui 0.24.10 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/chart/README.md +223 -77
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
- package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
- package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +1909 -666
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
- package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +146 -5
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
- package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +111 -5
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +100 -6
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +105 -5
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
- package/i18n/catalogs/en-US.messages.json +90 -5
- package/locales/ar-sa/ar-sa.messages.json +90 -5
- package/locales/de-de/de-de.messages.json +90 -5
- package/locales/es-es/es-es.messages.json +90 -5
- package/locales/fr-fr/fr-fr.messages.json +91 -6
- package/locales/id-id/id-id.messages.json +90 -5
- package/locales/it-it/it-it.messages.json +90 -5
- package/locales/ja-jp/ja-jp.messages.json +90 -5
- package/locales/ko-kr/ko-kr.messages.json +90 -5
- package/locales/pt-br/pt-br.messages.json +90 -5
- package/locales/ru-ru/ru-ru.messages.json +90 -5
- package/locales/tr-tr/tr-tr.messages.json +90 -5
- package/locales/zh-cn/zh-cn.messages.json +90 -5
- package/locales/zh-tw/zh-tw.messages.json +90 -5
- package/package.json +2 -1
- package/styles.css +156 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
- package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
- package/types/nanahoshi-mona-ui-button.d.ts +26 -3
- package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
- package/types/nanahoshi-mona-ui-card.d.ts +22 -6
- package/types/nanahoshi-mona-ui-chart.d.ts +519 -527
- package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
- package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
- package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
- package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
- package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-common.d.ts +28 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
- package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
- package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
- package/types/nanahoshi-mona-ui-i18n.d.ts +130 -3
- package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
- package/types/nanahoshi-mona-ui-label.d.ts +17 -2
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +85 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
- package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
- package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
- package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
- package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
- package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
- package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
- package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
- package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
- package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
- package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
- package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
- package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
- package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
- package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as i1 from '@angular/cdk/a11y';
|
|
2
2
|
import { CdkTrapFocus } from '@angular/cdk/a11y';
|
|
3
|
+
import { createBlockScrollStrategy } from '@angular/cdk/overlay';
|
|
3
4
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { signal, computed, Service, InjectionToken, inject, PLATFORM_ID, linkedSignal, effect, untracked, ElementRef, Injector, input, model,
|
|
5
|
+
import { signal, computed, Service, InjectionToken, inject, PLATFORM_ID, linkedSignal, effect, untracked, isDevMode, ApplicationRef, DestroyRef, DOCUMENT, ElementRef, Injector, input, model, afterRenderEffect, afterNextRender, Component, Directive, makeEnvironmentProviders } from '@angular/core';
|
|
5
6
|
import { classInputToClass } from '@nanahoshi/mona-ui/common';
|
|
6
|
-
import { injectComponentDirection } from '@nanahoshi/mona-ui/i18n';
|
|
7
|
+
import { injectComponentDirection, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
|
|
8
|
+
import { createElementControlId, themeRaisedBackdropClasses, inertOutside } from '@nanahoshi/mona-ui/internal';
|
|
9
|
+
import { TooltipDirective } from '@nanahoshi/mona-ui/tooltip';
|
|
7
10
|
import { twMerge } from 'tailwind-merge';
|
|
8
|
-
import { createElementControlId, themeRaisedBackdropClasses } from '@nanahoshi/mona-ui/internal';
|
|
9
11
|
import { isPlatformBrowser } from '@angular/common';
|
|
10
12
|
import { cva } from 'class-variance-authority';
|
|
11
13
|
import { SkeletonComponent } from '@nanahoshi/mona-ui/skeleton';
|
|
@@ -13,8 +15,26 @@ import * as i1$1 from '@nanahoshi/mona-ui/text-box';
|
|
|
13
15
|
import { TextBoxDirective } from '@nanahoshi/mona-ui/text-box';
|
|
14
16
|
import * as i1$2 from '@nanahoshi/mona-ui/button';
|
|
15
17
|
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
16
|
-
import {
|
|
18
|
+
import { COLLAPSIBLE_CONFIG, CollapsibleTriggerDirective } from '@nanahoshi/mona-ui/collapsible';
|
|
17
19
|
|
|
20
|
+
// Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
|
|
21
|
+
// Edit the JSON file and run `npm run generate:locale-catalogs`.
|
|
22
|
+
const SIDEBAR_DEFAULT_MESSAGES = {
|
|
23
|
+
drawerLabel: "Sidebar",
|
|
24
|
+
rail: "Toggle sidebar"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** The physical edge a sidebar sits against, for the styles that have to name one. */
|
|
28
|
+
function resolvePhysicalSide(direction, side) {
|
|
29
|
+
const isRtl = direction === "rtl";
|
|
30
|
+
if (side === "start") {
|
|
31
|
+
return isRtl ? "right" : "left";
|
|
32
|
+
}
|
|
33
|
+
return isRtl ? "left" : "right";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** `Node.DOCUMENT_POSITION_FOLLOWING`, written out because `Node` isn't a global on every server. */
|
|
37
|
+
const DOCUMENT_POSITION_FOLLOWING = 4;
|
|
18
38
|
/**
|
|
19
39
|
* Layout-wide state shared by every sidebar under one `mona-sidebar-layout`. Provided by
|
|
20
40
|
* `SidebarLayoutComponent`, while each `mona-sidebar` provides its own `SidebarService`.
|
|
@@ -33,6 +53,11 @@ class SidebarLayoutService {
|
|
|
33
53
|
...(ngDevMode ? [{ debugName: "#compact" }] : /* istanbul ignore next */ []));
|
|
34
54
|
this.#controllers = signal(new Map(), /* @ts-ignore */
|
|
35
55
|
...(ngDevMode ? [{ debugName: "#controllers" }] : /* istanbul ignore next */ []));
|
|
56
|
+
this.#elements = new WeakMap();
|
|
57
|
+
this.#modalScope = signal("page", /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "#modalScope" }] : /* istanbul ignore next */ []));
|
|
59
|
+
this.#holdingReturnFocus = false;
|
|
60
|
+
this.#returnFocusTo = null;
|
|
36
61
|
/**
|
|
37
62
|
* @description Whether any sidebar's drawer is open. The layout paints one backdrop for all of
|
|
38
63
|
* them, and the region beside them steps out of the way for whichever one is showing.
|
|
@@ -41,8 +66,10 @@ class SidebarLayoutService {
|
|
|
41
66
|
...(ngDevMode ? [{ debugName: "anyMobileOpen" }] : /* istanbul ignore next */ []));
|
|
42
67
|
/** @description Whether the viewport is narrow enough for sidebars to present as overlay drawers. */
|
|
43
68
|
this.compact = this.#compact.asReadonly();
|
|
69
|
+
/** @description How far an open drawer's modality reaches. Set by the `mona-sidebar-layout` it belongs to. */
|
|
70
|
+
this.modalScope = this.#modalScope.asReadonly();
|
|
44
71
|
/**
|
|
45
|
-
* @description The first sidebar
|
|
72
|
+
* @description The first sidebar in the layout, in author order.
|
|
46
73
|
*
|
|
47
74
|
* What the parts that sit beside the sidebars rather than inside one fall back to: a trigger in a
|
|
48
75
|
* shared header with no `for` set, and the inset's surface. Best effort by design — with more than
|
|
@@ -57,6 +84,10 @@ class SidebarLayoutService {
|
|
|
57
84
|
}
|
|
58
85
|
#compact;
|
|
59
86
|
#controllers;
|
|
87
|
+
#elements;
|
|
88
|
+
#modalScope;
|
|
89
|
+
#holdingReturnFocus;
|
|
90
|
+
#returnFocusTo;
|
|
60
91
|
/** Closes every open drawer. Backs the shared backdrop and the layout's Escape handling. */
|
|
61
92
|
closeAll() {
|
|
62
93
|
for (const controller of this.#controllers().values()) {
|
|
@@ -65,10 +96,31 @@ class SidebarLayoutService {
|
|
|
65
96
|
}
|
|
66
97
|
}
|
|
67
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* A controller for the sidebar named `id`, or for the layout's first one without an `id`. It follows that sidebar
|
|
101
|
+
* rather than holding it, because a component in the inset is created before the sidebars have registered, and
|
|
102
|
+
* reads as a closed sidebar while there is none.
|
|
103
|
+
*/
|
|
104
|
+
controllerFor(id) {
|
|
105
|
+
const target = computed(() => (id ? this.getController(id) : this.primaryController()), /* @ts-ignore */
|
|
106
|
+
...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
107
|
+
return this.#followingController(target);
|
|
108
|
+
}
|
|
68
109
|
/** @description The sidebar registered under `id`, or `null` when no sidebar answers to it. */
|
|
69
110
|
getController(id) {
|
|
70
111
|
return this.#controllers().get(id) ?? null;
|
|
71
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Records where focus goes when the drawers are done. Only the first drawer's opener counts: a drawer opened from
|
|
115
|
+
* inside another one would otherwise send focus back into a panel that has closed.
|
|
116
|
+
*/
|
|
117
|
+
holdReturnFocus(element) {
|
|
118
|
+
if (this.#holdingReturnFocus) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.#holdingReturnFocus = true;
|
|
122
|
+
this.#returnFocusTo = element;
|
|
123
|
+
}
|
|
72
124
|
/**
|
|
73
125
|
* Closes any other open drawer, so only one is ever showing. Called by a sidebar as it opens its
|
|
74
126
|
* own: two drawers overlaying the same layout would stack their backdrops and fight over the focus
|
|
@@ -88,9 +140,12 @@ class SidebarLayoutService {
|
|
|
88
140
|
* Two sidebars sharing an id collide here, and the later registration wins. That is a mistake in
|
|
89
141
|
* the markup rather than something to recover from — ids are already required to be unique in a
|
|
90
142
|
* document — so it is left to the duplicate `id` attributes to surface it.
|
|
143
|
+
*
|
|
144
|
+
* Kept in document order, so a sidebar that renders late or changes its id doesn't become the primary one.
|
|
91
145
|
*/
|
|
92
|
-
register(id, controller) {
|
|
93
|
-
this.#
|
|
146
|
+
register(id, controller, element) {
|
|
147
|
+
this.#elements.set(controller, element);
|
|
148
|
+
this.#controllers.update(controllers => this.#inAuthorOrder(new Map(controllers).set(id, controller)));
|
|
94
149
|
return () => {
|
|
95
150
|
this.#controllers.update(controllers => {
|
|
96
151
|
// Only if this registration is still the current one. An id that has since been taken
|
|
@@ -104,10 +159,55 @@ class SidebarLayoutService {
|
|
|
104
159
|
});
|
|
105
160
|
};
|
|
106
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Hands over where focus goes, once the drawer that's closing was the last one open. A drawer closing because
|
|
164
|
+
* another one is opening hands over nothing, and that one takes the same place when it closes.
|
|
165
|
+
*/
|
|
166
|
+
releaseReturnFocus(closingId) {
|
|
167
|
+
for (const [id, controller] of this.#controllers()) {
|
|
168
|
+
if (id !== closingId && controller.mobileOpen()) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const element = this.#returnFocusTo;
|
|
173
|
+
this.#holdingReturnFocus = false;
|
|
174
|
+
this.#returnFocusTo = null;
|
|
175
|
+
return element;
|
|
176
|
+
}
|
|
107
177
|
/** @internal Published by `mona-sidebar-layout` from its breakpoint query. */
|
|
108
178
|
setCompact(compact) {
|
|
109
179
|
this.#compact.set(compact);
|
|
110
180
|
}
|
|
181
|
+
/** @internal Published by `mona-sidebar-layout` from its own input. */
|
|
182
|
+
setModalScope(scope) {
|
|
183
|
+
this.#modalScope.set(scope);
|
|
184
|
+
}
|
|
185
|
+
#followingController(target) {
|
|
186
|
+
return {
|
|
187
|
+
collapse: () => target()?.collapse(),
|
|
188
|
+
collapsible: computed(() => target()?.collapsible() ?? "offcanvas"),
|
|
189
|
+
compact: this.compact,
|
|
190
|
+
expand: () => target()?.expand(),
|
|
191
|
+
expanded: computed(() => target()?.expanded() ?? false),
|
|
192
|
+
iconOnly: computed(() => target()?.iconOnly() ?? false),
|
|
193
|
+
mobileOpen: computed(() => target()?.mobileOpen() ?? false),
|
|
194
|
+
side: computed(() => target()?.side() ?? "start"),
|
|
195
|
+
sidebarId: computed(() => target()?.sidebarId() ?? ""),
|
|
196
|
+
state: computed(() => target()?.state() ?? "collapsed"),
|
|
197
|
+
toggle: () => target()?.toggle(),
|
|
198
|
+
variant: computed(() => target()?.variant() ?? "sidebar")
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
#inAuthorOrder(controllers) {
|
|
202
|
+
return new Map([...controllers].sort(([, first], [, second]) => {
|
|
203
|
+
const firstElement = this.#elements.get(first);
|
|
204
|
+
const secondElement = this.#elements.get(second);
|
|
205
|
+
if (!firstElement || !secondElement || firstElement === secondElement) {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
return firstElement.compareDocumentPosition(secondElement) & DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
111
211
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarLayoutService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
112
212
|
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.6", ngImport: i0, type: SidebarLayoutService, autoProvided: false }); }
|
|
113
213
|
}
|
|
@@ -144,7 +244,11 @@ class LocalStorageSidebarStorage {
|
|
|
144
244
|
}
|
|
145
245
|
try {
|
|
146
246
|
const stored = localStorage.getItem(key);
|
|
147
|
-
|
|
247
|
+
// Anything else isn't this sidebar's, such as another feature's entry under the same key.
|
|
248
|
+
if (stored === "true") {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
return stored === "false" ? false : null;
|
|
148
252
|
}
|
|
149
253
|
catch {
|
|
150
254
|
return null;
|
|
@@ -198,17 +302,19 @@ class SidebarService {
|
|
|
198
302
|
#expanded;
|
|
199
303
|
#generatedId;
|
|
200
304
|
#layoutService;
|
|
201
|
-
#persistKey;
|
|
202
|
-
#providedId;
|
|
203
|
-
#side;
|
|
204
|
-
#storage;
|
|
205
|
-
#variant;
|
|
206
305
|
/**
|
|
207
306
|
* Reset every time the viewport crosses the breakpoint. A drawer left open on a phone must not
|
|
208
307
|
* still count as open when the window is widened back to a desktop layout, where the same flag
|
|
209
308
|
* would be read as the docked sidebar's state.
|
|
210
309
|
*/
|
|
211
310
|
#mobileOpen;
|
|
311
|
+
#persistKey;
|
|
312
|
+
#providedId;
|
|
313
|
+
#side;
|
|
314
|
+
#storage;
|
|
315
|
+
#variant;
|
|
316
|
+
/** What storage holds as far as this service knows, so only a change is written. */
|
|
317
|
+
#syncedExpanded;
|
|
212
318
|
constructor() {
|
|
213
319
|
this.#collapsible = signal("offcanvas", /* @ts-ignore */
|
|
214
320
|
...(ngDevMode ? [{ debugName: "#collapsible" }] : /* istanbul ignore next */ []));
|
|
@@ -223,6 +329,13 @@ class SidebarService {
|
|
|
223
329
|
...(ngDevMode ? [{ debugName: "#expanded" }] : /* istanbul ignore next */ []));
|
|
224
330
|
this.#generatedId = createElementControlId();
|
|
225
331
|
this.#layoutService = inject(SidebarLayoutService, { optional: true });
|
|
332
|
+
/**
|
|
333
|
+
* Reset every time the viewport crosses the breakpoint. A drawer left open on a phone must not
|
|
334
|
+
* still count as open when the window is widened back to a desktop layout, where the same flag
|
|
335
|
+
* would be read as the docked sidebar's state.
|
|
336
|
+
*/
|
|
337
|
+
this.#mobileOpen = linkedSignal({ ...(ngDevMode ? { debugName: "#mobileOpen" } : /* istanbul ignore next */ {}), source: () => this.#compact(),
|
|
338
|
+
computation: () => false });
|
|
226
339
|
this.#persistKey = signal("", /* @ts-ignore */
|
|
227
340
|
...(ngDevMode ? [{ debugName: "#persistKey" }] : /* istanbul ignore next */ []));
|
|
228
341
|
this.#providedId = signal(null, /* @ts-ignore */
|
|
@@ -232,13 +345,8 @@ class SidebarService {
|
|
|
232
345
|
this.#storage = inject(SIDEBAR_STORAGE);
|
|
233
346
|
this.#variant = signal("sidebar", /* @ts-ignore */
|
|
234
347
|
...(ngDevMode ? [{ debugName: "#variant" }] : /* istanbul ignore next */ []));
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
* still count as open when the window is widened back to a desktop layout, where the same flag
|
|
238
|
-
* would be read as the docked sidebar's state.
|
|
239
|
-
*/
|
|
240
|
-
this.#mobileOpen = linkedSignal({ ...(ngDevMode ? { debugName: "#mobileOpen" } : /* istanbul ignore next */ {}), source: () => this.#compact(),
|
|
241
|
-
computation: () => false });
|
|
348
|
+
/** What storage holds as far as this service knows, so only a change is written. */
|
|
349
|
+
this.#syncedExpanded = null;
|
|
242
350
|
/** @description How the sidebar behaves when collapsed. Set by the `mona-sidebar` it belongs to. */
|
|
243
351
|
this.collapsible = this.#collapsible.asReadonly();
|
|
244
352
|
/** @description Whether the sidebar presents as an overlay drawer rather than as a column. */
|
|
@@ -278,7 +386,6 @@ class SidebarService {
|
|
|
278
386
|
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
279
387
|
/** @description The visual treatment of the sidebar. Set by the `mona-sidebar` it belongs to. */
|
|
280
388
|
this.variant = this.#variant.asReadonly();
|
|
281
|
-
/** @description The subset of this service that is safe to hand to a consumer. */
|
|
282
389
|
this.controller = {
|
|
283
390
|
collapse: () => this.collapse(),
|
|
284
391
|
collapsible: this.collapsible,
|
|
@@ -294,18 +401,19 @@ class SidebarService {
|
|
|
294
401
|
variant: this.variant
|
|
295
402
|
};
|
|
296
403
|
// Restore before persist, so the first pass cannot write the default back over what was
|
|
297
|
-
// stored
|
|
298
|
-
// consumer asked for one.
|
|
404
|
+
// stored, or over something under that key this storage can't read. Both sit idle until
|
|
405
|
+
// `mona-sidebar` publishes a key, which it only does when the consumer asked for one.
|
|
299
406
|
effect(() => {
|
|
300
407
|
const key = this.#persistKey();
|
|
301
408
|
if (!key) {
|
|
302
409
|
return;
|
|
303
410
|
}
|
|
304
411
|
untracked(() => {
|
|
305
|
-
const stored = this.#
|
|
412
|
+
const stored = this.#readStored(key);
|
|
306
413
|
if (stored !== null) {
|
|
307
414
|
this.#expanded.set(stored);
|
|
308
415
|
}
|
|
416
|
+
this.#syncedExpanded = this.#expanded();
|
|
309
417
|
});
|
|
310
418
|
});
|
|
311
419
|
/*
|
|
@@ -319,7 +427,12 @@ class SidebarService {
|
|
|
319
427
|
if (!key) {
|
|
320
428
|
return;
|
|
321
429
|
}
|
|
322
|
-
untracked(() =>
|
|
430
|
+
untracked(() => {
|
|
431
|
+
if (expanded !== this.#syncedExpanded) {
|
|
432
|
+
this.#syncedExpanded = expanded;
|
|
433
|
+
this.#writeStored(key, expanded);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
323
436
|
});
|
|
324
437
|
}
|
|
325
438
|
collapse() {
|
|
@@ -370,6 +483,29 @@ class SidebarService {
|
|
|
370
483
|
toggle() {
|
|
371
484
|
this.setExpanded(!this.expanded());
|
|
372
485
|
}
|
|
486
|
+
/** A custom storage that throws shouldn't take the sidebar down: it opens as its input says. */
|
|
487
|
+
#readStored(key) {
|
|
488
|
+
try {
|
|
489
|
+
return this.#storage.read(key);
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
this.#reportStorageError(error);
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
#reportStorageError(error) {
|
|
497
|
+
if (isDevMode()) {
|
|
498
|
+
console.error("mona-sidebar: the sidebar storage threw.", error);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
#writeStored(key, expanded) {
|
|
502
|
+
try {
|
|
503
|
+
this.#storage.write(key, expanded);
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
this.#reportStorageError(error);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
373
509
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarService, deps: [], target: i0.ɵɵFactoryTarget.Service }); }
|
|
374
510
|
static { this.ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.0.6", ngImport: i0, type: SidebarService, autoProvided: false }); }
|
|
375
511
|
}
|
|
@@ -567,22 +703,27 @@ const sidebarMenuButtonThemeVariants = cva(`
|
|
|
567
703
|
flex w-full items-center justify-start overflow-hidden
|
|
568
704
|
rounded-md border-0 bg-transparent
|
|
569
705
|
text-start text-sm font-normal whitespace-nowrap no-underline
|
|
570
|
-
outline-
|
|
571
|
-
focus-visible:ring-2 focus-visible:ring-(--color-sidebar-ring)/60
|
|
706
|
+
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--color-sidebar-ring)
|
|
572
707
|
[&>*:first-child]:shrink-0 [&>svg]:shrink-0
|
|
573
708
|
[transition:gap_var(--mona-motion-standard)_ease-out,height_var(--mona-motion-standard)_ease-out,padding_var(--mona-motion-standard)_ease-out,background-color_100ms_ease-in-out,color_100ms_ease-in-out]
|
|
574
709
|
motion-reduce:[transition:none]
|
|
575
710
|
`, {
|
|
576
711
|
variants: {
|
|
577
712
|
active: {
|
|
578
|
-
|
|
713
|
+
// The bar and the weight say it without color, as the fill is faint against the sidebar and
|
|
714
|
+
// forced colors drop it altogether.
|
|
715
|
+
true: `
|
|
716
|
+
relative font-medium text-(--color-sidebar-primary-foreground)
|
|
717
|
+
before:absolute before:inset-y-1 before:start-0 before:w-0.5 before:rounded-full before:bg-current
|
|
718
|
+
forced-colors:before:forced-color-adjust-none forced-colors:before:bg-[Highlight]
|
|
719
|
+
`,
|
|
579
720
|
false: `
|
|
580
721
|
text-(--color-sidebar-foreground)
|
|
581
722
|
hover:bg-(--color-sidebar-accent) hover:text-(--color-sidebar-accent-foreground)
|
|
582
723
|
`
|
|
583
724
|
},
|
|
584
725
|
disabled: {
|
|
585
|
-
true: "opacity-50 pointer-events-none cursor-default",
|
|
726
|
+
true: "opacity-50 pointer-events-none cursor-default forced-colors:text-[GrayText]",
|
|
586
727
|
false: "cursor-pointer"
|
|
587
728
|
},
|
|
588
729
|
iconOnly: {
|
|
@@ -655,6 +796,7 @@ const sidebarThemeVariants = cva(`
|
|
|
655
796
|
drawer: {
|
|
656
797
|
true: `
|
|
657
798
|
absolute inset-y-0 z-50 h-full m-0
|
|
799
|
+
max-w-[calc(100%-3rem)] outline-none focus-visible:outline-hidden
|
|
658
800
|
shadow-(--shadow-overlay)
|
|
659
801
|
transition-[translate] duration-(--mona-motion-standard) ease-out
|
|
660
802
|
motion-reduce:transition-none
|
|
@@ -718,11 +860,15 @@ const sidebarMenuBadgeThemeVariants = cva(`
|
|
|
718
860
|
const sidebarRailThemeVariants = cva(`
|
|
719
861
|
absolute inset-y-0 z-20 hidden w-1
|
|
720
862
|
cursor-pointer
|
|
721
|
-
transition-colors hover:bg-(--color-sidebar-border)
|
|
863
|
+
transition-colors motion-reduce:transition-none hover:bg-(--color-sidebar-border)
|
|
722
864
|
focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-(--color-sidebar-ring)
|
|
723
|
-
sm:flex
|
|
724
865
|
`, {
|
|
725
866
|
variants: {
|
|
867
|
+
// The breakpoint that makes a drawer is the layout's to set, so `sm` alone can't keep it out of one.
|
|
868
|
+
compact: {
|
|
869
|
+
true: "",
|
|
870
|
+
false: "sm:flex"
|
|
871
|
+
},
|
|
726
872
|
// The rail sits on the sidebar's inner edge, which is the opposite one to the physical side it is
|
|
727
873
|
// docked against.
|
|
728
874
|
physicalSide: {
|
|
@@ -731,6 +877,7 @@ const sidebarRailThemeVariants = cva(`
|
|
|
731
877
|
}
|
|
732
878
|
},
|
|
733
879
|
defaultVariants: {
|
|
880
|
+
compact: false,
|
|
734
881
|
physicalSide: "left"
|
|
735
882
|
}
|
|
736
883
|
});
|
|
@@ -747,42 +894,57 @@ const sidebarSeparatorThemeVariants = cva(`
|
|
|
747
894
|
}
|
|
748
895
|
});
|
|
749
896
|
|
|
897
|
+
/** What stays usable or looks after itself beside an open drawer: the backdrop, other sidebars and the focus trap's stops. */
|
|
898
|
+
const keepBesideDrawer = (element) => element.localName === "mona-sidebar" ||
|
|
899
|
+
element.hasAttribute("data-sidebar-backdrop") ||
|
|
900
|
+
element.classList.contains("cdk-focus-trap-anchor");
|
|
901
|
+
const railTooltipTextOf = (element) => element.getAttribute("data-sidebar-tooltip") ?? "";
|
|
902
|
+
/** Where a part of the sidebar has gone out of reach while it collapses. */
|
|
903
|
+
const OUT_OF_REACH_SELECTOR = "[inert], [data-hidden='true']";
|
|
750
904
|
/**
|
|
751
905
|
* @description
|
|
752
906
|
* The sidebar region itself. Content is projected in author order, so header, content and footer
|
|
753
907
|
* parts appear exactly where they are written.
|
|
754
908
|
*
|
|
755
909
|
* Below the layout's `mobileBreakpoint` it presents as a modal overlay drawer: focus is trapped
|
|
756
|
-
* inside it while open, restored to whatever opened it on close, and
|
|
757
|
-
* inert. It is not a navigation landmark by itself — wrap
|
|
758
|
-
* `role` and `
|
|
910
|
+
* inside it while open, restored to whatever opened it on close, and everything outside it is made
|
|
911
|
+
* inert, as far as the layout's `modalScope` says. It is not a navigation landmark by itself — wrap
|
|
912
|
+
* the menus in a labelled `nav`, or set `role` and `aria-label` if the whole region is navigation.
|
|
759
913
|
*/
|
|
760
914
|
class SidebarComponent {
|
|
915
|
+
#appRef;
|
|
916
|
+
#destroyRef;
|
|
761
917
|
#direction;
|
|
918
|
+
#document;
|
|
762
919
|
#focusTrap;
|
|
763
920
|
#host;
|
|
921
|
+
#i18n;
|
|
764
922
|
#injector;
|
|
765
923
|
#layoutService;
|
|
924
|
+
#messages;
|
|
766
925
|
#sidebarService;
|
|
767
|
-
#
|
|
926
|
+
#focusTrapped;
|
|
768
927
|
constructor() {
|
|
928
|
+
this.#appRef = inject(ApplicationRef);
|
|
929
|
+
this.#destroyRef = inject(DestroyRef);
|
|
769
930
|
this.#direction = injectComponentDirection();
|
|
931
|
+
this.#document = inject(DOCUMENT);
|
|
770
932
|
this.#focusTrap = inject(CdkTrapFocus);
|
|
771
933
|
this.#host = inject(ElementRef);
|
|
934
|
+
this.#i18n = inject(MonaI18nService);
|
|
772
935
|
this.#injector = inject(Injector);
|
|
773
936
|
this.#layoutService = inject(SidebarLayoutService, { optional: true });
|
|
937
|
+
this.#messages = this.#i18n.componentMessages("sidebar", SIDEBAR_DEFAULT_MESSAGES);
|
|
774
938
|
this.#sidebarService = inject(SidebarService);
|
|
775
|
-
this.#
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
return isRtl ? "right" : "left";
|
|
939
|
+
this.#focusTrapped = false;
|
|
940
|
+
/** Only while there's a role to name. On a plain element a label means nothing, and axe reports it. */
|
|
941
|
+
this.accessibleName = computed(() => {
|
|
942
|
+
if (!this.resolvedRole()) {
|
|
943
|
+
return null;
|
|
781
944
|
}
|
|
782
|
-
return
|
|
945
|
+
return this.ariaLabel() || (this.drawer() && !this.ariaLabelledBy() ? this.#messages().drawerLabel : null);
|
|
783
946
|
}, /* @ts-ignore */
|
|
784
|
-
...(ngDevMode ? [{ debugName: "
|
|
785
|
-
this.drawerPhysicalSide = this.physicalSide;
|
|
947
|
+
...(ngDevMode ? [{ debugName: "accessibleName" }] : /* istanbul ignore next */ []));
|
|
786
948
|
this.baseClass = computed(() => {
|
|
787
949
|
const variantClass = sidebarThemeVariants({
|
|
788
950
|
drawer: this.drawer(),
|
|
@@ -796,8 +958,6 @@ class SidebarComponent {
|
|
|
796
958
|
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
797
959
|
/** The compact presentation: an overlay pinned to one edge rather than a column in the flow. */
|
|
798
960
|
this.drawer = this.#sidebarService.compact;
|
|
799
|
-
/** Published rather than the raw input, so a `left`/`right` alias still reports as `start`/`end`. */
|
|
800
|
-
this.logicalSide = this.#sidebarService.side;
|
|
801
961
|
/**
|
|
802
962
|
* Whether the panel is out of view entirely. The icon rail does not count — it is still on screen
|
|
803
963
|
* and still operable — but a closed drawer and a fully collapsed off-canvas sidebar both do.
|
|
@@ -809,8 +969,19 @@ class SidebarComponent {
|
|
|
809
969
|
return this.offCanvasClosed();
|
|
810
970
|
}, /* @ts-ignore */
|
|
811
971
|
...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
|
|
972
|
+
this.iconOnly = this.#sidebarService.iconOnly;
|
|
973
|
+
/** Published rather than the raw input, so a `left`/`right` alias still reports as `start`/`end`. */
|
|
974
|
+
this.logicalSide = this.#sidebarService.side;
|
|
975
|
+
/** A drawer scoped to its layout leaves what's around that usable, so it can't claim to be modal. */
|
|
976
|
+
this.modal = computed(() => this.drawer() && (this.#layoutService?.modalScope() ?? "page") === "page", /* @ts-ignore */
|
|
977
|
+
...(ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []));
|
|
812
978
|
this.offCanvasClosed = computed(() => !this.drawer() && !this.#sidebarService.expanded() && this.collapsible() === "offcanvas", /* @ts-ignore */
|
|
813
979
|
...(ngDevMode ? [{ debugName: "offCanvasClosed" }] : /* istanbul ignore next */ []));
|
|
980
|
+
this.physicalSide = computed(() => resolvePhysicalSide(this.#direction(), this.#sidebarService.side()), /* @ts-ignore */
|
|
981
|
+
...(ngDevMode ? [{ debugName: "physicalSide" }] : /* istanbul ignore next */ []));
|
|
982
|
+
this.railOpensToward = computed(() => (this.#sidebarService.side() === "start" ? "end" : "start"), /* @ts-ignore */
|
|
983
|
+
...(ngDevMode ? [{ debugName: "railOpensToward" }] : /* istanbul ignore next */ []));
|
|
984
|
+
this.railTooltipText = railTooltipTextOf;
|
|
814
985
|
/** A drawer is a modal surface; a docked sidebar keeps whatever role the consumer gave it. */
|
|
815
986
|
this.resolvedRole = computed(() => (this.drawer() ? "dialog" : this.role() || null), /* @ts-ignore */
|
|
816
987
|
...(ngDevMode ? [{ debugName: "resolvedRole" }] : /* istanbul ignore next */ []));
|
|
@@ -825,7 +996,9 @@ class SidebarComponent {
|
|
|
825
996
|
this.widthString = computed(() => {
|
|
826
997
|
// A drawer is always at full width; it is moved out of view rather than shrunk.
|
|
827
998
|
if (this.drawer()) {
|
|
828
|
-
|
|
999
|
+
const width = toCssLength(this.mobileWidth());
|
|
1000
|
+
// The `sidebar` variant's edge border belongs to its docked form, so its drawer has nothing to allow for.
|
|
1001
|
+
return this.variant() === "sidebar" ? width : this.#withBorderAllowance(width);
|
|
829
1002
|
}
|
|
830
1003
|
if (this.#sidebarService.expanded()) {
|
|
831
1004
|
return this.#withBorderAllowance(toCssLength(this.width()));
|
|
@@ -836,10 +1009,16 @@ class SidebarComponent {
|
|
|
836
1009
|
...(ngDevMode ? [{ debugName: "widthString" }] : /* istanbul ignore next */ []));
|
|
837
1010
|
/**
|
|
838
1011
|
* @description Accessible name for the sidebar region. Required when `role` is set, and used as the
|
|
839
|
-
* drawer's name on compact viewports.
|
|
1012
|
+
* drawer's name on compact viewports, which otherwise has a localized default.
|
|
840
1013
|
* @default ""
|
|
841
1014
|
*/
|
|
842
1015
|
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
1016
|
+
/**
|
|
1017
|
+
* @description The id of the element that names the sidebar region, in place of `aria-label`. A docked sidebar with no
|
|
1018
|
+
* `role` ignores it.
|
|
1019
|
+
* @default ""
|
|
1020
|
+
*/
|
|
1021
|
+
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
843
1022
|
/**
|
|
844
1023
|
* @description How the sidebar behaves when collapsed. `"icon"` keeps a narrow rail of icons visible,
|
|
845
1024
|
* `"offcanvas"` removes it from the layout entirely, and `"none"` disables collapsing altogether.
|
|
@@ -849,7 +1028,8 @@ class SidebarComponent {
|
|
|
849
1028
|
...(ngDevMode ? [{ debugName: "collapsible" }] : /* istanbul ignore next */ []));
|
|
850
1029
|
/**
|
|
851
1030
|
* @description Sets whether this sidebar is open. Supports two-way binding. While the viewport is
|
|
852
|
-
* compact this reflects the drawer, so one binding drives both presentations
|
|
1031
|
+
* compact this reflects the drawer, so one binding drives both presentations, and it reads `false` on
|
|
1032
|
+
* a phone from the start. To remember the docked state, use `persistKey` rather than saving this.
|
|
853
1033
|
* @default true
|
|
854
1034
|
*/
|
|
855
1035
|
this.expanded = model(true, /* @ts-ignore */
|
|
@@ -956,32 +1136,71 @@ class SidebarComponent {
|
|
|
956
1136
|
return;
|
|
957
1137
|
}
|
|
958
1138
|
const id = this.#sidebarService.sidebarId();
|
|
959
|
-
onCleanup(layoutService.register(id, this.#sidebarService.controller));
|
|
1139
|
+
onCleanup(layoutService.register(id, this.#sidebarService.controller, this.#host.nativeElement));
|
|
960
1140
|
});
|
|
961
1141
|
effect(() => {
|
|
962
1142
|
const trapped = this.drawer() && this.#sidebarService.mobileOpen();
|
|
963
1143
|
untracked(() => this.#setFocusTrapped(trapped));
|
|
964
1144
|
});
|
|
1145
|
+
effect(onCleanup => {
|
|
1146
|
+
if (!this.drawer() || !this.#sidebarService.mobileOpen()) {
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
const modal = this.modal();
|
|
1150
|
+
onCleanup(untracked(() => this.#holdOutside(modal)));
|
|
1151
|
+
});
|
|
1152
|
+
// After the render that takes the part away, and before the browser moves focus to the body because of it.
|
|
1153
|
+
afterRenderEffect(() => {
|
|
1154
|
+
const expanded = this.#sidebarService.expanded();
|
|
1155
|
+
untracked(() => {
|
|
1156
|
+
if (!expanded && !this.drawer()) {
|
|
1157
|
+
this.#moveFocusOutOfCollapsedPart();
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
});
|
|
1161
|
+
afterNextRender(() => this.#warnWithoutName());
|
|
1162
|
+
this.#destroyRef.onDestroy(() => {
|
|
1163
|
+
if (this.#focusTrapped) {
|
|
1164
|
+
const restoreTo = this.#layoutService?.releaseReturnFocus(this.#sidebarService.sidebarId());
|
|
1165
|
+
if (restoreTo) {
|
|
1166
|
+
this.#returnFocus(restoreTo, this.#appRef.injector);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
/** Makes everything outside the open drawer inert, up to the layout or across the page, and returns the undo. */
|
|
1172
|
+
#holdOutside(modal) {
|
|
1173
|
+
const host = this.#host.nativeElement;
|
|
1174
|
+
const release = inertOutside(host, {
|
|
1175
|
+
keep: keepBesideDrawer,
|
|
1176
|
+
stopAt: modal ? null : host.closest("mona-sidebar-layout")
|
|
1177
|
+
});
|
|
1178
|
+
if (!modal) {
|
|
1179
|
+
return release;
|
|
1180
|
+
}
|
|
1181
|
+
const scroll = createBlockScrollStrategy(this.#injector);
|
|
1182
|
+
scroll.enable();
|
|
1183
|
+
return () => {
|
|
1184
|
+
release();
|
|
1185
|
+
scroll.disable();
|
|
1186
|
+
};
|
|
965
1187
|
}
|
|
966
1188
|
/**
|
|
967
|
-
*
|
|
968
|
-
*
|
|
1189
|
+
* Collapsing takes the panel, or a part of it that doesn't fit the rail, away from under focus. It goes to a
|
|
1190
|
+
* trigger for this sidebar, or to the rail, rather than falling to the body.
|
|
969
1191
|
*/
|
|
970
|
-
#
|
|
971
|
-
this.#
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
this.#restoreFocusTo = active instanceof HTMLElement ? active : null;
|
|
975
|
-
this.#focusTrap.focusTrap.focusInitialElementWhenReady();
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
const restoreTo = this.#restoreFocusTo;
|
|
979
|
-
this.#restoreFocusTo = null;
|
|
980
|
-
// Only pull focus back if it is still inside the panel that is closing. Moving it otherwise
|
|
981
|
-
// would yank the caret away from wherever the user has since gone.
|
|
982
|
-
if (!restoreTo || !this.#host.nativeElement.contains(document.activeElement)) {
|
|
1192
|
+
#moveFocusOutOfCollapsedPart() {
|
|
1193
|
+
const host = this.#host.nativeElement;
|
|
1194
|
+
const active = this.#document.activeElement;
|
|
1195
|
+
if (!active || !host.contains(active) || !active.closest(OUT_OF_REACH_SELECTOR)) {
|
|
983
1196
|
return;
|
|
984
1197
|
}
|
|
1198
|
+
const id = this.#sidebarService.sidebarId();
|
|
1199
|
+
const candidates = Array.from(this.#document.querySelectorAll("[aria-controls]")).filter(element => element.getAttribute("aria-controls") === id && !element.closest(OUT_OF_REACH_SELECTOR));
|
|
1200
|
+
const target = candidates.find(element => !element.hasAttribute("monaSidebarRail")) ?? candidates[0];
|
|
1201
|
+
target?.focus({ preventScroll: true });
|
|
1202
|
+
}
|
|
1203
|
+
#returnFocus(element, injector) {
|
|
985
1204
|
/*
|
|
986
1205
|
* Deferred to the next render, not called here. Whatever opened the drawer is almost always
|
|
987
1206
|
* behind it, and the region behind it is still `inert` at this point in the change detection
|
|
@@ -989,10 +1208,48 @@ class SidebarComponent {
|
|
|
989
1208
|
* stranded inside the panel that was about to become inert itself.
|
|
990
1209
|
*/
|
|
991
1210
|
afterNextRender(() => {
|
|
992
|
-
if (
|
|
993
|
-
|
|
1211
|
+
if (element.isConnected) {
|
|
1212
|
+
element.focus();
|
|
994
1213
|
}
|
|
995
|
-
}, { injector
|
|
1214
|
+
}, { injector });
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* The trap is only armed for the drawer. A docked sidebar sits in the page beside its content, and
|
|
1218
|
+
* holding focus inside it would leave the keyboard unable to reach the rest of the layout at all.
|
|
1219
|
+
*/
|
|
1220
|
+
#setFocusTrapped(trapped) {
|
|
1221
|
+
const wasTrapped = this.#focusTrapped;
|
|
1222
|
+
this.#focusTrapped = trapped;
|
|
1223
|
+
this.#focusTrap.enabled = trapped;
|
|
1224
|
+
const host = this.#host.nativeElement;
|
|
1225
|
+
if (trapped) {
|
|
1226
|
+
const active = this.#document.activeElement;
|
|
1227
|
+
this.#layoutService?.holdReturnFocus(active instanceof HTMLElement ? active : null);
|
|
1228
|
+
void this.#focusTrap.focusTrap.focusInitialElementWhenReady().then(found => {
|
|
1229
|
+
const current = this.#document.activeElement;
|
|
1230
|
+
const unmoved = current === active || !current || current === this.#document.body;
|
|
1231
|
+
if (!found && unmoved && this.#focusTrapped) {
|
|
1232
|
+
host.focus({ preventScroll: true });
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if (!wasTrapped) {
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
const restoreTo = this.#layoutService?.releaseReturnFocus(this.#sidebarService.sidebarId());
|
|
1241
|
+
const active = this.#document.activeElement;
|
|
1242
|
+
// A press on the backdrop leaves focus on the body, which is focus lost rather than focus moved. Pulling it
|
|
1243
|
+
// back from anywhere else would yank the caret away from wherever the user has since gone.
|
|
1244
|
+
const lost = !active || active === this.#document.body;
|
|
1245
|
+
if (restoreTo && (lost || host.contains(active))) {
|
|
1246
|
+
this.#returnFocus(restoreTo, this.#injector);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
#warnWithoutName() {
|
|
1250
|
+
if (isDevMode() && this.role() && !this.ariaLabel() && !this.ariaLabelledBy()) {
|
|
1251
|
+
console.warn(`mona-sidebar: role="${this.role()}" needs a name. Set aria-label or aria-labelledby.`);
|
|
1252
|
+
}
|
|
996
1253
|
}
|
|
997
1254
|
#withBorderAllowance(width) {
|
|
998
1255
|
const allowance = sidebarBorderAllowance[this.variant()];
|
|
@@ -1000,19 +1257,44 @@ class SidebarComponent {
|
|
|
1000
1257
|
return allowance === "0px" ? width : `calc(${width} + ${allowance})`;
|
|
1001
1258
|
}
|
|
1002
1259
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1003
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: SidebarComponent, isStandalone: true, selector: "mona-sidebar", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, collapsible: { classPropertyName: "collapsible", publicName: "collapsible", isSignal: true, isRequired: false, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null }, iconWidth: { classPropertyName: "iconWidth", publicName: "iconWidth", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, mobileWidth: { classPropertyName: "mobileWidth", publicName: "mobileWidth", isSignal: true, isRequired: false, transformFunction: null }, persistKey: { classPropertyName: "persistKey", publicName: "persistKey", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { properties: { "attr.aria-hidden": "hidden() ? 'true' : null", "attr.aria-label": "
|
|
1260
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.6", type: SidebarComponent, isStandalone: true, selector: "mona-sidebar", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, collapsible: { classPropertyName: "collapsible", publicName: "collapsible", isSignal: true, isRequired: false, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null }, iconWidth: { classPropertyName: "iconWidth", publicName: "iconWidth", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, mobileWidth: { classPropertyName: "mobileWidth", publicName: "mobileWidth", isSignal: true, isRequired: false, transformFunction: null }, persistKey: { classPropertyName: "persistKey", publicName: "persistKey", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { properties: { "attr.aria-hidden": "hidden() ? 'true' : null", "attr.aria-label": "accessibleName()", "attr.aria-labelledby": "resolvedRole() ? ariaLabelledBy() || null : null", "attr.aria-modal": "modal() ? 'true' : null", "attr.data-collapsible": "collapsible()", "attr.data-side": "logicalSide()", "attr.data-state": "state()", "attr.data-variant": "variant()", "attr.id": "sidebarId()", "attr.inert": "hidden() ? '' : null", "attr.role": "resolvedRole()", "attr.tabindex": "drawer() ? -1 : null", "class": "baseClass()", "style.width": "widthString()" } }, providers: [SidebarService], hostDirectives: [{ directive: i1.CdkTrapFocus }], ngImport: i0, template: `
|
|
1261
|
+
<div
|
|
1262
|
+
class="contents"
|
|
1263
|
+
monaTooltip
|
|
1264
|
+
mode="content"
|
|
1265
|
+
filter="[data-sidebar-tooltip]"
|
|
1266
|
+
[contentOf]="railTooltipText"
|
|
1267
|
+
[disabled]="!iconOnly()"
|
|
1268
|
+
[position]="railOpensToward()">
|
|
1269
|
+
<ng-content></ng-content>
|
|
1270
|
+
</div>
|
|
1271
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: TooltipDirective, selector: "[monaTooltip]", inputs: ["contentOf", "disabled", "filter", "hideDelay", "mode", "monaTooltip", "position", "tooltipRounded", "showDelay"], outputs: ["hidden", "shown"] }] }); }
|
|
1004
1272
|
}
|
|
1005
1273
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarComponent, decorators: [{
|
|
1006
1274
|
type: Component,
|
|
1007
1275
|
args: [{
|
|
1008
1276
|
selector: "mona-sidebar",
|
|
1009
|
-
|
|
1010
|
-
|
|
1277
|
+
imports: [TooltipDirective],
|
|
1278
|
+
// One tooltip for every row on the rail, and off the rail it isn't listening for anything. `contents` keeps the
|
|
1279
|
+
// parts laid out by the panel, as if this element weren't here.
|
|
1280
|
+
template: `
|
|
1281
|
+
<div
|
|
1282
|
+
class="contents"
|
|
1283
|
+
monaTooltip
|
|
1284
|
+
mode="content"
|
|
1285
|
+
filter="[data-sidebar-tooltip]"
|
|
1286
|
+
[contentOf]="railTooltipText"
|
|
1287
|
+
[disabled]="!iconOnly()"
|
|
1288
|
+
[position]="railOpensToward()">
|
|
1289
|
+
<ng-content></ng-content>
|
|
1290
|
+
</div>
|
|
1291
|
+
`,
|
|
1011
1292
|
hostDirectives: [CdkTrapFocus],
|
|
1012
1293
|
host: {
|
|
1013
1294
|
"[attr.aria-hidden]": "hidden() ? 'true' : null",
|
|
1014
|
-
"[attr.aria-label]": "
|
|
1015
|
-
"[attr.aria-
|
|
1295
|
+
"[attr.aria-label]": "accessibleName()",
|
|
1296
|
+
"[attr.aria-labelledby]": "resolvedRole() ? ariaLabelledBy() || null : null",
|
|
1297
|
+
"[attr.aria-modal]": "modal() ? 'true' : null",
|
|
1016
1298
|
"[attr.data-collapsible]": "collapsible()",
|
|
1017
1299
|
"[attr.data-side]": "logicalSide()",
|
|
1018
1300
|
"[attr.data-state]": "state()",
|
|
@@ -1023,6 +1305,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1023
1305
|
// collapsed panel reachable by keyboard and readable by assistive technology.
|
|
1024
1306
|
"[attr.inert]": "hidden() ? '' : null",
|
|
1025
1307
|
"[attr.role]": "resolvedRole()",
|
|
1308
|
+
// Something for focus to land on when the drawer has no controls, or a press lands on blank space in it.
|
|
1309
|
+
"[attr.tabindex]": "drawer() ? -1 : null",
|
|
1026
1310
|
"[class]": "baseClass()",
|
|
1027
1311
|
"[style.width]": "widthString()"
|
|
1028
1312
|
},
|
|
@@ -1030,7 +1314,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1030
1314
|
// keeps its own side, width and open state. Descendants resolve the nearest one, which is theirs.
|
|
1031
1315
|
providers: [SidebarService]
|
|
1032
1316
|
}]
|
|
1033
|
-
}], ctorParameters: () => [], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], collapsible: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsible", required: false }] }], expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }], iconWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconWidth", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], mobileWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "mobileWidth", required: false }] }], persistKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "persistKey", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
|
|
1317
|
+
}], ctorParameters: () => [], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], collapsible: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsible", required: false }] }], expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }], iconWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconWidth", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], mobileWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "mobileWidth", required: false }] }], persistKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "persistKey", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
|
|
1034
1318
|
function toCssLength(value) {
|
|
1035
1319
|
return typeof value === "number" ? `${value}px` : value;
|
|
1036
1320
|
}
|
|
@@ -1082,21 +1366,23 @@ function getComposedAncestors(startElement) {
|
|
|
1082
1366
|
* closes any other, and they share the single backdrop this layout paints behind them.
|
|
1083
1367
|
*/
|
|
1084
1368
|
class SidebarLayoutComponent {
|
|
1369
|
+
#browserCssDirection;
|
|
1085
1370
|
#destroyRef;
|
|
1086
1371
|
#direction;
|
|
1372
|
+
#document;
|
|
1087
1373
|
#host;
|
|
1088
1374
|
#layoutService;
|
|
1089
1375
|
#matches;
|
|
1090
|
-
#browserCssDirection;
|
|
1091
1376
|
constructor() {
|
|
1377
|
+
this.#browserCssDirection = signal(null, /* @ts-ignore */
|
|
1378
|
+
...(ngDevMode ? [{ debugName: "#browserCssDirection" }] : /* istanbul ignore next */ []));
|
|
1092
1379
|
this.#destroyRef = inject(DestroyRef);
|
|
1093
1380
|
this.#direction = injectComponentDirection();
|
|
1381
|
+
this.#document = inject(DOCUMENT);
|
|
1094
1382
|
this.#host = inject(ElementRef);
|
|
1095
1383
|
this.#layoutService = inject(SidebarLayoutService);
|
|
1096
1384
|
this.#matches = signal(false, /* @ts-ignore */
|
|
1097
1385
|
...(ngDevMode ? [{ debugName: "#matches" }] : /* istanbul ignore next */ []));
|
|
1098
|
-
this.#browserCssDirection = signal(null, /* @ts-ignore */
|
|
1099
|
-
...(ngDevMode ? [{ debugName: "#browserCssDirection" }] : /* istanbul ignore next */ []));
|
|
1100
1386
|
this.backdropClass = computed(() => sidebarBackdropThemeVariants({ open: this.mobileOpen() }), /* @ts-ignore */
|
|
1101
1387
|
...(ngDevMode ? [{ debugName: "backdropClass" }] : /* istanbul ignore next */ []));
|
|
1102
1388
|
this.baseClass = computed(() => resolveSidebarLayoutBaseClass({
|
|
@@ -1115,12 +1401,25 @@ class SidebarLayoutComponent {
|
|
|
1115
1401
|
*/
|
|
1116
1402
|
this.mobileBreakpoint = input(768, /* @ts-ignore */
|
|
1117
1403
|
...(ngDevMode ? [{ debugName: "mobileBreakpoint" }] : /* istanbul ignore next */ []));
|
|
1404
|
+
/**
|
|
1405
|
+
* @description How far an open drawer's modality reaches. `"page"` makes everything outside the drawer inert and
|
|
1406
|
+
* locks the page's scroll. Use `"layout"` for a sidebar embedded in part of a page: what's around the layout stays
|
|
1407
|
+
* usable, so the drawer isn't `aria-modal`.
|
|
1408
|
+
* @default "page"
|
|
1409
|
+
*/
|
|
1410
|
+
this.modalScope = input("page", /* @ts-ignore */
|
|
1411
|
+
...(ngDevMode ? [{ debugName: "modalScope" }] : /* istanbul ignore next */ []));
|
|
1118
1412
|
/**
|
|
1119
1413
|
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
1120
1414
|
* @default ""
|
|
1121
1415
|
*/
|
|
1122
1416
|
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class",
|
|
1123
1417
|
transform: value => classInputToClass(value) });
|
|
1418
|
+
effect(() => {
|
|
1419
|
+
const scope = this.modalScope();
|
|
1420
|
+
untracked(() => this.#layoutService.setModalScope(scope));
|
|
1421
|
+
});
|
|
1422
|
+
this.#watchEscapeOutside();
|
|
1124
1423
|
this.#watchBreakpoint();
|
|
1125
1424
|
this.#watchCssDirection();
|
|
1126
1425
|
}
|
|
@@ -1129,8 +1428,9 @@ class SidebarLayoutComponent {
|
|
|
1129
1428
|
}
|
|
1130
1429
|
onEscape(event) {
|
|
1131
1430
|
// Only a drawer is dismissible. A docked sidebar is part of the page, and closing it on
|
|
1132
|
-
// Escape would take the key from anything inside it that wanted to handle it.
|
|
1133
|
-
|
|
1431
|
+
// Escape would take the key from anything inside it that wanted to handle it. A control
|
|
1432
|
+
// that already used the key, such as a search box clearing itself, keeps it.
|
|
1433
|
+
if (event.defaultPrevented || !this.#layoutService.anyMobileOpen()) {
|
|
1134
1434
|
return;
|
|
1135
1435
|
}
|
|
1136
1436
|
event.preventDefault();
|
|
@@ -1141,7 +1441,6 @@ class SidebarLayoutComponent {
|
|
|
1141
1441
|
* crossed and the query is rebuilt only when the breakpoint input itself changes.
|
|
1142
1442
|
*/
|
|
1143
1443
|
#watchBreakpoint() {
|
|
1144
|
-
const destroyRef = inject(DestroyRef);
|
|
1145
1444
|
effect(() => {
|
|
1146
1445
|
const compact = this.#matches();
|
|
1147
1446
|
untracked(() => this.#layoutService.setCompact(compact));
|
|
@@ -1154,7 +1453,7 @@ class SidebarLayoutComponent {
|
|
|
1154
1453
|
let current = null;
|
|
1155
1454
|
const onChange = (event) => this.#matches.set(event.matches);
|
|
1156
1455
|
const detach = () => current?.removeEventListener("change", onChange);
|
|
1157
|
-
destroyRef.onDestroy(detach);
|
|
1456
|
+
this.#destroyRef.onDestroy(detach);
|
|
1158
1457
|
effect(() => {
|
|
1159
1458
|
const breakpoint = this.mobileBreakpoint();
|
|
1160
1459
|
untracked(() => {
|
|
@@ -1280,17 +1579,36 @@ class SidebarLayoutComponent {
|
|
|
1280
1579
|
});
|
|
1281
1580
|
}
|
|
1282
1581
|
}
|
|
1582
|
+
/**
|
|
1583
|
+
* A press on blank space or text can leave focus outside the layout, on the body. Escape still has to work there,
|
|
1584
|
+
* but not from a popup opened from the drawer: closing that is all its Escape should do.
|
|
1585
|
+
*/
|
|
1586
|
+
#watchEscapeOutside() {
|
|
1587
|
+
const onKeydown = (event) => {
|
|
1588
|
+
const target = event.target;
|
|
1589
|
+
if (event.key === "Escape" && !target.closest?.(".cdk-overlay-container")) {
|
|
1590
|
+
this.onEscape(event);
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
effect(onCleanup => {
|
|
1594
|
+
if (this.mobileOpen()) {
|
|
1595
|
+
this.#document.addEventListener("keydown", onKeydown);
|
|
1596
|
+
onCleanup(() => this.#document.removeEventListener("keydown", onKeydown));
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1283
1600
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarLayoutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1284
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SidebarLayoutComponent, isStandalone: true, selector: "mona-sidebar-layout", inputs: { mobileBreakpoint: { classPropertyName: "mobileBreakpoint", publicName: "mobileBreakpoint", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keydown.escape": "onEscape($event)" }, properties: { "attr.data-compact": "compact() ? 'true' : null", "class": "baseClass()" } }, providers: [SidebarLayoutService], ngImport: i0, template: `
|
|
1601
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SidebarLayoutComponent, isStandalone: true, selector: "mona-sidebar-layout", inputs: { mobileBreakpoint: { classPropertyName: "mobileBreakpoint", publicName: "mobileBreakpoint", isSignal: true, isRequired: false, transformFunction: null }, modalScope: { classPropertyName: "modalScope", publicName: "modalScope", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "keydown.escape": "onEscape($event)" }, properties: { "attr.data-compact": "compact() ? 'true' : null", "class": "baseClass()" } }, providers: [SidebarLayoutService], ngImport: i0, template: `
|
|
1285
1602
|
<ng-content></ng-content>
|
|
1286
1603
|
@if (compact()) {
|
|
1287
1604
|
<div
|
|
1288
1605
|
[class]="backdropClass()"
|
|
1289
1606
|
[attr.aria-hidden]="'true'"
|
|
1290
1607
|
[attr.data-state]="mobileOpen() ? 'open' : 'closed'"
|
|
1608
|
+
data-sidebar-backdrop="true"
|
|
1291
1609
|
(click)="onBackdropClick()"></div>
|
|
1292
1610
|
}
|
|
1293
|
-
`, isInline: true
|
|
1611
|
+
`, isInline: true }); }
|
|
1294
1612
|
}
|
|
1295
1613
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarLayoutComponent, decorators: [{
|
|
1296
1614
|
type: Component,
|
|
@@ -1303,24 +1621,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1303
1621
|
[class]="backdropClass()"
|
|
1304
1622
|
[attr.aria-hidden]="'true'"
|
|
1305
1623
|
[attr.data-state]="mobileOpen() ? 'open' : 'closed'"
|
|
1624
|
+
data-sidebar-backdrop="true"
|
|
1306
1625
|
(click)="onBackdropClick()"></div>
|
|
1307
1626
|
}
|
|
1308
1627
|
`,
|
|
1309
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1310
1628
|
host: {
|
|
1311
1629
|
"[attr.data-compact]": "compact() ? 'true' : null",
|
|
1312
1630
|
"[class]": "baseClass()",
|
|
1313
1631
|
// Escape closes the drawer from anywhere inside the layout, including from within the
|
|
1314
|
-
// trapped focus inside the drawer itself.
|
|
1632
|
+
// trapped focus inside the drawer itself. The innermost open layout hears it first.
|
|
1315
1633
|
"(keydown.escape)": "onEscape($event)"
|
|
1316
1634
|
},
|
|
1317
1635
|
providers: [SidebarLayoutService]
|
|
1318
1636
|
}]
|
|
1319
|
-
}], ctorParameters: () => [], propDecorators: { mobileBreakpoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "mobileBreakpoint", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1637
|
+
}], ctorParameters: () => [], propDecorators: { mobileBreakpoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "mobileBreakpoint", required: false }] }], modalScope: [{ type: i0.Input, args: [{ isSignal: true, alias: "modalScope", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1320
1638
|
|
|
1321
1639
|
/**
|
|
1322
1640
|
* @description
|
|
1323
|
-
* A loading placeholder shaped like a menu item.
|
|
1641
|
+
* A loading placeholder shaped like a menu item. Its label bar is clipped on the icon rail, where the
|
|
1324
1642
|
* real labels are not visible either.
|
|
1325
1643
|
*/
|
|
1326
1644
|
class SidebarMenuSkeletonComponent {
|
|
@@ -1353,7 +1671,7 @@ class SidebarMenuSkeletonComponent {
|
|
|
1353
1671
|
<mona-skeleton width="1rem" height="1rem" rounded="small"></mona-skeleton>
|
|
1354
1672
|
}
|
|
1355
1673
|
<mona-skeleton [width]="labelWidth()" height="1rem" rounded="small"></mona-skeleton>
|
|
1356
|
-
`, isInline: true, dependencies: [{ kind: "component", type: SkeletonComponent, selector: "mona-skeleton", inputs: ["height", "rounded", "class", "width"] }]
|
|
1674
|
+
`, isInline: true, dependencies: [{ kind: "component", type: SkeletonComponent, selector: "mona-skeleton", inputs: ["height", "rounded", "class", "width"] }] }); }
|
|
1357
1675
|
}
|
|
1358
1676
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarMenuSkeletonComponent, decorators: [{
|
|
1359
1677
|
type: Component,
|
|
@@ -1365,7 +1683,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1365
1683
|
}
|
|
1366
1684
|
<mona-skeleton [width]="labelWidth()" height="1rem" rounded="small"></mona-skeleton>
|
|
1367
1685
|
`,
|
|
1368
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1369
1686
|
imports: [SkeletonComponent],
|
|
1370
1687
|
host: {
|
|
1371
1688
|
"[class]": "baseClass()"
|
|
@@ -1430,23 +1747,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1430
1747
|
/**
|
|
1431
1748
|
* @description
|
|
1432
1749
|
* A titled section of the sidebar, grouping a label and its menu. Stack as many as the sidebar
|
|
1433
|
-
* needs; each is an ordinary block, so a `monaSidebarSeparator` between them is optional.
|
|
1750
|
+
* needs; each is an ordinary block, so a `monaSidebarSeparator` between them is optional. A
|
|
1751
|
+
* `monaSidebarGroupLabel` inside it names the group.
|
|
1434
1752
|
*/
|
|
1435
1753
|
class SidebarGroupDirective {
|
|
1436
1754
|
constructor() {
|
|
1437
1755
|
// The group owns the inset for everything it contains, and keeps it the same in both states.
|
|
1438
1756
|
// A `3rem` icon rail less this padding leaves exactly the `2rem` square a menu button becomes.
|
|
1439
1757
|
this.baseClass = sidebarGroupThemeVariants();
|
|
1758
|
+
/** @internal Published by the `monaSidebarGroupLabel` inside this group. */
|
|
1759
|
+
this.labelId = signal(null, /* @ts-ignore */
|
|
1760
|
+
...(ngDevMode ? [{ debugName: "labelId" }] : /* istanbul ignore next */ []));
|
|
1440
1761
|
}
|
|
1441
1762
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarGroupDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1442
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SidebarGroupDirective, isStandalone: true, selector: "[monaSidebarGroup]", host: { properties: { "class": "baseClass" } }, ngImport: i0 }); }
|
|
1763
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SidebarGroupDirective, isStandalone: true, selector: "[monaSidebarGroup]", host: { attributes: { "role": "group" }, properties: { "attr.aria-labelledby": "labelId()", "class": "baseClass" } }, ngImport: i0 }); }
|
|
1443
1764
|
}
|
|
1444
1765
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarGroupDirective, decorators: [{
|
|
1445
1766
|
type: Directive,
|
|
1446
1767
|
args: [{
|
|
1447
1768
|
selector: "[monaSidebarGroup]",
|
|
1448
1769
|
host: {
|
|
1449
|
-
"[
|
|
1770
|
+
"[attr.aria-labelledby]": "labelId()",
|
|
1771
|
+
"[class]": "baseClass",
|
|
1772
|
+
role: "group"
|
|
1450
1773
|
}
|
|
1451
1774
|
}]
|
|
1452
1775
|
}] });
|
|
@@ -1531,30 +1854,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1531
1854
|
|
|
1532
1855
|
/**
|
|
1533
1856
|
* @description
|
|
1534
|
-
* The name of a group
|
|
1857
|
+
* The name of a group, which the enclosing `monaSidebarGroup` is labelled by. Fades out on the icon
|
|
1858
|
+
* rail, where there is no width to read it in.
|
|
1535
1859
|
*/
|
|
1536
1860
|
class SidebarGroupLabelDirective {
|
|
1861
|
+
#element;
|
|
1862
|
+
#group;
|
|
1863
|
+
#sidebarService;
|
|
1537
1864
|
constructor() {
|
|
1865
|
+
this.#element = inject(ElementRef).nativeElement;
|
|
1866
|
+
this.#group = inject(SidebarGroupDirective, { optional: true });
|
|
1538
1867
|
this.#sidebarService = inject(SidebarService, { optional: true });
|
|
1539
1868
|
// Faded rather than removed from the layout: the header around it closes by height over the same
|
|
1540
1869
|
// interval, so dropping the label outright would empty the row before it had finished shrinking.
|
|
1541
1870
|
// `visibility` follows the fade so it leaves the accessibility tree with it.
|
|
1542
1871
|
this.baseClass = computed(() => sidebarGroupLabelThemeVariants({ hidden: this.#sidebarService?.iconOnly() ?? false }), /* @ts-ignore */
|
|
1543
1872
|
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
1873
|
+
this.id = this.#element.id || createElementControlId();
|
|
1874
|
+
this.#group?.labelId.set(this.id);
|
|
1875
|
+
inject(DestroyRef).onDestroy(() => this.#group?.labelId.set(null));
|
|
1544
1876
|
}
|
|
1545
|
-
#sidebarService;
|
|
1546
1877
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarGroupLabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1547
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SidebarGroupLabelDirective, isStandalone: true, selector: "[monaSidebarGroupLabel]", host: { properties: { "class": "baseClass()" } }, ngImport: i0 }); }
|
|
1878
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: SidebarGroupLabelDirective, isStandalone: true, selector: "[monaSidebarGroupLabel]", host: { properties: { "attr.id": "id", "class": "baseClass()" } }, ngImport: i0 }); }
|
|
1548
1879
|
}
|
|
1549
1880
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarGroupLabelDirective, decorators: [{
|
|
1550
1881
|
type: Directive,
|
|
1551
1882
|
args: [{
|
|
1552
1883
|
selector: "[monaSidebarGroupLabel]",
|
|
1553
1884
|
host: {
|
|
1885
|
+
"[attr.id]": "id",
|
|
1554
1886
|
"[class]": "baseClass()"
|
|
1555
1887
|
}
|
|
1556
1888
|
}]
|
|
1557
|
-
}] });
|
|
1889
|
+
}], ctorParameters: () => [] });
|
|
1558
1890
|
|
|
1559
1891
|
/**
|
|
1560
1892
|
* @description
|
|
@@ -1634,6 +1966,7 @@ class SidebarInsetDirective {
|
|
|
1634
1966
|
return twMerge(variantClass, this.userClass());
|
|
1635
1967
|
}, /* @ts-ignore */
|
|
1636
1968
|
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
1969
|
+
// Also what stops this region scrolling behind the drawer, as the layout clips its own overflow.
|
|
1637
1970
|
this.behindDrawer = computed(() => this.#layoutService?.anyMobileOpen() ?? false, /* @ts-ignore */
|
|
1638
1971
|
...(ngDevMode ? [{ debugName: "behindDrawer" }] : /* istanbul ignore next */ []));
|
|
1639
1972
|
/**
|
|
@@ -1656,9 +1989,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1656
1989
|
// The drawer is modal, so everything behind it leaves the tab order and the accessibility
|
|
1657
1990
|
// tree. `inert` covers both, and unlike `aria-hidden` it also stops pointer interaction.
|
|
1658
1991
|
"[attr.inert]": "behindDrawer() ? '' : null"
|
|
1659
|
-
// The scoped equivalent of locking body scroll. The layout already clips its own overflow, so
|
|
1660
|
-
// this region is the only thing behind the drawer that scrolls; suppressing it here avoids
|
|
1661
|
-
// reaching out to mutate `document.body`, which a library has no business owning.
|
|
1662
1992
|
}
|
|
1663
1993
|
}]
|
|
1664
1994
|
}], propDecorators: { userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
@@ -1759,7 +2089,7 @@ class SidebarMenuItemDirective {
|
|
|
1759
2089
|
constructor() {
|
|
1760
2090
|
// Applying `monaCollapsible` to the same element turns the item into a disclosure row, so it has to
|
|
1761
2091
|
// stack its trigger and submenu instead of laying them out side-by-side.
|
|
1762
|
-
this.#collapsible = inject(
|
|
2092
|
+
this.#collapsible = inject(COLLAPSIBLE_CONFIG, { optional: true, self: true });
|
|
1763
2093
|
this.#sidebarService = inject(SidebarService, { optional: true });
|
|
1764
2094
|
this.#expandedBeforeRail = false;
|
|
1765
2095
|
this.baseClass = computed(() => {
|
|
@@ -1793,7 +2123,9 @@ class SidebarMenuItemDirective {
|
|
|
1793
2123
|
*
|
|
1794
2124
|
* Closing the disclosure for real keeps the trigger's own state truthful and lets the collapsible
|
|
1795
2125
|
* content directive apply the `inert` it already applies when closed. The prior state is restored
|
|
1796
|
-
* on the way back out, so collapsing and expanding the sidebar does not quietly discard it.
|
|
2126
|
+
* on the way back out, so collapsing and expanding the sidebar does not quietly discard it. The row
|
|
2127
|
+
* itself expands the sidebar when it's activated on the rail, so that closing only meets a submenu
|
|
2128
|
+
* opened from code.
|
|
1797
2129
|
*/
|
|
1798
2130
|
#keepSubmenuClosedOnRail() {
|
|
1799
2131
|
const collapsible = this.#collapsible;
|
|
@@ -1848,14 +2180,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1848
2180
|
* bar preview, none of which a button can offer.
|
|
1849
2181
|
*
|
|
1850
2182
|
* On a compact viewport, following a link closes the drawer, since the destination it navigates to is
|
|
1851
|
-
* underneath it.
|
|
2183
|
+
* underneath it. A row that opens a submenu leaves the drawer open, and on the icon rail it expands the
|
|
2184
|
+
* sidebar, since that's the only place the submenu can open.
|
|
1852
2185
|
*/
|
|
1853
2186
|
class SidebarMenuButtonDirective {
|
|
2187
|
+
#authoredRole;
|
|
2188
|
+
#collapsibleTrigger;
|
|
2189
|
+
#element;
|
|
2190
|
+
#menuItem;
|
|
2191
|
+
#nativeButton;
|
|
2192
|
+
#sidebarService;
|
|
2193
|
+
#disabledHref;
|
|
1854
2194
|
constructor() {
|
|
2195
|
+
this.#collapsibleTrigger = inject(CollapsibleTriggerDirective, { optional: true, self: true });
|
|
1855
2196
|
this.#element = inject(ElementRef).nativeElement;
|
|
1856
2197
|
this.#menuItem = inject(SidebarMenuItemDirective, { optional: true });
|
|
1857
2198
|
this.#nativeButton = this.#element.tagName === "BUTTON";
|
|
1858
2199
|
this.#sidebarService = inject(SidebarService, { optional: true });
|
|
2200
|
+
this.#disabledHref = null;
|
|
1859
2201
|
this.ariaDisabled = computed(() => (this.disabled() ? "true" : null), /* @ts-ignore */
|
|
1860
2202
|
...(ngDevMode ? [{ debugName: "ariaDisabled" }] : /* istanbul ignore next */ []));
|
|
1861
2203
|
this.baseClass = computed(() => {
|
|
@@ -1884,12 +2226,15 @@ class SidebarMenuButtonDirective {
|
|
|
1884
2226
|
this.railBox = computed(() => this.#sidebarService?.iconOnly() ?? false, /* @ts-ignore */
|
|
1885
2227
|
...(ngDevMode ? [{ debugName: "railBox" }] : /* istanbul ignore next */ []));
|
|
1886
2228
|
// The label is clipped away on the rail, so the leading visual needs something to identify it. Only
|
|
1887
|
-
// set there, so the
|
|
1888
|
-
this.
|
|
2229
|
+
// set there, so the tooltip never duplicates a label that is already legible. `mona-sidebar` shows it.
|
|
2230
|
+
this.railTooltip = computed(() => {
|
|
1889
2231
|
const tooltip = this.tooltip();
|
|
1890
2232
|
return tooltip && this.railBox() ? tooltip : null;
|
|
1891
2233
|
}, /* @ts-ignore */
|
|
1892
|
-
...(ngDevMode ? [{ debugName: "
|
|
2234
|
+
...(ngDevMode ? [{ debugName: "railTooltip" }] : /* istanbul ignore next */ []));
|
|
2235
|
+
// Without its `href` an anchor is no longer a link, so a disabled one has to say so itself.
|
|
2236
|
+
this.role = computed(() => this.disabled() && !this.#nativeButton ? (this.#authoredRole ?? "link") : this.#authoredRole, /* @ts-ignore */
|
|
2237
|
+
...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
|
|
1893
2238
|
this.tabIndex = computed(() => (this.disabled() && !this.#nativeButton ? 0 : null), /* @ts-ignore */
|
|
1894
2239
|
...(ngDevMode ? [{ debugName: "tabIndex" }] : /* istanbul ignore next */ []));
|
|
1895
2240
|
// Guards against a sidebar row inside a form submitting it.
|
|
@@ -1897,13 +2242,14 @@ class SidebarMenuButtonDirective {
|
|
|
1897
2242
|
/**
|
|
1898
2243
|
* @description Closes the overlay drawer after this row is activated. Only applies on compact
|
|
1899
2244
|
* viewports, where the drawer covers the destination being navigated to. Set to `false` for rows
|
|
1900
|
-
* that do not navigate
|
|
1901
|
-
* @default true
|
|
2245
|
+
* that do not navigate. Leave it unset on a `monaCollapsibleTrigger`, which keeps the drawer open.
|
|
2246
|
+
* @default true, or false on a `monaCollapsibleTrigger`
|
|
1902
2247
|
*/
|
|
1903
|
-
this.closeOnSelect = input(
|
|
2248
|
+
this.closeOnSelect = input(undefined, /* @ts-ignore */
|
|
1904
2249
|
...(ngDevMode ? [{ debugName: "closeOnSelect" }] : /* istanbul ignore next */ []));
|
|
1905
2250
|
/**
|
|
1906
|
-
* @description Renders the row as unavailable and suppresses activation
|
|
2251
|
+
* @description Renders the row as unavailable and suppresses activation, including a `routerLink` and any `click`
|
|
2252
|
+
* handler on it. A disabled anchor gives up its `href`.
|
|
1907
2253
|
* @default false
|
|
1908
2254
|
*/
|
|
1909
2255
|
this.disabled = input(false, /* @ts-ignore */
|
|
@@ -1917,8 +2263,7 @@ class SidebarMenuButtonDirective {
|
|
|
1917
2263
|
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1918
2264
|
/**
|
|
1919
2265
|
* @description Text identifying this item while the sidebar is collapsed to its icon rail, where the
|
|
1920
|
-
* label is clipped away.
|
|
1921
|
-
* ancestor carrying `monaTooltip` with `mode="content"` renders it as a styled tooltip instead.
|
|
2266
|
+
* label is clipped away. Shown as a tooltip on hover and on keyboard focus, on the rail only.
|
|
1922
2267
|
* @default ""
|
|
1923
2268
|
*/
|
|
1924
2269
|
this.tooltip = input("", /* @ts-ignore */
|
|
@@ -1929,24 +2274,55 @@ class SidebarMenuButtonDirective {
|
|
|
1929
2274
|
*/
|
|
1930
2275
|
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class",
|
|
1931
2276
|
transform: value => classInputToClass(value) });
|
|
2277
|
+
this.#authoredRole = this.#element.getAttribute("role");
|
|
2278
|
+
/*
|
|
2279
|
+
* Angular merges every listener for one event on one element into a single DOM listener, so stopping the event
|
|
2280
|
+
* from inside one of them stops none of the others, `RouterLink`'s among them. This one runs ahead of that.
|
|
2281
|
+
*/
|
|
2282
|
+
const suppressWhileDisabled = (event) => {
|
|
2283
|
+
if (this.disabled()) {
|
|
2284
|
+
event.preventDefault();
|
|
2285
|
+
event.stopImmediatePropagation();
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
this.#element.addEventListener("click", suppressWhileDisabled, { capture: true });
|
|
2289
|
+
inject(DestroyRef).onDestroy(() => this.#element.removeEventListener("click", suppressWhileDisabled, { capture: true }));
|
|
2290
|
+
// After the render, because `RouterLink` sets `href` from its own binding.
|
|
2291
|
+
afterRenderEffect(() => {
|
|
2292
|
+
const disabled = this.disabled();
|
|
2293
|
+
untracked(() => this.#syncDisabledHref(disabled));
|
|
2294
|
+
});
|
|
1932
2295
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
#sidebarService;
|
|
1937
|
-
onClick(event) {
|
|
1938
|
-
if (this.disabled()) {
|
|
1939
|
-
// `aria-disabled` is advisory: an anchor with an `href` still navigates without this.
|
|
1940
|
-
event.preventDefault();
|
|
1941
|
-
event.stopImmediatePropagation();
|
|
2296
|
+
onClick() {
|
|
2297
|
+
if (this.railBox() && this.#collapsibleTrigger) {
|
|
2298
|
+
this.#sidebarService?.expand();
|
|
1942
2299
|
return;
|
|
1943
2300
|
}
|
|
1944
|
-
|
|
2301
|
+
const closes = this.closeOnSelect() ?? !this.#collapsibleTrigger;
|
|
2302
|
+
if (closes && this.#sidebarService?.mobileOpen()) {
|
|
1945
2303
|
this.#sidebarService.collapse();
|
|
1946
2304
|
}
|
|
1947
2305
|
}
|
|
2306
|
+
#syncDisabledHref(disabled) {
|
|
2307
|
+
if (this.#nativeButton) {
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (disabled) {
|
|
2311
|
+
const href = this.#element.getAttribute("href");
|
|
2312
|
+
if (href !== null) {
|
|
2313
|
+
this.#disabledHref = href;
|
|
2314
|
+
this.#element.removeAttribute("href");
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
else if (this.#disabledHref !== null) {
|
|
2318
|
+
if (!this.#element.hasAttribute("href")) {
|
|
2319
|
+
this.#element.setAttribute("href", this.#disabledHref);
|
|
2320
|
+
}
|
|
2321
|
+
this.#disabledHref = null;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
1948
2324
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarMenuButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1949
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarMenuButtonDirective, isStandalone: true, selector: "a[monaSidebarMenuButton], button[monaSidebarMenuButton]", inputs: { closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick(
|
|
2325
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarMenuButtonDirective, isStandalone: true, selector: "a[monaSidebarMenuButton], button[monaSidebarMenuButton]", inputs: { closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()" }, properties: { "attr.aria-current": "current()", "attr.aria-disabled": "ariaDisabled()", "attr.data-sidebar-tooltip": "railTooltip()", "attr.disabled": "nativeDisabled()", "attr.role": "role()", "attr.tabindex": "tabIndex()", "attr.type": "type", "class": "baseClass()" } }, exportAs: ["monaSidebarMenuButton"], ngImport: i0 }); }
|
|
1950
2326
|
}
|
|
1951
2327
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarMenuButtonDirective, decorators: [{
|
|
1952
2328
|
type: Directive,
|
|
@@ -1956,17 +2332,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1956
2332
|
host: {
|
|
1957
2333
|
"[attr.aria-current]": "current()",
|
|
1958
2334
|
"[attr.aria-disabled]": "ariaDisabled()",
|
|
2335
|
+
"[attr.data-sidebar-tooltip]": "railTooltip()",
|
|
1959
2336
|
"[attr.disabled]": "nativeDisabled()",
|
|
2337
|
+
"[attr.role]": "role()",
|
|
1960
2338
|
// An anchor without an `href` is not focusable or clickable, so a disabled link has to be
|
|
1961
2339
|
// given back a tab stop to stay announceable, and its activation suppressed instead.
|
|
1962
2340
|
"[attr.tabindex]": "tabIndex()",
|
|
1963
|
-
"[attr.title]": "railTitle()",
|
|
1964
2341
|
"[attr.type]": "type",
|
|
1965
2342
|
"[class]": "baseClass()",
|
|
1966
|
-
"(click)": "onClick(
|
|
2343
|
+
"(click)": "onClick()"
|
|
1967
2344
|
}
|
|
1968
2345
|
}]
|
|
1969
|
-
}], propDecorators: { closeOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSelect", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], tooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltip", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
2346
|
+
}], ctorParameters: () => [], propDecorators: { closeOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSelect", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], tooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltip", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
1970
2347
|
|
|
1971
2348
|
/**
|
|
1972
2349
|
* @description
|
|
@@ -2007,35 +2384,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2007
2384
|
* which positions it. Hidden on narrow viewports, where the edge is too easy to hit by accident.
|
|
2008
2385
|
*
|
|
2009
2386
|
* Deliberately outside the tab order: it is a pointer shortcut for what `monaSidebarTrigger` already
|
|
2010
|
-
* does, and a second tab stop onto
|
|
2011
|
-
*
|
|
2012
|
-
* `aria-label` so pointer users of assistive technology can still identify it.
|
|
2387
|
+
* does, and a second tab stop onto a 4px strip would be noise for keyboard users. Provide a
|
|
2388
|
+
* `monaSidebarTrigger` as well — the rail is not a substitute for it.
|
|
2013
2389
|
*/
|
|
2014
2390
|
class SidebarRailDirective {
|
|
2015
2391
|
constructor() {
|
|
2016
2392
|
this.#direction = injectComponentDirection();
|
|
2393
|
+
this.#i18n = inject(MonaI18nService);
|
|
2017
2394
|
this.#sidebarService = inject(SidebarService);
|
|
2018
|
-
this.
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
return isRtl ? "right" : "left";
|
|
2023
|
-
}
|
|
2024
|
-
return isRtl ? "left" : "right";
|
|
2025
|
-
}, /* @ts-ignore */
|
|
2026
|
-
...(ngDevMode ? [{ debugName: "physicalSide" }] : /* istanbul ignore next */ []));
|
|
2027
|
-
this.baseClass = computed(() => sidebarRailThemeVariants({ physicalSide: this.physicalSide() }), /* @ts-ignore */
|
|
2395
|
+
this.baseClass = computed(() => sidebarRailThemeVariants({
|
|
2396
|
+
compact: this.#sidebarService.compact(),
|
|
2397
|
+
physicalSide: resolvePhysicalSide(this.#direction(), this.#sidebarService.side())
|
|
2398
|
+
}), /* @ts-ignore */
|
|
2028
2399
|
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
2029
2400
|
this.expanded = this.#sidebarService.expanded;
|
|
2401
|
+
this.messages = this.#i18n.componentMessages("sidebar", SIDEBAR_DEFAULT_MESSAGES);
|
|
2030
2402
|
this.sidebarId = this.#sidebarService.sidebarId;
|
|
2403
|
+
/**
|
|
2404
|
+
* @description Accessible name of the rail, which otherwise has a localized default.
|
|
2405
|
+
* @default ""
|
|
2406
|
+
*/
|
|
2407
|
+
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
2031
2408
|
}
|
|
2032
2409
|
#direction;
|
|
2410
|
+
#i18n;
|
|
2033
2411
|
#sidebarService;
|
|
2034
2412
|
onClick() {
|
|
2035
2413
|
this.#sidebarService.toggle();
|
|
2036
2414
|
}
|
|
2037
2415
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarRailDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2038
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
2416
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarRailDirective, isStandalone: true, selector: "button[monaSidebarRail]", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()" }, properties: { "attr.aria-controls": "sidebarId()", "attr.aria-expanded": "expanded()", "attr.aria-label": "ariaLabel() || messages().rail", "attr.tabindex": "-1", "attr.type": "'button'", "class": "baseClass()" } }, ngImport: i0 }); }
|
|
2039
2417
|
}
|
|
2040
2418
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarRailDirective, decorators: [{
|
|
2041
2419
|
type: Directive,
|
|
@@ -2044,6 +2422,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2044
2422
|
host: {
|
|
2045
2423
|
"[attr.aria-controls]": "sidebarId()",
|
|
2046
2424
|
"[attr.aria-expanded]": "expanded()",
|
|
2425
|
+
"[attr.aria-label]": "ariaLabel() || messages().rail",
|
|
2047
2426
|
"[attr.tabindex]": "-1",
|
|
2048
2427
|
// Without this a rail inside a form submits it, because `submit` is a button's default type.
|
|
2049
2428
|
"[attr.type]": "'button'",
|
|
@@ -2051,7 +2430,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2051
2430
|
"(click)": "onClick()"
|
|
2052
2431
|
}
|
|
2053
2432
|
}]
|
|
2054
|
-
}] });
|
|
2433
|
+
}], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }] } });
|
|
2055
2434
|
|
|
2056
2435
|
/**
|
|
2057
2436
|
* @description
|
|
@@ -2067,6 +2446,8 @@ class SidebarSeparatorDirective {
|
|
|
2067
2446
|
return twMerge(variantClass, this.userClass());
|
|
2068
2447
|
}, /* @ts-ignore */
|
|
2069
2448
|
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
2449
|
+
// An `hr` already is one.
|
|
2450
|
+
this.role = inject(ElementRef).nativeElement.tagName === "HR" ? null : "separator";
|
|
2070
2451
|
/**
|
|
2071
2452
|
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
2072
2453
|
* @default ""
|
|
@@ -2076,13 +2457,14 @@ class SidebarSeparatorDirective {
|
|
|
2076
2457
|
}
|
|
2077
2458
|
#sidebarService;
|
|
2078
2459
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarSeparatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2079
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarSeparatorDirective, isStandalone: true, selector: "[monaSidebarSeparator]", inputs: { userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "baseClass()" } }, ngImport: i0 }); }
|
|
2460
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarSeparatorDirective, isStandalone: true, selector: "[monaSidebarSeparator]", inputs: { userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.role": "role", "class": "baseClass()" } }, ngImport: i0 }); }
|
|
2080
2461
|
}
|
|
2081
2462
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarSeparatorDirective, decorators: [{
|
|
2082
2463
|
type: Directive,
|
|
2083
2464
|
args: [{
|
|
2084
2465
|
selector: "[monaSidebarSeparator]",
|
|
2085
2466
|
host: {
|
|
2467
|
+
"[attr.role]": "role",
|
|
2086
2468
|
"[class]": "baseClass()"
|
|
2087
2469
|
}
|
|
2088
2470
|
}]
|
|
@@ -2096,17 +2478,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2096
2478
|
* By default it drives the sidebar it is written inside. Set `for` to the id of a `mona-sidebar` to
|
|
2097
2479
|
* drive that one instead, which is what a trigger in a shared header needs when the layout holds more
|
|
2098
2480
|
* than one sidebar. A `for` that matches no sidebar leaves the trigger inert rather than throwing, so
|
|
2099
|
-
* a sidebar that has not rendered yet does not take the page down with it.
|
|
2481
|
+
* a sidebar that has not rendered yet does not take the page down with it, and warns in development.
|
|
2100
2482
|
*
|
|
2101
2483
|
* A `button` is the right host and needs nothing further. On any other element the directive supplies
|
|
2102
|
-
* the rest of the button contract — `role`, a tab stop, and Enter/Space activation — so a `div
|
|
2103
|
-
* `span`
|
|
2484
|
+
* the rest of the button contract — `role`, a tab stop, and Enter/Space activation — so a `div`, a
|
|
2485
|
+
* `span` or an `a` without `href` is still operable by keyboard rather than silently mouse-only.
|
|
2486
|
+
*
|
|
2487
|
+
* A sidebar that can't collapse has nothing for a trigger to do on a wide viewport, so the trigger
|
|
2488
|
+
* reports itself as disabled there rather than as an open disclosure.
|
|
2104
2489
|
*/
|
|
2105
2490
|
class SidebarTriggerDirective {
|
|
2491
|
+
#element;
|
|
2492
|
+
#layoutService;
|
|
2493
|
+
// A binding such as `routerLink` sets `href` after this directive is created, so it's read after the first render.
|
|
2494
|
+
#nativeAnchor;
|
|
2495
|
+
#nativeButton;
|
|
2496
|
+
// Optional, because a trigger aimed at a sidebar by id is usually written outside every sidebar.
|
|
2497
|
+
#sidebarService;
|
|
2498
|
+
/**
|
|
2499
|
+
* The sidebar this trigger drives: the one named by `for`, else the one it is written inside, else
|
|
2500
|
+
* the layout's first. That last step is what lets a trigger in the inset or a header go on working
|
|
2501
|
+
* without naming anything, which is all a layout with a single sidebar ever needs.
|
|
2502
|
+
*/
|
|
2503
|
+
#targetController;
|
|
2106
2504
|
constructor() {
|
|
2107
2505
|
this.#element = inject(ElementRef).nativeElement;
|
|
2108
2506
|
this.#layoutService = inject(SidebarLayoutService, { optional: true });
|
|
2109
|
-
|
|
2507
|
+
// A binding such as `routerLink` sets `href` after this directive is created, so it's read after the first render.
|
|
2508
|
+
this.#nativeAnchor = signal(false, /* @ts-ignore */
|
|
2509
|
+
...(ngDevMode ? [{ debugName: "#nativeAnchor" }] : /* istanbul ignore next */ []));
|
|
2110
2510
|
this.#nativeButton = this.#element.tagName === "BUTTON" || this.#element.tagName === "INPUT" || this.#element.tagName === "SUMMARY";
|
|
2111
2511
|
// Optional, because a trigger aimed at a sidebar by id is usually written outside every sidebar.
|
|
2112
2512
|
this.#sidebarService = inject(SidebarService, { optional: true });
|
|
@@ -2125,12 +2525,19 @@ class SidebarTriggerDirective {
|
|
|
2125
2525
|
...(ngDevMode ? [{ debugName: "#targetController" }] : /* istanbul ignore next */ []));
|
|
2126
2526
|
// Null rather than false when nothing is targeted: a trigger that controls nothing has no
|
|
2127
2527
|
// expanded state to report, and claiming one would announce a control that does not exist.
|
|
2128
|
-
this.expanded = computed(() => this.#targetController()?.expanded() ?? null, /* @ts-ignore */
|
|
2528
|
+
this.expanded = computed(() => this.fixed() ? null : (this.#targetController()?.expanded() ?? null), /* @ts-ignore */
|
|
2129
2529
|
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
2130
|
-
this.
|
|
2530
|
+
this.fixed = computed(() => {
|
|
2531
|
+
const target = this.#targetController();
|
|
2532
|
+
return target?.collapsible() === "none" && !target.compact();
|
|
2533
|
+
}, /* @ts-ignore */
|
|
2534
|
+
...(ngDevMode ? [{ debugName: "fixed" }] : /* istanbul ignore next */ []));
|
|
2535
|
+
this.role = computed(() => (this.#nativeButton || this.#nativeAnchor() ? null : "button"), /* @ts-ignore */
|
|
2536
|
+
...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
|
|
2131
2537
|
this.sidebarId = computed(() => this.#targetController()?.sidebarId() ?? null, /* @ts-ignore */
|
|
2132
2538
|
...(ngDevMode ? [{ debugName: "sidebarId" }] : /* istanbul ignore next */ []));
|
|
2133
|
-
this.tabIndex = this.#nativeButton || this.#nativeAnchor ? null : 0
|
|
2539
|
+
this.tabIndex = computed(() => (this.#nativeButton || this.#nativeAnchor() ? null : 0), /* @ts-ignore */
|
|
2540
|
+
...(ngDevMode ? [{ debugName: "tabIndex" }] : /* istanbul ignore next */ []));
|
|
2134
2541
|
this.type = this.#element.tagName === "BUTTON" ? "button" : null;
|
|
2135
2542
|
/**
|
|
2136
2543
|
* @description Id of the `mona-sidebar` to toggle. Leave unset to toggle the sidebar this trigger
|
|
@@ -2139,25 +2546,21 @@ class SidebarTriggerDirective {
|
|
|
2139
2546
|
*/
|
|
2140
2547
|
this.for = input("", /* @ts-ignore */
|
|
2141
2548
|
...(ngDevMode ? [{ debugName: "for" }] : /* istanbul ignore next */ []));
|
|
2549
|
+
this.#nativeAnchor.set(this.#element.tagName === "A" && this.#element.hasAttribute("href"));
|
|
2550
|
+
afterNextRender(() => {
|
|
2551
|
+
this.#nativeAnchor.set(this.#element.tagName === "A" && this.#element.hasAttribute("href"));
|
|
2552
|
+
if (isDevMode() && this.for() && !this.#targetController()) {
|
|
2553
|
+
console.warn(`monaSidebarTrigger: no sidebar with the id "${this.for()}" in this layout. A trigger can only reach ` +
|
|
2554
|
+
"a sidebar in its own mona-sidebar-layout.");
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2142
2557
|
}
|
|
2143
|
-
#element;
|
|
2144
|
-
#layoutService;
|
|
2145
|
-
#nativeAnchor;
|
|
2146
|
-
#nativeButton;
|
|
2147
|
-
// Optional, because a trigger aimed at a sidebar by id is usually written outside every sidebar.
|
|
2148
|
-
#sidebarService;
|
|
2149
|
-
/**
|
|
2150
|
-
* The sidebar this trigger drives: the one named by `for`, else the one it is written inside, else
|
|
2151
|
-
* the layout's first. That last step is what lets a trigger in the inset or a header go on working
|
|
2152
|
-
* without naming anything, which is all a layout with a single sidebar ever needs.
|
|
2153
|
-
*/
|
|
2154
|
-
#targetController;
|
|
2155
2558
|
onClick() {
|
|
2156
2559
|
this.#targetController()?.toggle();
|
|
2157
2560
|
}
|
|
2158
2561
|
onEnterKeydown(event) {
|
|
2159
|
-
// Buttons and
|
|
2160
|
-
if (this.#nativeButton || this.#nativeAnchor) {
|
|
2562
|
+
// Buttons and links already synthesize a click for Enter.
|
|
2563
|
+
if (this.#nativeButton || this.#nativeAnchor()) {
|
|
2161
2564
|
return;
|
|
2162
2565
|
}
|
|
2163
2566
|
event.preventDefault();
|
|
@@ -2172,7 +2575,7 @@ class SidebarTriggerDirective {
|
|
|
2172
2575
|
this.#targetController()?.toggle();
|
|
2173
2576
|
}
|
|
2174
2577
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2175
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarTriggerDirective, isStandalone: true, selector: "[monaSidebarTrigger]", inputs: { for: { classPropertyName: "for", publicName: "for", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()", "keydown.enter": "onEnterKeydown($event)", "keydown.space": "onSpaceKeydown($event)" }, properties: { "attr.aria-controls": "sidebarId()", "attr.aria-expanded": "expanded()", "attr.role": "role", "attr.tabindex": "tabIndex", "attr.type": "type" } }, exportAs: ["monaSidebarTrigger"], ngImport: i0 }); }
|
|
2578
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: SidebarTriggerDirective, isStandalone: true, selector: "[monaSidebarTrigger]", inputs: { for: { classPropertyName: "for", publicName: "for", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick()", "keydown.enter": "onEnterKeydown($event)", "keydown.space": "onSpaceKeydown($event)" }, properties: { "attr.aria-controls": "sidebarId()", "attr.aria-disabled": "fixed() ? 'true' : null", "attr.aria-expanded": "expanded()", "attr.role": "role()", "attr.tabindex": "tabIndex()", "attr.type": "type" } }, exportAs: ["monaSidebarTrigger"], ngImport: i0 }); }
|
|
2176
2579
|
}
|
|
2177
2580
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SidebarTriggerDirective, decorators: [{
|
|
2178
2581
|
type: Directive,
|
|
@@ -2181,9 +2584,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2181
2584
|
exportAs: "monaSidebarTrigger",
|
|
2182
2585
|
host: {
|
|
2183
2586
|
"[attr.aria-controls]": "sidebarId()",
|
|
2587
|
+
"[attr.aria-disabled]": "fixed() ? 'true' : null",
|
|
2184
2588
|
"[attr.aria-expanded]": "expanded()",
|
|
2185
|
-
"[attr.role]": "role",
|
|
2186
|
-
"[attr.tabindex]": "tabIndex",
|
|
2589
|
+
"[attr.role]": "role()",
|
|
2590
|
+
"[attr.tabindex]": "tabIndex()",
|
|
2187
2591
|
// Without this a trigger inside a form submits it, because `submit` is a button's default type.
|
|
2188
2592
|
"[attr.type]": "type",
|
|
2189
2593
|
"(click)": "onClick()",
|
|
@@ -2191,20 +2595,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
2191
2595
|
"(keydown.space)": "onSpaceKeydown($event)"
|
|
2192
2596
|
}
|
|
2193
2597
|
}]
|
|
2194
|
-
}], propDecorators: { for: [{ type: i0.Input, args: [{ isSignal: true, alias: "for", required: false }] }] } });
|
|
2598
|
+
}], ctorParameters: () => [], propDecorators: { for: [{ type: i0.Input, args: [{ isSignal: true, alias: "for", required: false }] }] } });
|
|
2195
2599
|
|
|
2196
2600
|
/**
|
|
2197
2601
|
* Replaces where sidebars remember whether they were left open. The default is `localStorage`, which
|
|
2198
2602
|
* the server cannot read; supply a cookie- or request-backed storage here to have a server-rendered
|
|
2199
2603
|
* application render the remembered state rather than correcting it on hydration.
|
|
2604
|
+
* @param storage the storage, or a factory for it that runs in an injection context, such as for one
|
|
2605
|
+
* that injects the current request
|
|
2200
2606
|
*/
|
|
2201
2607
|
function provideSidebarStorage(storage) {
|
|
2202
|
-
return makeEnvironmentProviders([
|
|
2608
|
+
return makeEnvironmentProviders([
|
|
2609
|
+
typeof storage === "function"
|
|
2610
|
+
? { provide: SIDEBAR_STORAGE, useFactory: storage }
|
|
2611
|
+
: { provide: SIDEBAR_STORAGE, useValue: storage }
|
|
2612
|
+
]);
|
|
2203
2613
|
}
|
|
2204
2614
|
|
|
2205
2615
|
function injectSidebar(options) {
|
|
2206
|
-
const service = inject(SidebarService, { optional:
|
|
2207
|
-
|
|
2616
|
+
const service = inject(SidebarService, { optional: true });
|
|
2617
|
+
if (service && !options?.for) {
|
|
2618
|
+
return service.controller;
|
|
2619
|
+
}
|
|
2620
|
+
const layout = inject(SidebarLayoutService, { optional: true });
|
|
2621
|
+
if (layout) {
|
|
2622
|
+
return layout.controllerFor(options?.for);
|
|
2623
|
+
}
|
|
2624
|
+
if (options?.optional) {
|
|
2625
|
+
return null;
|
|
2626
|
+
}
|
|
2627
|
+
if (options?.for) {
|
|
2628
|
+
// Only a layout can find a sidebar by id, and the enclosing one may not be the one that was named.
|
|
2629
|
+
throw new Error(`injectSidebar: there's no mona-sidebar-layout to find the sidebar "${options.for}" in.`);
|
|
2630
|
+
}
|
|
2631
|
+
// Asked again without `optional`, for the framework's own error when there's nothing to read.
|
|
2632
|
+
return inject(SidebarService).controller;
|
|
2208
2633
|
}
|
|
2209
2634
|
|
|
2210
2635
|
/*
|
|
@@ -2215,5 +2640,5 @@ function injectSidebar(options) {
|
|
|
2215
2640
|
* Generated bundle index. Do not edit.
|
|
2216
2641
|
*/
|
|
2217
2642
|
|
|
2218
|
-
export { LocalStorageSidebarStorage, SIDEBAR_STORAGE, SidebarComponent, SidebarContentDirective, SidebarFooterDirective, SidebarGroupActionDirective, SidebarGroupContentDirective, SidebarGroupDirective, SidebarGroupHeaderDirective, SidebarGroupLabelDirective, SidebarHeaderDirective, SidebarInputDirective, SidebarInsetDirective, SidebarLayoutComponent, SidebarMenuActionDirective, SidebarMenuBadgeDirective, SidebarMenuButtonDirective, SidebarMenuDirective, SidebarMenuItemDirective, SidebarMenuSkeletonComponent, SidebarMenuSubDirective, SidebarRailDirective, SidebarSeparatorDirective, SidebarTriggerDirective, injectSidebar, provideSidebarStorage };
|
|
2643
|
+
export { LocalStorageSidebarStorage, SIDEBAR_DEFAULT_MESSAGES, SIDEBAR_STORAGE, SidebarComponent, SidebarContentDirective, SidebarFooterDirective, SidebarGroupActionDirective, SidebarGroupContentDirective, SidebarGroupDirective, SidebarGroupHeaderDirective, SidebarGroupLabelDirective, SidebarHeaderDirective, SidebarInputDirective, SidebarInsetDirective, SidebarLayoutComponent, SidebarMenuActionDirective, SidebarMenuBadgeDirective, SidebarMenuButtonDirective, SidebarMenuDirective, SidebarMenuItemDirective, SidebarMenuSkeletonComponent, SidebarMenuSubDirective, SidebarRailDirective, SidebarSeparatorDirective, SidebarTriggerDirective, injectSidebar, provideSidebarStorage };
|
|
2219
2644
|
//# sourceMappingURL=nanahoshi-mona-ui-sidebar.mjs.map
|