@sixbell-telco/sdk 3.3.0 → 4.0.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/CHANGELOG.md +137 -1
- package/README.md +45 -45
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/_index.css +673 -76
- package/components/audio-player/README.md +1 -0
- package/components/audio-player/button-play/button-play.component.d.ts +3 -0
- package/components/audio-player/src/audio-player.component.d.ts +8 -0
- package/components/audio-player/volume-control/volume-control.component.d.ts +3 -0
- package/components/button/README.md +13 -0
- package/components/button/src/button.component.d.ts +30 -5
- package/components/data-table/README.md +53 -3
- package/components/data-table/expandable/expandable.component.d.ts +15 -2
- package/components/data-table/public-api.d.ts +2 -0
- package/components/data-table/sortable-header/sortable-header.component.d.ts +15 -1
- package/components/data-table/src/aria-sort.d.ts +22 -0
- package/components/data-table/src/data-table-context.service.d.ts +11 -3
- package/components/data-table/src/data-table.component.d.ts +39 -3
- package/components/data-table/src/sort-icon.component.d.ts +22 -0
- package/components/data-table/src/toggle-size.d.ts +7 -0
- package/components/data-table/sub-component-toggle/sub-component-toggle.component.d.ts +13 -0
- package/components/dialog/README.md +1 -0
- package/components/dialog/src/dialog.component.d.ts +9 -2
- package/components/divider/src/divider.component.d.ts +5 -0
- package/components/dropdown/README.md +21 -0
- package/components/dropdown/dropdown-content/dropdown-content.component.d.ts +4 -0
- package/components/dropdown/dropdown-trigger/dropdown-trigger.component.d.ts +36 -0
- package/components/dropdown/src/dropdown-item-focus.d.ts +6 -0
- package/components/dropdown/src/dropdown.component.d.ts +5 -2
- package/components/dual-list/src/dual-list.component.d.ts +6 -0
- package/components/file-upload/file-dropzone/file-dropzone.component.d.ts +6 -0
- package/components/forms/combobox/src/combobox.component.d.ts +7 -0
- package/components/forms/date-picker/README.md +2 -0
- package/components/forms/date-picker/src/date-picker.component.d.ts +6 -0
- package/components/forms/select/src/select.component.d.ts +3 -0
- package/components/icon/README.md +8 -1
- package/components/icon/src/icon.component.d.ts +9 -1
- package/components/notification/README.md +8 -0
- package/components/notification/src/notification.component.d.ts +8 -1
- package/components/paginator/README.md +1 -0
- package/components/paginator/components/pagination-item/pagination-item.component.d.ts +7 -1
- package/components/paginator/src/paginator.component.d.ts +10 -0
- package/components/sonner/toaster/src/toaster.component.d.ts +2 -1
- package/components/table/README.md +25 -0
- package/components/table/public-api.d.ts +1 -0
- package/components/table/src/table-loading.d.ts +18 -0
- package/components/table/src/table.component.d.ts +32 -4
- package/components/text/README.md +1 -0
- package/components/tooltip/src/tooltip.component.d.ts +2 -0
- package/directives/text/src/text.directive.d.ts +2 -2
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs +48 -10
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-button.mjs +83 -4
- package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table-sub-component-toggle.mjs +34 -33
- package/fesm2022/sixbell-telco-sdk-components-data-table-sub-component-toggle.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +429 -361
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs +42 -22
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-divider.mjs +8 -2
- package/fesm2022/sixbell-telco-sdk-components-divider.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +7 -8
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +4 -4
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +247 -48
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +10 -3
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +16 -8
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +13 -5
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +9 -3
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-radio.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-range.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-range.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +8 -4
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-switch.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +3 -15
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-toggle.mjs +2 -3
- package/fesm2022/sixbell-telco-sdk-components-forms-toggle.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-icon.mjs +12 -4
- package/fesm2022/sixbell-telco-sdk-components-icon.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-link.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-link.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-notification.mjs +17 -8
- package/fesm2022/sixbell-telco-sdk-components-notification.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-overlay.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs +24 -5
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs +5 -5
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-sonner-toaster.mjs +2 -1
- package/fesm2022/sixbell-telco-sdk-components-sonner-toaster.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-sonner.mjs +2 -1
- package/fesm2022/sixbell-telco-sdk-components-sonner.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tab.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tab.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-table.mjs +99 -22
- package/fesm2022/sixbell-telco-sdk-components-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tooltip.mjs +21 -3
- package/fesm2022/sixbell-telco-sdk-components-tooltip.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs +9 -9
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-text.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-directives-text.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-layouts.mjs +919 -0
- package/fesm2022/sixbell-telco-sdk-layouts.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-cn.mjs +2 -3
- package/fesm2022/sixbell-telco-sdk-utils-cn.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-http.mjs +39 -0
- package/fesm2022/sixbell-telco-sdk-utils-http.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-mfe.mjs +150 -0
- package/fesm2022/sixbell-telco-sdk-utils-mfe.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +103 -4
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +71 -2
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/layouts/README.md +278 -0
- package/layouts/index.d.ts +5 -0
- package/layouts/public-api.d.ts +23 -0
- package/layouts/src/app-layout/app-layout.component.d.ts +71 -0
- package/layouts/src/layout-account.d.ts +16 -0
- package/layouts/src/layout-logo.d.ts +10 -0
- package/layouts/src/layout-switcher/layout-switcher.component.d.ts +13 -0
- package/layouts/src/layout.config.d.ts +18 -0
- package/layouts/src/layout.service.d.ts +17 -0
- package/layouts/src/menu/menu-active.d.ts +24 -0
- package/layouts/src/menu/menu-animation.d.ts +34 -0
- package/layouts/src/menu/menu-search.d.ts +13 -0
- package/layouts/src/menu/menu-sections.d.ts +23 -0
- package/layouts/src/menu/menu-url.d.ts +12 -0
- package/layouts/src/menu/menu.model.d.ts +15 -0
- package/layouts/src/navbar/navbar.component.d.ts +33 -0
- package/layouts/src/page-banner/page-banner.component.d.ts +40 -0
- package/layouts/src/side-menu/side-menu.component.d.ts +89 -0
- package/layouts/src/user-menu/user-menu.component.d.ts +91 -0
- package/package.json +30 -19
- package/utils/cn/src/cn.d.ts +1 -1
- package/utils/http/README.md +26 -0
- package/utils/http/index.d.ts +5 -0
- package/utils/http/public-api.d.ts +3 -0
- package/utils/http/src/bearer-token.interceptor.d.ts +19 -0
- package/utils/http/src/http-context.d.ts +3 -0
- package/utils/mfe/README.md +35 -0
- package/utils/mfe/index.d.ts +5 -0
- package/utils/mfe/public-api.d.ts +5 -0
- package/utils/mfe/src/mfe-shadow-root.d.ts +23 -0
- package/utils/mfe/src/mfe-shadow-shell.component.d.ts +20 -0
- package/utils/mfe/src/provide-mfe-shadow-shell.d.ts +20 -0
- package/utils/mfe/src/shadow-root-overlay-container.d.ts +13 -0
- package/utils/theme/README.md +14 -0
- package/utils/theme/public-api.d.ts +3 -1
- package/utils/theme/src/models/theme.d.ts +18 -0
- package/utils/theme/src/scheme-favicon/scheme-favicon.d.ts +26 -0
- package/utils/theme/src/theme-assets/theme-assets.service.d.ts +31 -1
- package/utils/theme/src/theme-assets/theme-assets.types.d.ts +6 -0
- package/utils/translation/README.md +12 -0
- package/utils/translation/public-api.d.ts +4 -0
- package/utils/translation/src/title-strategy/translated-title-strategy.d.ts +27 -0
- package/utils/translation/src/translated-label/translated-label.d.ts +21 -0
|
@@ -0,0 +1,919 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, computed, InjectionToken, signal, Injectable, model, ChangeDetectionStrategy, Component, input, output, viewChild, ElementRef, afterRenderEffect, Injector, effect, untracked, afterNextRender, TemplateRef, Directive, contentChild } from '@angular/core';
|
|
4
|
+
import { RouterLink, Router, NavigationEnd } from '@angular/router';
|
|
5
|
+
import { cn } from '@sixbell-telco/sdk/utils/cn';
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
import { ThemeService, ThemeAssetsService } from '@sixbell-telco/sdk/utils/theme';
|
|
8
|
+
import { TranslationService, TranslatePipe, TranslateService } from '@sixbell-telco/sdk/utils/translation';
|
|
9
|
+
import { DialogComponent, DialogTitleComponent, DialogContentComponent } from '@sixbell-telco/sdk/components/dialog';
|
|
10
|
+
import { IconComponent } from '@sixbell-telco/sdk/components/icon';
|
|
11
|
+
import { matCheckOutline, matDarkModeOutline, matLightModeOutline, matComputerOutline, matColorLensOutline, matPersonOutline, matPasswordOutline, matLogoutOutline, matLanguageOutline, matDashboardCustomizeOutline, matFolderOutline, matSearchOutline, matMenuOpenOutline, matMenuOutline } from '@sixbell-telco/sdk/components/icon/material/outline';
|
|
12
|
+
import { TextDirective } from '@sixbell-telco/sdk/directives/text';
|
|
13
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
14
|
+
import { AvatarComponent } from '@sixbell-telco/sdk/components/avatar';
|
|
15
|
+
import { ButtonComponent } from '@sixbell-telco/sdk/components/button';
|
|
16
|
+
import { DropdownComponent, DropdownTriggerComponent, DropdownContentComponent, DropdownItemComponent, DropdownItemRadioComponent, DropdownLabelComponent, DropdownSeparatorComponent, DropdownChevronComponent } from '@sixbell-telco/sdk/components/dropdown';
|
|
17
|
+
import { matChevronLeft, matKeyboardArrowDown, matKeyboardBackspace } from '@sixbell-telco/sdk/components/icon/material/baseline';
|
|
18
|
+
import { merge, filter, map, startWith } from 'rxjs';
|
|
19
|
+
import { InputComponent, InputContentComponent } from '@sixbell-telco/sdk/components/forms/input';
|
|
20
|
+
import { TooltipComponent } from '@sixbell-telco/sdk/components/tooltip';
|
|
21
|
+
import { generateUniqueId } from '@sixbell-telco/sdk/utils/generators/uuid';
|
|
22
|
+
|
|
23
|
+
/** Theme art and alt text for the layout logos. Call it in an injection context. */
|
|
24
|
+
function injectLayoutLogo() {
|
|
25
|
+
const themeService = inject(ThemeService);
|
|
26
|
+
const themeAssetsService = inject(ThemeAssetsService);
|
|
27
|
+
const translationService = inject(TranslationService);
|
|
28
|
+
return {
|
|
29
|
+
assetUrl: (key) => themeAssetsService.getAssetUrl(themeService.selectedTheme(), key, themeService.resolvedScheme()),
|
|
30
|
+
alt: (override) => computed(() => {
|
|
31
|
+
const value = override();
|
|
32
|
+
if (value)
|
|
33
|
+
return value;
|
|
34
|
+
translationService.changes();
|
|
35
|
+
return themeService.getLocalizedThemeName(themeService.selectedTheme());
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const LAYOUT_CONFIG = new InjectionToken('LAYOUT_CONFIG', { factory: () => ({}) });
|
|
41
|
+
const LAYOUT_OPTIONS = [
|
|
42
|
+
{ value: 'classic', labelKey: 'sdk.layout.classic', descriptionKey: 'sdk.layout.classic_description' },
|
|
43
|
+
{ value: 'modern', labelKey: 'sdk.layout.modern', descriptionKey: 'sdk.layout.modern_description' },
|
|
44
|
+
];
|
|
45
|
+
/** Configures the SDK layouts: default layout and preference namespace. */
|
|
46
|
+
function provideLayout(config) {
|
|
47
|
+
return { provide: LAYOUT_CONFIG, useValue: config };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const FALLBACK_LAYOUT = 'classic';
|
|
51
|
+
const isLayout = (value) => LAYOUT_OPTIONS.some((option) => option.value === value);
|
|
52
|
+
/** Selected layout and sidebar state, persisted in `localStorage` like the theme and language preferences. */
|
|
53
|
+
class LayoutService {
|
|
54
|
+
config = inject(LAYOUT_CONFIG);
|
|
55
|
+
prefix = this.config.storageNamespace ? `layout:${this.config.storageNamespace}:` : 'layout:';
|
|
56
|
+
options = LAYOUT_OPTIONS;
|
|
57
|
+
selectedLayout = signal(this.restoreLayout());
|
|
58
|
+
sidebarCollapsed = signal(this.read('sidebarCollapsed') === 'true');
|
|
59
|
+
setLayout(layout) {
|
|
60
|
+
this.selectedLayout.set(layout);
|
|
61
|
+
this.write('selectedLayout', layout);
|
|
62
|
+
}
|
|
63
|
+
setSidebarCollapsed(collapsed) {
|
|
64
|
+
this.sidebarCollapsed.set(collapsed);
|
|
65
|
+
this.write('sidebarCollapsed', String(collapsed));
|
|
66
|
+
}
|
|
67
|
+
restoreLayout() {
|
|
68
|
+
const stored = this.read('selectedLayout');
|
|
69
|
+
if (isLayout(stored)) {
|
|
70
|
+
return stored;
|
|
71
|
+
}
|
|
72
|
+
return isLayout(this.config.defaultLayout) ? this.config.defaultLayout : FALLBACK_LAYOUT;
|
|
73
|
+
}
|
|
74
|
+
read(key) {
|
|
75
|
+
try {
|
|
76
|
+
return localStorage.getItem(this.prefix + key);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
write(key, value) {
|
|
83
|
+
try {
|
|
84
|
+
localStorage.setItem(this.prefix + key, value);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Storage can be unavailable (private mode, SSR); the in-memory state still applies.
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LayoutService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
91
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LayoutService, providedIn: 'root' });
|
|
92
|
+
}
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LayoutService, decorators: [{
|
|
94
|
+
type: Injectable,
|
|
95
|
+
args: [{ providedIn: 'root' }]
|
|
96
|
+
}] });
|
|
97
|
+
|
|
98
|
+
/** Dialog that previews the classic and modern layouts and applies the one the user picks. */
|
|
99
|
+
class LayoutSwitcherComponent {
|
|
100
|
+
layoutService = inject(LayoutService);
|
|
101
|
+
opened = model(false);
|
|
102
|
+
options = this.layoutService.options;
|
|
103
|
+
selectedLayout = this.layoutService.selectedLayout;
|
|
104
|
+
checkIcon = matCheckOutline;
|
|
105
|
+
select(layout) {
|
|
106
|
+
this.layoutService.setLayout(layout);
|
|
107
|
+
this.opened.set(false);
|
|
108
|
+
}
|
|
109
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LayoutSwitcherComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
110
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: LayoutSwitcherComponent, isStandalone: true, selector: "st-layout-switcher", inputs: { opened: { classPropertyName: "opened", publicName: "opened", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { opened: "openedChange" }, ngImport: i0, template: "<st-dialog [(opened)]=\"opened\" width=\"lg\">\n\t<st-dialog-title>{{ 'sdk.layout.title' | translate }}</st-dialog-title>\n\t<st-dialog-content>\n\t\t<div class=\"grid grid-cols-2 gap-6 py-4\">\n\t\t\t@for (option of options; track option.value) {\n\t\t\t\t<!-- Preview Card -->\n\t\t\t\t<button\n\t\t\t\t\tclass=\"group rounded-box relative flex cursor-pointer flex-col items-center gap-3 border-2 p-4 transition-all duration-300 active:scale-[0.98]\"\n\t\t\t\t\t[class]=\"\n\t\t\t\t\t\tselectedLayout() === option.value\n\t\t\t\t\t\t\t? 'border-primary ring-primary/30 ring-4'\n\t\t\t\t\t\t\t: 'border-base-300 hover:border-primary/50 hover:ring-primary/15 hover:ring-2'\n\t\t\t\t\t\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t[attr.aria-pressed]=\"selectedLayout() === option.value\"\n\t\t\t\t\t[attr.data-st-layout-option]=\"option.value\"\n\t\t\t\t\t[attr.aria-describedby]=\"'st-layout-option-' + option.value + '-description'\"\n\t\t\t\t\t(click)=\"select(option.value)\"\n\t\t\t\t>\n\t\t\t\t\t<!-- Selected Checkmark Badge -->\n\t\t\t\t\t@if (selectedLayout() === option.value) {\n\t\t\t\t\t\t<div class=\"bg-primary text-primary-content absolute -top-2.5 -right-2.5 z-10 grid h-6 w-6 place-items-center rounded-full shadow-md\">\n\t\t\t\t\t\t\t<st-icon [icon]=\"checkIcon\" size=\"xs\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t}\n\n\t\t\t\t\t<!-- Minimap Container -->\n\t\t\t\t\t<div class=\"bg-base-200 rounded-box relative h-40 w-full overflow-hidden\">\n\t\t\t\t\t\t@switch (option.value) {\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t<!-- CLASSIC MINIMAP -->\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t@case ('classic') {\n\t\t\t\t\t\t\t\t<div class=\"absolute inset-0 flex\">\n\t\t\t\t\t\t\t\t\t<!-- Sidebar -->\n\t\t\t\t\t\t\t\t\t<div class=\"bg-base-300 border-base-content/10 flex flex-col justify-between border-r px-2 py-3\">\n\t\t\t\t\t\t\t\t\t\t<!-- Logo placeholder -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-col gap-2\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/15 h-2 w-10 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<!-- Menu items -->\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"mt-2 flex flex-col gap-1.5\">\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/60 h-1.5 w-12 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-10 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-8 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-11 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<!-- Avatar placeholder at bottom -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/30 h-3 w-3 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-6 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<!-- Main content area -->\n\t\t\t\t\t\t\t\t\t<div class=\"flex flex-1 flex-col items-center justify-center gap-2 p-4\">\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/8 h-2 w-3/4 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-12 w-5/6\"></div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-6 w-2/3\"></div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t<!-- MODERN MINIMAP -->\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t@case ('modern') {\n\t\t\t\t\t\t\t\t<div class=\"absolute inset-0 flex flex-col gap-1 p-1.5\">\n\t\t\t\t\t\t\t\t\t<!-- Top navbar -->\n\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/70 rounded-field flex h-6 shrink-0 items-center justify-between px-2\">\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/30 h-1.5 w-8 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/20 h-2 w-2 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/20 h-2 w-2 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/30 h-2.5 w-2.5 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<!-- Body: sidebar + main -->\n\t\t\t\t\t\t\t\t\t<div class=\"flex min-h-0 flex-1 gap-1\">\n\t\t\t\t\t\t\t\t\t\t<!-- Sidebar (rounded) -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-300 border-base-content/10 rounded-field flex flex-col gap-1.5 border px-2 py-2\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/60 h-1.5 w-12 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-10 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-8 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-11 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<!-- Main content -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-1 flex-col justify-center gap-1.5 px-3\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/8 h-1.5 w-3/4 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-10 w-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-5 w-2/3\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<!-- Label -->\n\t\t\t\t\t<span stText=\"8\" stTextWeight=\"medium\" class=\"text-base-content\">{{ option.labelKey | translate }}</span>\n\t\t\t\t\t<span class=\"sr-only\" [id]=\"'st-layout-option-' + option.value + '-description'\">{{ option.descriptionKey | translate }}</span>\n\t\t\t\t</button>\n\t\t\t}\n\t\t</div>\n\t</st-dialog-content>\n</st-dialog>\n", dependencies: [{ kind: "component", type: DialogComponent, selector: "st-dialog", inputs: ["width", "xPosition", "yPosition", "opened", "stopPropagation"], outputs: ["openedChange", "closed", "clickOutside", "clicked", "pointerDown", "keyDownEnter", "keyDownSpace", "triggered"] }, { kind: "component", type: DialogTitleComponent, selector: "st-dialog-title" }, { kind: "component", type: DialogContentComponent, selector: "st-dialog-content" }, { kind: "component", type: IconComponent, selector: "st-icon", inputs: ["color", "size", "icon", "ariaLabel"] }, { kind: "directive", type: TextDirective, selector: "[stText]", inputs: ["stText", "stTextWeight", "stTextColor", "stTextOverflow", "stTextLineClamp", "stTextClass"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
111
|
+
}
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LayoutSwitcherComponent, decorators: [{
|
|
113
|
+
type: Component,
|
|
114
|
+
args: [{ selector: 'st-layout-switcher', changeDetection: ChangeDetectionStrategy.OnPush, imports: [DialogComponent, DialogTitleComponent, DialogContentComponent, IconComponent, TextDirective, TranslatePipe], template: "<st-dialog [(opened)]=\"opened\" width=\"lg\">\n\t<st-dialog-title>{{ 'sdk.layout.title' | translate }}</st-dialog-title>\n\t<st-dialog-content>\n\t\t<div class=\"grid grid-cols-2 gap-6 py-4\">\n\t\t\t@for (option of options; track option.value) {\n\t\t\t\t<!-- Preview Card -->\n\t\t\t\t<button\n\t\t\t\t\tclass=\"group rounded-box relative flex cursor-pointer flex-col items-center gap-3 border-2 p-4 transition-all duration-300 active:scale-[0.98]\"\n\t\t\t\t\t[class]=\"\n\t\t\t\t\t\tselectedLayout() === option.value\n\t\t\t\t\t\t\t? 'border-primary ring-primary/30 ring-4'\n\t\t\t\t\t\t\t: 'border-base-300 hover:border-primary/50 hover:ring-primary/15 hover:ring-2'\n\t\t\t\t\t\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t[attr.aria-pressed]=\"selectedLayout() === option.value\"\n\t\t\t\t\t[attr.data-st-layout-option]=\"option.value\"\n\t\t\t\t\t[attr.aria-describedby]=\"'st-layout-option-' + option.value + '-description'\"\n\t\t\t\t\t(click)=\"select(option.value)\"\n\t\t\t\t>\n\t\t\t\t\t<!-- Selected Checkmark Badge -->\n\t\t\t\t\t@if (selectedLayout() === option.value) {\n\t\t\t\t\t\t<div class=\"bg-primary text-primary-content absolute -top-2.5 -right-2.5 z-10 grid h-6 w-6 place-items-center rounded-full shadow-md\">\n\t\t\t\t\t\t\t<st-icon [icon]=\"checkIcon\" size=\"xs\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t}\n\n\t\t\t\t\t<!-- Minimap Container -->\n\t\t\t\t\t<div class=\"bg-base-200 rounded-box relative h-40 w-full overflow-hidden\">\n\t\t\t\t\t\t@switch (option.value) {\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t<!-- CLASSIC MINIMAP -->\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t@case ('classic') {\n\t\t\t\t\t\t\t\t<div class=\"absolute inset-0 flex\">\n\t\t\t\t\t\t\t\t\t<!-- Sidebar -->\n\t\t\t\t\t\t\t\t\t<div class=\"bg-base-300 border-base-content/10 flex flex-col justify-between border-r px-2 py-3\">\n\t\t\t\t\t\t\t\t\t\t<!-- Logo placeholder -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-col gap-2\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/15 h-2 w-10 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<!-- Menu items -->\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"mt-2 flex flex-col gap-1.5\">\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/60 h-1.5 w-12 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-10 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-8 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-11 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<!-- Avatar placeholder at bottom -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/30 h-3 w-3 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-6 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<!-- Main content area -->\n\t\t\t\t\t\t\t\t\t<div class=\"flex flex-1 flex-col items-center justify-center gap-2 p-4\">\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/8 h-2 w-3/4 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-12 w-5/6\"></div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-6 w-2/3\"></div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t<!-- MODERN MINIMAP -->\n\t\t\t\t\t\t\t<!-- ============================== -->\n\t\t\t\t\t\t\t@case ('modern') {\n\t\t\t\t\t\t\t\t<div class=\"absolute inset-0 flex flex-col gap-1 p-1.5\">\n\t\t\t\t\t\t\t\t\t<!-- Top navbar -->\n\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/70 rounded-field flex h-6 shrink-0 items-center justify-between px-2\">\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/30 h-1.5 w-8 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/20 h-2 w-2 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/20 h-2 w-2 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary-content/30 h-2.5 w-2.5 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<!-- Body: sidebar + main -->\n\t\t\t\t\t\t\t\t\t<div class=\"flex min-h-0 flex-1 gap-1\">\n\t\t\t\t\t\t\t\t\t\t<!-- Sidebar (rounded) -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-300 border-base-content/10 rounded-field flex flex-col gap-1.5 border px-2 py-2\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-primary/60 h-1.5 w-12 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-10 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-8 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/10 h-1.5 w-11 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<!-- Main content -->\n\t\t\t\t\t\t\t\t\t\t<div class=\"flex flex-1 flex-col justify-center gap-1.5 px-3\">\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/8 h-1.5 w-3/4 rounded-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-10 w-full\"></div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"bg-base-content/5 rounded-field h-5 w-2/3\"></div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<!-- Label -->\n\t\t\t\t\t<span stText=\"8\" stTextWeight=\"medium\" class=\"text-base-content\">{{ option.labelKey | translate }}</span>\n\t\t\t\t\t<span class=\"sr-only\" [id]=\"'st-layout-option-' + option.value + '-description'\">{{ option.descriptionKey | translate }}</span>\n\t\t\t\t</button>\n\t\t\t}\n\t\t</div>\n\t</st-dialog-content>\n</st-dialog>\n" }]
|
|
115
|
+
}] });
|
|
116
|
+
|
|
117
|
+
const DEFAULT_MENU_TOP_LEVEL_GROUPS = 'collapsible';
|
|
118
|
+
const DEFAULT_MENU_ACTIVE_MATCH = 'route';
|
|
119
|
+
/** True when the item has at least one child; `children: []` counts as a leaf. */
|
|
120
|
+
function menuItemHasChildren(item) {
|
|
121
|
+
return (item.children?.length ?? 0) > 0;
|
|
122
|
+
}
|
|
123
|
+
function walkMenuItems(items, visit, depth = 1) {
|
|
124
|
+
for (const item of items) {
|
|
125
|
+
visit(item, depth);
|
|
126
|
+
if (item.children?.length) {
|
|
127
|
+
walkMenuItems(item.children, visit, depth + 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const LAYOUT_ACCOUNT = new InjectionToken('LAYOUT_ACCOUNT');
|
|
133
|
+
/**
|
|
134
|
+
* Supplies the account used by `st-user-menu`. `factory` runs in an injection context, so it can
|
|
135
|
+
* `inject()` the app's session service.
|
|
136
|
+
*/
|
|
137
|
+
function provideLayoutAccount(factory) {
|
|
138
|
+
return { provide: LAYOUT_ACCOUNT, useFactory: factory };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const SCHEME_ICONS = {
|
|
142
|
+
system: matComputerOutline,
|
|
143
|
+
light: matLightModeOutline,
|
|
144
|
+
dark: matDarkModeOutline,
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Account menu of the SDK layouts: the user's avatar opens account actions (change password, logout)
|
|
148
|
+
* and preferences (language, color scheme, theme, layout). The account comes from `provideLayoutAccount`.
|
|
149
|
+
*/
|
|
150
|
+
class UserMenuComponent {
|
|
151
|
+
account = inject(LAYOUT_ACCOUNT);
|
|
152
|
+
layoutService = inject(LayoutService);
|
|
153
|
+
themeService = inject(ThemeService);
|
|
154
|
+
translationService = inject(TranslationService);
|
|
155
|
+
translateService = inject(TranslateService);
|
|
156
|
+
variant = input('sidebar');
|
|
157
|
+
/** Sidebar variant only: shows the avatar without name, role or chevron. */
|
|
158
|
+
collapsed = input(false);
|
|
159
|
+
/** Shows the language option (also needs more than one language). */
|
|
160
|
+
showLanguageSelector = input(true);
|
|
161
|
+
/** Shows the color scheme option (also needs more than one scheme). */
|
|
162
|
+
showSchemeSelector = input(true);
|
|
163
|
+
/** Shows the theme option (also needs more than one theme). */
|
|
164
|
+
showThemeSelector = input(true);
|
|
165
|
+
/** Shows the layout option (also needs more than one layout). */
|
|
166
|
+
showLayoutSelector = input(true);
|
|
167
|
+
class = input('');
|
|
168
|
+
openLayoutSwitcher = output();
|
|
169
|
+
openChange = output();
|
|
170
|
+
/** Ticks on any translation change, including hosts that drive ngx-translate directly. */
|
|
171
|
+
translationEvents = toSignal(merge(this.translateService.onLangChange, this.translateService.onTranslationChange, this.translateService.onFallbackLangChange), { initialValue: null });
|
|
172
|
+
i18n = computed(() => [this.translationService.changes(), this.translationEvents()]);
|
|
173
|
+
view = signal('options');
|
|
174
|
+
backButton = viewChild('backButton', { read: ElementRef });
|
|
175
|
+
optionsView = viewChild('optionsView', { read: ElementRef });
|
|
176
|
+
/** The submenu just left, so focus can return to the option that opened it. */
|
|
177
|
+
returnFocusTo = null;
|
|
178
|
+
user = this.account.user;
|
|
179
|
+
canChangePassword = !!this.account.changePassword;
|
|
180
|
+
compact = computed(() => this.variant() === 'sidebar' && this.collapsed());
|
|
181
|
+
triggerLabel = computed(() => {
|
|
182
|
+
this.i18n();
|
|
183
|
+
const user = this.user();
|
|
184
|
+
const menu = this.translationService.instant('sdk.layout.account_menu');
|
|
185
|
+
return [user?.displayName, user?.role, menu].filter(Boolean).join(', ');
|
|
186
|
+
});
|
|
187
|
+
languages = computed(() => {
|
|
188
|
+
this.i18n();
|
|
189
|
+
return this.translationService
|
|
190
|
+
.getAvailableLanguagesConfig()
|
|
191
|
+
.map(({ code }) => ({ value: code, label: this.translationService.getLocalizedLanguageName(code) }));
|
|
192
|
+
});
|
|
193
|
+
schemes = computed(() => {
|
|
194
|
+
this.i18n();
|
|
195
|
+
return this.themeService.getAvailableSchemes().map((scheme) => ({ value: scheme, label: this.themeService.getLocalizedSchemeName(scheme) }));
|
|
196
|
+
});
|
|
197
|
+
themes = computed(() => {
|
|
198
|
+
this.i18n();
|
|
199
|
+
return this.themeService.getAvailableThemes().map((theme) => ({ value: theme, label: this.themeService.getLocalizedThemeName(theme) }));
|
|
200
|
+
});
|
|
201
|
+
currentLanguage = this.translationService.currentLanguage;
|
|
202
|
+
currentScheme = this.themeService.selectedScheme;
|
|
203
|
+
currentTheme = this.themeService.selectedTheme;
|
|
204
|
+
hasLanguageSelector = computed(() => this.showLanguageSelector() && this.languages().length > 1);
|
|
205
|
+
hasSchemeSelector = computed(() => this.showSchemeSelector() && this.schemes().length > 1);
|
|
206
|
+
hasThemeSelector = computed(() => this.showThemeSelector() && this.themes().length > 1);
|
|
207
|
+
hasLayoutSelector = computed(() => this.showLayoutSelector() && this.layoutService.options.length > 1);
|
|
208
|
+
hasPreferences = computed(() => this.hasLanguageSelector() || this.hasSchemeSelector() || this.hasThemeSelector() || this.hasLayoutSelector());
|
|
209
|
+
submenu = computed(() => {
|
|
210
|
+
switch (this.view()) {
|
|
211
|
+
case 'language':
|
|
212
|
+
return {
|
|
213
|
+
titleKey: 'sdk.layout.languages',
|
|
214
|
+
choices: this.languages(),
|
|
215
|
+
current: this.currentLanguage(),
|
|
216
|
+
select: (code) => this.translationService.setLanguage(code),
|
|
217
|
+
};
|
|
218
|
+
case 'scheme':
|
|
219
|
+
return {
|
|
220
|
+
titleKey: 'sdk.layout.schemes',
|
|
221
|
+
choices: this.schemes(),
|
|
222
|
+
current: this.currentScheme(),
|
|
223
|
+
select: (scheme) => this.themeService.setScheme(scheme),
|
|
224
|
+
};
|
|
225
|
+
case 'theme':
|
|
226
|
+
return {
|
|
227
|
+
titleKey: 'sdk.layout.themes',
|
|
228
|
+
choices: this.themes(),
|
|
229
|
+
current: this.currentTheme(),
|
|
230
|
+
select: (theme) => this.themeService.setTheme(theme),
|
|
231
|
+
};
|
|
232
|
+
default:
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
hostClass = computed(() => cn(this.variant() === 'sidebar' ? 'block w-full' : 'inline-block', this.class()));
|
|
237
|
+
triggerClass = computed(() => cn('*:h-auto *:min-h-0 *:transition-all *:duration-300', {
|
|
238
|
+
'w-full *:w-full *:justify-between *:px-3 *:py-1.5': this.variant() === 'sidebar' && !this.compact(),
|
|
239
|
+
'*:w-10 *:min-w-10 *:justify-center *:p-0': this.compact(),
|
|
240
|
+
'*:gap-2 *:px-2 *:py-1': this.variant() === 'navbar',
|
|
241
|
+
}));
|
|
242
|
+
icons = {
|
|
243
|
+
back: matChevronLeft,
|
|
244
|
+
layout: matDashboardCustomizeOutline,
|
|
245
|
+
language: matLanguageOutline,
|
|
246
|
+
logout: matLogoutOutline,
|
|
247
|
+
password: matPasswordOutline,
|
|
248
|
+
person: matPersonOutline,
|
|
249
|
+
theme: matColorLensOutline,
|
|
250
|
+
};
|
|
251
|
+
constructor() {
|
|
252
|
+
afterRenderEffect(() => {
|
|
253
|
+
if (this.view() !== 'options') {
|
|
254
|
+
this.backButton()?.nativeElement.querySelector('button')?.focus();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const opener = this.returnFocusTo;
|
|
258
|
+
const options = this.optionsView()?.nativeElement;
|
|
259
|
+
if (opener && options) {
|
|
260
|
+
this.returnFocusTo = null;
|
|
261
|
+
options.querySelector(`[data-st-user-menu-option="${opener}"] li`)?.focus();
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Enter on a submenu entry swaps the view and focuses Back before the key sequence ends; without
|
|
267
|
+
* this, the browser's implicit Enter activation lands on Back and returns to the options at once.
|
|
268
|
+
* It listens on the document, which outlives the swap: the entry's own listeners are torn down
|
|
269
|
+
* with the options view while the event is still bubbling, and the overlay is outside the host.
|
|
270
|
+
*/
|
|
271
|
+
preventSubmenuEnter(event) {
|
|
272
|
+
const entry = event.target?.closest('[data-st-user-menu-option]')?.getAttribute('data-st-user-menu-option');
|
|
273
|
+
if (entry === 'language' || entry === 'scheme' || entry === 'theme') {
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
schemeIcon(scheme) {
|
|
278
|
+
return SCHEME_ICONS[scheme] ?? matComputerOutline;
|
|
279
|
+
}
|
|
280
|
+
show(view) {
|
|
281
|
+
this.returnFocusTo = view === 'options' && this.view() !== 'options' ? this.view() : null;
|
|
282
|
+
this.view.set(view);
|
|
283
|
+
}
|
|
284
|
+
handleOpenChange(open) {
|
|
285
|
+
if (open) {
|
|
286
|
+
this.returnFocusTo = null;
|
|
287
|
+
this.view.set('options');
|
|
288
|
+
}
|
|
289
|
+
this.openChange.emit(open);
|
|
290
|
+
}
|
|
291
|
+
changePassword() {
|
|
292
|
+
this.account.changePassword?.();
|
|
293
|
+
}
|
|
294
|
+
logout() {
|
|
295
|
+
this.account.logout();
|
|
296
|
+
}
|
|
297
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: UserMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
298
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: UserMenuComponent, isStandalone: true, selector: "st-user-menu", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, showLanguageSelector: { classPropertyName: "showLanguageSelector", publicName: "showLanguageSelector", isSignal: true, isRequired: false, transformFunction: null }, showSchemeSelector: { classPropertyName: "showSchemeSelector", publicName: "showSchemeSelector", isSignal: true, isRequired: false, transformFunction: null }, showThemeSelector: { classPropertyName: "showThemeSelector", publicName: "showThemeSelector", isSignal: true, isRequired: false, transformFunction: null }, showLayoutSelector: { classPropertyName: "showLayoutSelector", publicName: "showLayoutSelector", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { openLayoutSwitcher: "openLayoutSwitcher", openChange: "openChange" }, host: { listeners: { "document:keydown.enter": "preventSubmenuEnter($event)" }, properties: { "class": "hostClass()" } }, viewQueries: [{ propertyName: "backButton", first: true, predicate: ["backButton"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "optionsView", first: true, predicate: ["optionsView"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: "@let sidebar = variant() === 'sidebar';\n<st-dropdown [class]=\"sidebar ? 'block w-full' : 'inline-block'\" (openChange)=\"handleOpenChange($event)\">\n\t<st-dropdown-trigger\n\t\t[class]=\"sidebar ? 'block w-full *:w-full' : ''\"\n\t\toriginX=\"end\"\n\t\toriginY=\"bottom\"\n\t\t[overlayX]=\"sidebar ? 'start' : 'end'\"\n\t\t[overlayY]=\"sidebar ? 'bottom' : 'top'\"\n\t>\n\t\t<st-button variant=\"base\" [ghost]=\"true\" [block]=\"sidebar && !compact()\" [class]=\"triggerClass()\" data-st-user-menu-trigger>\n\t\t\t<span class=\"sr-only\">{{ triggerLabel() }}</span>\n\t\t\t@if (user(); as currentUser) {\n\t\t\t\t<st-avatar\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclass=\"[&_.avatar>div]:text-primary-content [&_span]:text-nowrap\"\n\t\t\t\t\t[class.p-1]=\"sidebar\"\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t[shape]=\"sidebar ? 'square' : 'rounded'\"\n\t\t\t\t\t[ring]=\"sidebar\"\n\t\t\t\t\t[user]=\"currentUser\"\n\t\t\t\t\t[showNameAndRole]=\"!compact()\"\n\t\t\t\t/>\n\t\t\t} @else {\n\t\t\t\t<st-icon [icon]=\"icons.person\" />\n\t\t\t}\n\t\t\t@if (sidebar && !compact()) {\n\t\t\t\t<st-dropdown-chevron aria-hidden=\"true\" position=\"right\" size=\"auto\" />\n\t\t\t}\n\t\t</st-button>\n\t</st-dropdown-trigger>\n\t<st-dropdown-content class=\"min-w-64\">\n\t\t@if (submenu(); as menu) {\n\t\t\t<div class=\"animate-morph-in\" [attr.data-st-user-menu-view]=\"view()\">\n\t\t\t\t<div class=\"inline-flex items-center gap-2 py-1.5 ps-2\">\n\t\t\t\t\t<st-button\n\t\t\t\t\t\t#backButton\n\t\t\t\t\t\tclass=\"*:text-sm\"\n\t\t\t\t\t\tvariant=\"base\"\n\t\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\t\t[ghost]=\"true\"\n\t\t\t\t\t\t[circle]=\"true\"\n\t\t\t\t\t\t[icon]=\"icons.back\"\n\t\t\t\t\t\t(triggered)=\"show('options')\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"sr-only\">{{ 'sdk.layout.back' | translate }}</span>\n\t\t\t\t\t</st-button>\n\t\t\t\t\t<span stText=\"7\" stTextWeight=\"medium\">{{ menu.titleKey | translate }}</span>\n\t\t\t\t</div>\n\t\t\t\t<st-dropdown-separator />\n\t\t\t\t@for (choice of menu.choices; track choice.value) {\n\t\t\t\t\t<st-dropdown-item-radio\n\t\t\t\t\t\t[value]=\"choice.value\"\n\t\t\t\t\t\t[checked]=\"menu.current === choice.value\"\n\t\t\t\t\t\t[closeOnSelect]=\"false\"\n\t\t\t\t\t\t[attr.data-st-user-menu-choice]=\"choice.value\"\n\t\t\t\t\t\t(checkedChanged)=\"menu.select($event)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t@if (view() === 'scheme') {\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"schemeIcon(choice.value)\" />\n\t\t\t\t\t\t\t\t<span>{{ choice.label }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t<span>{{ choice.label }}</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t</st-dropdown-item-radio>\n\t\t\t\t}\n\t\t\t</div>\n\t\t} @else {\n\t\t\t<div #optionsView class=\"animate-morph-in\" data-st-user-menu-view=\"options\">\n\t\t\t\t@if (canChangePassword) {\n\t\t\t\t\t<st-dropdown-label class=\"text-base-content/80 font-semibold\">{{ 'sdk.layout.account' | translate }}</st-dropdown-label>\n\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"change-password\" (selected)=\"changePassword()\">\n\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t<st-icon [icon]=\"icons.password\" />\n\t\t\t\t\t\t\t<span>{{ 'sdk.layout.change_password' | translate }}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t<st-dropdown-separator />\n\t\t\t\t}\n\t\t\t\t@if (hasPreferences()) {\n\t\t\t\t\t<st-dropdown-label class=\"text-base-content/80 font-semibold\">{{ 'sdk.layout.preferences' | translate }}</st-dropdown-label>\n\t\t\t\t\t@if (hasLanguageSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"language\" [closeOnSelect]=\"false\" (selected)=\"show('language')\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"icons.language\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.language' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t@if (hasSchemeSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"scheme\" [closeOnSelect]=\"false\" (selected)=\"show('scheme')\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"schemeIcon(currentScheme())\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.scheme' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t@if (hasThemeSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"theme\" [closeOnSelect]=\"false\" (selected)=\"show('theme')\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"icons.theme\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.theme' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t@if (hasLayoutSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"layout\" (selected)=\"openLayoutSwitcher.emit()\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"icons.layout\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.layout' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t<st-dropdown-separator />\n\t\t\t\t}\n\t\t\t\t<st-dropdown-item class=\"text-error\" data-st-user-menu-option=\"logout\" (selected)=\"logout()\">\n\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t<st-icon [icon]=\"icons.logout\" />\n\t\t\t\t\t\t<span>{{ 'sdk.layout.logout' | translate }}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</st-dropdown-item>\n\t\t\t</div>\n\t\t}\n\t</st-dropdown-content>\n</st-dropdown>\n", dependencies: [{ kind: "component", type: AvatarComponent, selector: "st-avatar", inputs: ["variant", "shape", "size", "ring", "presence", "user", "image", "showNameAndRole"] }, { kind: "component", type: ButtonComponent, selector: "st-button", inputs: ["variant", "ghost", "outline", "link", "soft", "dash", "wide", "circle", "square", "glass", "block", "loader", "size", "shadow", "focusable", "icon", "iconPosition", "type", "disabled", "stopPropagation", "ariaLabel", "ariaExpanded", "ariaPressed"], outputs: ["clicked", "pointerDown", "keyDownEnter", "keyDownSpace", "triggered"] }, { kind: "component", type: DropdownComponent, selector: "st-dropdown", inputs: ["open"], outputs: ["openChange", "opened", "closed"], exportAs: ["stDropdown"] }, { kind: "component", type: DropdownTriggerComponent, selector: "st-dropdown-trigger", inputs: ["offsetX", "offsetY", "originX", "originY", "overlayX", "overlayY", "fallbacks", "stopPropagation", "triggerTabIndex"], outputs: ["opened", "closed", "clicked", "pointerDown", "keyDownEnter", "keyDownSpace", "triggered"] }, { kind: "component", type: DropdownContentComponent, selector: "st-dropdown-content", inputs: ["class", "size", "shadow"], outputs: ["closeRequested"], exportAs: ["dropdownContent"] }, { kind: "component", type: DropdownItemComponent, selector: "st-dropdown-item", inputs: ["active", "class", "disabled", "closeOnSelect", "stopPropagation"], outputs: ["selected", "clicked", "keyDownEnter", "keyDownSpace", "triggered"] }, { kind: "component", type: DropdownItemRadioComponent, selector: "st-dropdown-item-radio", inputs: ["checked", "value", "disabled", "indicator", "showIndicator", "class", "closeOnSelect", "stopPropagation"], outputs: ["checkedChanged", "triggered", "clicked", "keyDownEnter", "keyDownSpace"] }, { kind: "component", type: DropdownLabelComponent, selector: "st-dropdown-label", inputs: ["class"] }, { kind: "component", type: DropdownSeparatorComponent, selector: "st-dropdown-separator" }, { kind: "component", type: DropdownChevronComponent, selector: "st-dropdown-chevron", inputs: ["icon", "class", "size", "color", "position"] }, { kind: "component", type: IconComponent, selector: "st-icon", inputs: ["color", "size", "icon", "ariaLabel"] }, { kind: "directive", type: TextDirective, selector: "[stText]", inputs: ["stText", "stTextWeight", "stTextColor", "stTextOverflow", "stTextLineClamp", "stTextClass"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
299
|
+
}
|
|
300
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: UserMenuComponent, decorators: [{
|
|
301
|
+
type: Component,
|
|
302
|
+
args: [{ selector: 'st-user-menu', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
303
|
+
AvatarComponent,
|
|
304
|
+
ButtonComponent,
|
|
305
|
+
DropdownComponent,
|
|
306
|
+
DropdownTriggerComponent,
|
|
307
|
+
DropdownContentComponent,
|
|
308
|
+
DropdownItemComponent,
|
|
309
|
+
DropdownItemRadioComponent,
|
|
310
|
+
DropdownLabelComponent,
|
|
311
|
+
DropdownSeparatorComponent,
|
|
312
|
+
DropdownChevronComponent,
|
|
313
|
+
IconComponent,
|
|
314
|
+
TextDirective,
|
|
315
|
+
TranslatePipe,
|
|
316
|
+
], host: {
|
|
317
|
+
'[class]': 'hostClass()',
|
|
318
|
+
'(document:keydown.enter)': 'preventSubmenuEnter($event)',
|
|
319
|
+
}, template: "@let sidebar = variant() === 'sidebar';\n<st-dropdown [class]=\"sidebar ? 'block w-full' : 'inline-block'\" (openChange)=\"handleOpenChange($event)\">\n\t<st-dropdown-trigger\n\t\t[class]=\"sidebar ? 'block w-full *:w-full' : ''\"\n\t\toriginX=\"end\"\n\t\toriginY=\"bottom\"\n\t\t[overlayX]=\"sidebar ? 'start' : 'end'\"\n\t\t[overlayY]=\"sidebar ? 'bottom' : 'top'\"\n\t>\n\t\t<st-button variant=\"base\" [ghost]=\"true\" [block]=\"sidebar && !compact()\" [class]=\"triggerClass()\" data-st-user-menu-trigger>\n\t\t\t<span class=\"sr-only\">{{ triggerLabel() }}</span>\n\t\t\t@if (user(); as currentUser) {\n\t\t\t\t<st-avatar\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclass=\"[&_.avatar>div]:text-primary-content [&_span]:text-nowrap\"\n\t\t\t\t\t[class.p-1]=\"sidebar\"\n\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t[shape]=\"sidebar ? 'square' : 'rounded'\"\n\t\t\t\t\t[ring]=\"sidebar\"\n\t\t\t\t\t[user]=\"currentUser\"\n\t\t\t\t\t[showNameAndRole]=\"!compact()\"\n\t\t\t\t/>\n\t\t\t} @else {\n\t\t\t\t<st-icon [icon]=\"icons.person\" />\n\t\t\t}\n\t\t\t@if (sidebar && !compact()) {\n\t\t\t\t<st-dropdown-chevron aria-hidden=\"true\" position=\"right\" size=\"auto\" />\n\t\t\t}\n\t\t</st-button>\n\t</st-dropdown-trigger>\n\t<st-dropdown-content class=\"min-w-64\">\n\t\t@if (submenu(); as menu) {\n\t\t\t<div class=\"animate-morph-in\" [attr.data-st-user-menu-view]=\"view()\">\n\t\t\t\t<div class=\"inline-flex items-center gap-2 py-1.5 ps-2\">\n\t\t\t\t\t<st-button\n\t\t\t\t\t\t#backButton\n\t\t\t\t\t\tclass=\"*:text-sm\"\n\t\t\t\t\t\tvariant=\"base\"\n\t\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\t\t[ghost]=\"true\"\n\t\t\t\t\t\t[circle]=\"true\"\n\t\t\t\t\t\t[icon]=\"icons.back\"\n\t\t\t\t\t\t(triggered)=\"show('options')\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"sr-only\">{{ 'sdk.layout.back' | translate }}</span>\n\t\t\t\t\t</st-button>\n\t\t\t\t\t<span stText=\"7\" stTextWeight=\"medium\">{{ menu.titleKey | translate }}</span>\n\t\t\t\t</div>\n\t\t\t\t<st-dropdown-separator />\n\t\t\t\t@for (choice of menu.choices; track choice.value) {\n\t\t\t\t\t<st-dropdown-item-radio\n\t\t\t\t\t\t[value]=\"choice.value\"\n\t\t\t\t\t\t[checked]=\"menu.current === choice.value\"\n\t\t\t\t\t\t[closeOnSelect]=\"false\"\n\t\t\t\t\t\t[attr.data-st-user-menu-choice]=\"choice.value\"\n\t\t\t\t\t\t(checkedChanged)=\"menu.select($event)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t@if (view() === 'scheme') {\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"schemeIcon(choice.value)\" />\n\t\t\t\t\t\t\t\t<span>{{ choice.label }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t<span>{{ choice.label }}</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t</st-dropdown-item-radio>\n\t\t\t\t}\n\t\t\t</div>\n\t\t} @else {\n\t\t\t<div #optionsView class=\"animate-morph-in\" data-st-user-menu-view=\"options\">\n\t\t\t\t@if (canChangePassword) {\n\t\t\t\t\t<st-dropdown-label class=\"text-base-content/80 font-semibold\">{{ 'sdk.layout.account' | translate }}</st-dropdown-label>\n\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"change-password\" (selected)=\"changePassword()\">\n\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t<st-icon [icon]=\"icons.password\" />\n\t\t\t\t\t\t\t<span>{{ 'sdk.layout.change_password' | translate }}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t<st-dropdown-separator />\n\t\t\t\t}\n\t\t\t\t@if (hasPreferences()) {\n\t\t\t\t\t<st-dropdown-label class=\"text-base-content/80 font-semibold\">{{ 'sdk.layout.preferences' | translate }}</st-dropdown-label>\n\t\t\t\t\t@if (hasLanguageSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"language\" [closeOnSelect]=\"false\" (selected)=\"show('language')\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"icons.language\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.language' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t@if (hasSchemeSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"scheme\" [closeOnSelect]=\"false\" (selected)=\"show('scheme')\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"schemeIcon(currentScheme())\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.scheme' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t@if (hasThemeSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"theme\" [closeOnSelect]=\"false\" (selected)=\"show('theme')\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"icons.theme\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.theme' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t@if (hasLayoutSelector()) {\n\t\t\t\t\t\t<st-dropdown-item data-st-user-menu-option=\"layout\" (selected)=\"openLayoutSwitcher.emit()\">\n\t\t\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<st-icon [icon]=\"icons.layout\" />\n\t\t\t\t\t\t\t\t<span>{{ 'sdk.layout.layout' | translate }}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</st-dropdown-item>\n\t\t\t\t\t}\n\t\t\t\t\t<st-dropdown-separator />\n\t\t\t\t}\n\t\t\t\t<st-dropdown-item class=\"text-error\" data-st-user-menu-option=\"logout\" (selected)=\"logout()\">\n\t\t\t\t\t<div class=\"inline-flex items-center gap-2\">\n\t\t\t\t\t\t<st-icon [icon]=\"icons.logout\" />\n\t\t\t\t\t\t<span>{{ 'sdk.layout.logout' | translate }}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</st-dropdown-item>\n\t\t\t</div>\n\t\t}\n\t</st-dropdown-content>\n</st-dropdown>\n" }]
|
|
320
|
+
}], ctorParameters: () => [] });
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Top bar of the modern layout: the logo linking home, then any `[stNavbarEnd]` content and the
|
|
324
|
+
* account menu in a glass pill. The logo is the theme's `logo-modern` asset, else `logo`, for the
|
|
325
|
+
* resolved color scheme. It sits on the dark band of `bg-modern-gradient`: the logo and end regions
|
|
326
|
+
* (`data-st-navbar-band`) read `--color-primary-gradient-content` as their `--color-base-content`;
|
|
327
|
+
* the account menu panel opens in an overlay and keeps the page foreground.
|
|
328
|
+
*/
|
|
329
|
+
class NavbarComponent {
|
|
330
|
+
logo = injectLayoutLogo();
|
|
331
|
+
/** Route the logo links to. */
|
|
332
|
+
homeLink = input('/');
|
|
333
|
+
/** Shows the account menu pill at the end. */
|
|
334
|
+
showUserMenu = input(true);
|
|
335
|
+
/** Alt text of the logo; defaults to the localized theme name. */
|
|
336
|
+
logoAlt = input(null);
|
|
337
|
+
/** `st-user-menu` `showLanguageSelector`. */
|
|
338
|
+
showLanguageSelector = input(true);
|
|
339
|
+
/** `st-user-menu` `showSchemeSelector`. */
|
|
340
|
+
showSchemeSelector = input(true);
|
|
341
|
+
/** `st-user-menu` `showThemeSelector`. */
|
|
342
|
+
showThemeSelector = input(true);
|
|
343
|
+
/** `st-user-menu` `showLayoutSelector`. */
|
|
344
|
+
showLayoutSelector = input(true);
|
|
345
|
+
class = input('');
|
|
346
|
+
/** The account menu's layout option was picked; open `st-layout-switcher`. */
|
|
347
|
+
openLayoutSwitcher = output();
|
|
348
|
+
hostClass = computed(() => cn('flex h-full items-center justify-between gap-4', this.class()));
|
|
349
|
+
logoUrl = computed(() => this.logo.assetUrl('logo-modern') ?? this.logo.assetUrl('logo'));
|
|
350
|
+
logoLabel = this.logo.alt(this.logoAlt);
|
|
351
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NavbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
352
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: NavbarComponent, isStandalone: true, selector: "st-navbar", inputs: { homeLink: { classPropertyName: "homeLink", publicName: "homeLink", isSignal: true, isRequired: false, transformFunction: null }, showUserMenu: { classPropertyName: "showUserMenu", publicName: "showUserMenu", isSignal: true, isRequired: false, transformFunction: null }, logoAlt: { classPropertyName: "logoAlt", publicName: "logoAlt", isSignal: true, isRequired: false, transformFunction: null }, showLanguageSelector: { classPropertyName: "showLanguageSelector", publicName: "showLanguageSelector", isSignal: true, isRequired: false, transformFunction: null }, showSchemeSelector: { classPropertyName: "showSchemeSelector", publicName: "showSchemeSelector", isSignal: true, isRequired: false, transformFunction: null }, showThemeSelector: { classPropertyName: "showThemeSelector", publicName: "showThemeSelector", isSignal: true, isRequired: false, transformFunction: null }, showLayoutSelector: { classPropertyName: "showLayoutSelector", publicName: "showLayoutSelector", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { openLayoutSwitcher: "openLayoutSwitcher" }, host: { attributes: { "data-st-navbar": "" }, properties: { "class": "hostClass()" } }, ngImport: i0, template: "<a class=\"btn btn-ghost h-auto min-h-auto px-3 py-1.5\" [routerLink]=\"homeLink()\" data-st-navbar-home data-st-navbar-band>\n\t@if (logoUrl(); as logo) {\n\t\t<img [src]=\"logo\" [alt]=\"logoLabel()\" class=\"h-11 w-auto\" />\n\t} @else {\n\t\t<span class=\"font-semibold\">{{ logoLabel() }}</span>\n\t}\n</a>\n<div class=\"flex items-center gap-2\" data-st-navbar-band>\n\t<ng-content select=\"[stNavbarEnd]\" />\n\t@if (showUserMenu()) {\n\t\t<div class=\"glass border-base-content/20 rounded-box flex items-center border p-1.5\">\n\t\t\t<st-user-menu\n\t\t\t\tvariant=\"navbar\"\n\t\t\t\t[showLanguageSelector]=\"showLanguageSelector()\"\n\t\t\t\t[showSchemeSelector]=\"showSchemeSelector()\"\n\t\t\t\t[showThemeSelector]=\"showThemeSelector()\"\n\t\t\t\t[showLayoutSelector]=\"showLayoutSelector()\"\n\t\t\t\t(openLayoutSwitcher)=\"openLayoutSwitcher.emit()\"\n\t\t\t/>\n\t\t</div>\n\t}\n</div>\n", dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: UserMenuComponent, selector: "st-user-menu", inputs: ["variant", "collapsed", "showLanguageSelector", "showSchemeSelector", "showThemeSelector", "showLayoutSelector", "class"], outputs: ["openLayoutSwitcher", "openChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
353
|
+
}
|
|
354
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NavbarComponent, decorators: [{
|
|
355
|
+
type: Component,
|
|
356
|
+
args: [{ selector: 'st-navbar', changeDetection: ChangeDetectionStrategy.OnPush, imports: [RouterLink, UserMenuComponent], host: {
|
|
357
|
+
'[class]': 'hostClass()',
|
|
358
|
+
'data-st-navbar': '',
|
|
359
|
+
}, template: "<a class=\"btn btn-ghost h-auto min-h-auto px-3 py-1.5\" [routerLink]=\"homeLink()\" data-st-navbar-home data-st-navbar-band>\n\t@if (logoUrl(); as logo) {\n\t\t<img [src]=\"logo\" [alt]=\"logoLabel()\" class=\"h-11 w-auto\" />\n\t} @else {\n\t\t<span class=\"font-semibold\">{{ logoLabel() }}</span>\n\t}\n</a>\n<div class=\"flex items-center gap-2\" data-st-navbar-band>\n\t<ng-content select=\"[stNavbarEnd]\" />\n\t@if (showUserMenu()) {\n\t\t<div class=\"glass border-base-content/20 rounded-box flex items-center border p-1.5\">\n\t\t\t<st-user-menu\n\t\t\t\tvariant=\"navbar\"\n\t\t\t\t[showLanguageSelector]=\"showLanguageSelector()\"\n\t\t\t\t[showSchemeSelector]=\"showSchemeSelector()\"\n\t\t\t\t[showThemeSelector]=\"showThemeSelector()\"\n\t\t\t\t[showLayoutSelector]=\"showLayoutSelector()\"\n\t\t\t\t(openLayoutSwitcher)=\"openLayoutSwitcher.emit()\"\n\t\t\t/>\n\t\t</div>\n\t}\n</div>\n" }]
|
|
360
|
+
}] });
|
|
361
|
+
|
|
362
|
+
const MENU_QUERY_PARAM = 'menu';
|
|
363
|
+
function trimTrailingSlashes(path) {
|
|
364
|
+
let end = path.length;
|
|
365
|
+
while (end > 1 && path[end - 1] === '/')
|
|
366
|
+
end--;
|
|
367
|
+
return path.slice(0, end);
|
|
368
|
+
}
|
|
369
|
+
/** Path of a route or URL without query or fragment, with a leading slash and no trailing slash. */
|
|
370
|
+
function normalizeMenuRoute(route) {
|
|
371
|
+
const clean = route?.split('#')[0].split('?')[0].trim();
|
|
372
|
+
if (!clean)
|
|
373
|
+
return null;
|
|
374
|
+
const withSlash = clean.startsWith('/') ? clean : `/${clean}`;
|
|
375
|
+
return trimTrailingSlashes(withSlash);
|
|
376
|
+
}
|
|
377
|
+
/** True when `url` is the known route or sits beneath it, ignoring query and fragment. */
|
|
378
|
+
function menuRoutesMatch(knownRoute, url) {
|
|
379
|
+
const known = normalizeMenuRoute(knownRoute);
|
|
380
|
+
const current = normalizeMenuRoute(url);
|
|
381
|
+
if (!known || !current)
|
|
382
|
+
return false;
|
|
383
|
+
return current === known || current.startsWith(`${known}/`);
|
|
384
|
+
}
|
|
385
|
+
/** Value of the `menu` query param carried by a URL, or null when absent or empty. */
|
|
386
|
+
function menuIdFromUrl(url) {
|
|
387
|
+
const query = url.split('#')[0].split('?')[1];
|
|
388
|
+
if (!query)
|
|
389
|
+
return null;
|
|
390
|
+
return new URLSearchParams(query).get(MENU_QUERY_PARAM) || null;
|
|
391
|
+
}
|
|
392
|
+
/** Query params that link a page to its own menu entry (`menu-id` active mode). */
|
|
393
|
+
function menuQueryParams(item) {
|
|
394
|
+
if (!item)
|
|
395
|
+
return {};
|
|
396
|
+
const id = String(item.id);
|
|
397
|
+
return id === '' ? {} : { [MENU_QUERY_PARAM]: id };
|
|
398
|
+
}
|
|
399
|
+
/** Query params for an item's link: its own `queryParams`, plus the `menu` param in `menu-id` mode. */
|
|
400
|
+
function menuLinkQueryParams(item, match) {
|
|
401
|
+
return { ...item.queryParams, ...(match === 'menu-id' ? menuQueryParams(item) : {}) };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const EMPTY_STATE = { trailIds: new Set(), activeId: null, rootItem: null };
|
|
405
|
+
/** `menu-id` mode: the URL's `menu` param equals the id and the route matches the path. */
|
|
406
|
+
function isActiveMenuItem(url, item) {
|
|
407
|
+
const activeId = menuIdFromUrl(url);
|
|
408
|
+
if (activeId === null || String(item.id) !== activeId)
|
|
409
|
+
return false;
|
|
410
|
+
return menuRoutesMatch(item.route, url);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* False when navigating to `url` must keep the current expansion: in `menu-id` mode a URL without a
|
|
414
|
+
* `menu` param says nothing about the menu, so the open groups stay as the user left them.
|
|
415
|
+
*/
|
|
416
|
+
function shouldSyncActiveBranch(url, match) {
|
|
417
|
+
return match !== 'menu-id' || menuIdFromUrl(url) !== null;
|
|
418
|
+
}
|
|
419
|
+
function trailScore(trail) {
|
|
420
|
+
const leaf = trail.at(-1);
|
|
421
|
+
return leaf ? (normalizeMenuRoute(leaf.route)?.length ?? 0) : -1;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Depth-first trail to the best matching item for `url`; the longest route prefix wins, the later item on a tie.
|
|
425
|
+
* A matching child beats its own parent on an equally long route.
|
|
426
|
+
*/
|
|
427
|
+
function findRouteTrail(items, url, ancestors = []) {
|
|
428
|
+
let best = [];
|
|
429
|
+
for (const item of items) {
|
|
430
|
+
const trail = [...ancestors, item];
|
|
431
|
+
const ownTrail = menuRoutesMatch(item.route, url) ? trail : [];
|
|
432
|
+
const childTrail = menuItemHasChildren(item) ? findRouteTrail(item.children ?? [], url, trail) : [];
|
|
433
|
+
const candidate = childTrail.length > 0 && trailScore(childTrail) >= trailScore(ownTrail) ? childTrail : ownTrail;
|
|
434
|
+
if (candidate.length > 0 && trailScore(candidate) >= trailScore(best)) {
|
|
435
|
+
best = candidate;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return best;
|
|
439
|
+
}
|
|
440
|
+
/** First trail, depth-first, whose leaf satisfies `isActiveMenuItem`. */
|
|
441
|
+
function findMenuIdTrail(items, url, ancestors = []) {
|
|
442
|
+
for (const item of items) {
|
|
443
|
+
const trail = [...ancestors, item];
|
|
444
|
+
if (isActiveMenuItem(url, item))
|
|
445
|
+
return trail;
|
|
446
|
+
const childTrail = menuItemHasChildren(item) ? findMenuIdTrail(item.children ?? [], url, trail) : [];
|
|
447
|
+
if (childTrail.length > 0)
|
|
448
|
+
return childTrail;
|
|
449
|
+
}
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
452
|
+
function resolveActiveMenu(items, url, match = 'route') {
|
|
453
|
+
const trail = match === 'menu-id' ? findMenuIdTrail(items, url) : findRouteTrail(items, url);
|
|
454
|
+
const head = trail[0];
|
|
455
|
+
const leaf = trail.at(-1);
|
|
456
|
+
if (!head || !leaf)
|
|
457
|
+
return EMPTY_STATE;
|
|
458
|
+
return { trailIds: new Set(trail.map((item) => String(item.id))), activeId: String(leaf.id), rootItem: head };
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function nextToggleState(current) {
|
|
462
|
+
return current === 'closed' || current === 'closing' ? 'opening' : 'closing';
|
|
463
|
+
}
|
|
464
|
+
function stateAfterAnimationEnd(current) {
|
|
465
|
+
if (current === 'opening')
|
|
466
|
+
return 'open';
|
|
467
|
+
if (current === 'closing')
|
|
468
|
+
return 'closed';
|
|
469
|
+
return current;
|
|
470
|
+
}
|
|
471
|
+
/** The group content stays rendered while opening, open and closing, so the exit animation can play. */
|
|
472
|
+
function isExpandedState(state) {
|
|
473
|
+
return state !== 'closed';
|
|
474
|
+
}
|
|
475
|
+
function syncedState(current, wantsOpen, animate) {
|
|
476
|
+
if (!animate)
|
|
477
|
+
return wantsOpen ? 'open' : 'closed';
|
|
478
|
+
if (wantsOpen)
|
|
479
|
+
return current === 'open' || current === 'opening' ? current : 'opening';
|
|
480
|
+
return current === 'closed' || current === 'closing' ? current : 'closing';
|
|
481
|
+
}
|
|
482
|
+
function createMenuAnimationStore() {
|
|
483
|
+
const states = new Map();
|
|
484
|
+
const get = (id) => {
|
|
485
|
+
const key = String(id);
|
|
486
|
+
let current = states.get(key);
|
|
487
|
+
if (!current) {
|
|
488
|
+
current = signal('closed');
|
|
489
|
+
states.set(key, current);
|
|
490
|
+
}
|
|
491
|
+
return current;
|
|
492
|
+
};
|
|
493
|
+
return {
|
|
494
|
+
state: (id) => get(id).asReadonly(),
|
|
495
|
+
set: (id, value) => get(id).set(value),
|
|
496
|
+
toggle: (id) => get(id).update(nextToggleState),
|
|
497
|
+
animationEnd: (id) => get(id).update(stateAfterAnimationEnd),
|
|
498
|
+
isExpanded: (id) => isExpandedState(get(id)()),
|
|
499
|
+
sync: (items, openIds, options) => {
|
|
500
|
+
const animate = options?.animate ?? false;
|
|
501
|
+
walkMenuItems(items, (item) => {
|
|
502
|
+
if (!menuItemHasChildren(item))
|
|
503
|
+
return;
|
|
504
|
+
const wantsOpen = openIds.has(String(item.id));
|
|
505
|
+
get(item.id).update((current) => syncedState(current, wantsOpen, animate));
|
|
506
|
+
});
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** Lowercases, decomposes and strips combining marks so search ignores case and accents. */
|
|
512
|
+
function normalizeMenuSearchText(value) {
|
|
513
|
+
return value.toLowerCase().normalize('NFD').replaceAll(/\p{M}/gu, '');
|
|
514
|
+
}
|
|
515
|
+
/** Filters `items`, adding to `expandedIds` every group that matches or holds a match. */
|
|
516
|
+
function filterItems(items, needle, expandedIds) {
|
|
517
|
+
const result = [];
|
|
518
|
+
for (const item of items) {
|
|
519
|
+
const isGroup = menuItemHasChildren(item);
|
|
520
|
+
if (normalizeMenuSearchText(item.label).includes(needle)) {
|
|
521
|
+
result.push(item);
|
|
522
|
+
if (isGroup) {
|
|
523
|
+
expandedIds.add(String(item.id));
|
|
524
|
+
filterItems(item.children ?? [], needle, expandedIds);
|
|
525
|
+
}
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
const children = isGroup ? filterItems(item.children ?? [], needle, expandedIds) : [];
|
|
529
|
+
if (children.length === 0)
|
|
530
|
+
continue;
|
|
531
|
+
expandedIds.add(String(item.id));
|
|
532
|
+
result.push({ ...item, children });
|
|
533
|
+
}
|
|
534
|
+
return result;
|
|
535
|
+
}
|
|
536
|
+
function searchMenu(items, search) {
|
|
537
|
+
const needle = normalizeMenuSearchText(search.trim());
|
|
538
|
+
if (needle === '')
|
|
539
|
+
return { items, expandedIds: new Set() };
|
|
540
|
+
const expandedIds = new Set();
|
|
541
|
+
return { items: filterItems(items, needle, expandedIds), expandedIds };
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* `divider`: level-1 items with children become non-clickable labels followed by their children.
|
|
546
|
+
* `collapsible`: every top-level item stays a regular (possibly collapsible) item.
|
|
547
|
+
*/
|
|
548
|
+
function toMenuSections(items, mode = 'collapsible') {
|
|
549
|
+
return items.map((item) => {
|
|
550
|
+
if (mode === 'divider' && menuItemHasChildren(item)) {
|
|
551
|
+
return { kind: 'label', item, children: item.children ?? [] };
|
|
552
|
+
}
|
|
553
|
+
return { kind: 'item', item };
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
/** Items shown in the collapsed icon rail: divider mode flattens level-1 groups into their children. */
|
|
557
|
+
function toRailItems(items, mode = 'collapsible') {
|
|
558
|
+
if (mode !== 'divider')
|
|
559
|
+
return [...items];
|
|
560
|
+
return items.flatMap((item) => (menuItemHasChildren(item) ? (item.children ?? []) : [item]));
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Entry a collapsed-rail icon links to: the item itself when it is a leaf with a route, otherwise its
|
|
564
|
+
* first navigable descendant, depth-first. A group whose descendants have no route falls back to its
|
|
565
|
+
* own route. Null when nothing in the branch can be navigated to.
|
|
566
|
+
*/
|
|
567
|
+
function firstNavigableMenuItem(item) {
|
|
568
|
+
if (menuItemHasChildren(item)) {
|
|
569
|
+
for (const child of item.children ?? []) {
|
|
570
|
+
const target = firstNavigableMenuItem(child);
|
|
571
|
+
if (target)
|
|
572
|
+
return target;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return normalizeMenuRoute(item.route) ? item : null;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** Keyframes of the `animate-morph-in` / `animate-morph-out` utilities that open and close a group. */
|
|
579
|
+
const GROUP_ANIMATIONS = { opening: 'morphIn', closing: 'morphOut' };
|
|
580
|
+
/**
|
|
581
|
+
* Hover and pressed fills of entries that are not the current page: the press mixes `base-300` toward `base-content`.
|
|
582
|
+
* The inset primary focus ring falls below 3:1 against that fill in dark schemes, so a pressed ring uses `base-content`.
|
|
583
|
+
*/
|
|
584
|
+
const entryStateClass = cn('hover:bg-base-300 active:bg-[color-mix(in_oklch,var(--color-base-300)_80%,var(--color-base-content))]', 'active:focus-visible:outline-base-content');
|
|
585
|
+
/**
|
|
586
|
+
* Sidebar navigation shared by the classic and modern layouts: a search box, the menu tree and, when
|
|
587
|
+
* the sidebar is collapsed, an icon rail. Active entries follow the router URL.
|
|
588
|
+
*/
|
|
589
|
+
class SideMenuComponent {
|
|
590
|
+
router = inject(Router);
|
|
591
|
+
layoutService = inject(LayoutService);
|
|
592
|
+
host = inject(ElementRef);
|
|
593
|
+
injector = inject(Injector);
|
|
594
|
+
idPrefix = `st-side-menu-${generateUniqueId()}`;
|
|
595
|
+
groupIds = new Map();
|
|
596
|
+
store = createMenuAnimationStore();
|
|
597
|
+
/** Menu tree with labels already translated. */
|
|
598
|
+
items = input.required();
|
|
599
|
+
/** `divider`: level-1 groups render as section labels; `collapsible`: every group expands in place. */
|
|
600
|
+
topLevelGroups = input(DEFAULT_MENU_TOP_LEVEL_GROUPS);
|
|
601
|
+
/** `route`: the longest matching route is active; `menu-id`: the entry named by the URL's `menu` param. */
|
|
602
|
+
activeMatch = input(DEFAULT_MENU_ACTIVE_MATCH);
|
|
603
|
+
/**
|
|
604
|
+
* Overrides the visible state of `LayoutService.sidebarCollapsed()`, e.g. `[collapsed]="pinnedCollapsed && !hovered"`
|
|
605
|
+
* for a rail that expands while hovered. The pinned state itself is unchanged and still drives the collapse toggle.
|
|
606
|
+
*/
|
|
607
|
+
collapsed = input(undefined);
|
|
608
|
+
searchable = input(true);
|
|
609
|
+
/**
|
|
610
|
+
* Renders the footer button that pins the sidebar collapsed or open through `LayoutService.setSidebarCollapsed`.
|
|
611
|
+
* Its label, icon and action follow the pinned state, not the `collapsed` override, so a hover-expanded rail
|
|
612
|
+
* offers "expand" and pins the sidebar open; its placement follows the visible state.
|
|
613
|
+
*/
|
|
614
|
+
showCollapseToggle = input(true);
|
|
615
|
+
class = input('');
|
|
616
|
+
/**
|
|
617
|
+
* Text of the search box; `searchChange` emits each edit, so `[(search)]` binds it two-way. It clears on
|
|
618
|
+
* navigation and when the collapse toggle pins the sidebar collapsed (a hover rail that only collapses
|
|
619
|
+
* visually keeps it).
|
|
620
|
+
*/
|
|
621
|
+
search = model('');
|
|
622
|
+
/**
|
|
623
|
+
* The current page sits on `bg-primary`, so its focus ring switches to `primary-content` and moves
|
|
624
|
+
* 2px inside the edge: both sides of the ring are then the primary fill, in every theme and scheme.
|
|
625
|
+
* It is raised with a small shadow; hover and press mix the primary toward `base-content`, away from
|
|
626
|
+
* `primary-content`, and the press drops the shadow.
|
|
627
|
+
*/
|
|
628
|
+
activeLinkClass = cn('bg-primary text-primary-content shadow-shadow-primary shadow-sm active:shadow-none', 'hover:bg-[color-mix(in_oklch,var(--color-primary)_70%,var(--color-base-content))]', 'active:bg-[color-mix(in_oklch,var(--color-primary)_55%,var(--color-base-content))]', 'focus-visible:outline-primary-content focus-visible:-outline-offset-4');
|
|
629
|
+
inactiveLinkClass = cn(entryStateClass, 'focus-visible:outline-primary focus-visible:-outline-offset-2');
|
|
630
|
+
groupStateClass = entryStateClass;
|
|
631
|
+
chevronIcon = matKeyboardArrowDown;
|
|
632
|
+
fallbackIcon = matFolderOutline;
|
|
633
|
+
searchIcon = matSearchOutline;
|
|
634
|
+
collapseIcon = matMenuOpenOutline;
|
|
635
|
+
expandIcon = matMenuOutline;
|
|
636
|
+
url = toSignal(this.router.events.pipe(filter((event) => event instanceof NavigationEnd), map((event) => event.urlAfterRedirects), startWith(this.router.url)), { requireSync: true });
|
|
637
|
+
isPinnedCollapsed = this.layoutService.sidebarCollapsed.asReadonly();
|
|
638
|
+
isCollapsed = computed(() => this.collapsed() ?? this.isPinnedCollapsed());
|
|
639
|
+
hostClass = computed(() => cn('flex min-h-0 flex-1 flex-col', this.class()));
|
|
640
|
+
active = computed(() => resolveActiveMenu(this.items(), this.url(), this.activeMatch()));
|
|
641
|
+
searchResult = computed(() => searchMenu(this.items(), this.search()));
|
|
642
|
+
sections = computed(() => toMenuSections(this.searchResult().items, this.topLevelGroups()));
|
|
643
|
+
railEntries = computed(() => toRailItems(this.items(), this.topLevelGroups()).flatMap((item) => {
|
|
644
|
+
const target = firstNavigableMenuItem(item);
|
|
645
|
+
return target ? [{ item, target }] : [];
|
|
646
|
+
}));
|
|
647
|
+
constructor() {
|
|
648
|
+
effect(() => {
|
|
649
|
+
const items = this.items();
|
|
650
|
+
const url = this.url();
|
|
651
|
+
const query = this.search();
|
|
652
|
+
const match = this.activeMatch();
|
|
653
|
+
untracked(() => {
|
|
654
|
+
if (query.trim()) {
|
|
655
|
+
this.store.sync(items, searchMenu(items, query).expandedIds);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (!shouldSyncActiveBranch(url, match))
|
|
659
|
+
return;
|
|
660
|
+
this.store.sync(items, resolveActiveMenu(items, url, match).trailIds);
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
this.router.events
|
|
664
|
+
.pipe(filter((event) => event instanceof NavigationEnd), takeUntilDestroyed())
|
|
665
|
+
.subscribe(() => this.search.set(''));
|
|
666
|
+
}
|
|
667
|
+
hasChildren = menuItemHasChildren;
|
|
668
|
+
linkQueryParams(item) {
|
|
669
|
+
return menuLinkQueryParams(item, this.activeMatch());
|
|
670
|
+
}
|
|
671
|
+
isActive(item) {
|
|
672
|
+
return this.active().activeId === String(item.id);
|
|
673
|
+
}
|
|
674
|
+
isOnTrail(item) {
|
|
675
|
+
return this.active().trailIds.has(String(item.id));
|
|
676
|
+
}
|
|
677
|
+
/** `page` for the active link; `true` for a rail entry whose branch holds the active page. */
|
|
678
|
+
railCurrent(entry) {
|
|
679
|
+
if (this.isActive(entry.target))
|
|
680
|
+
return 'page';
|
|
681
|
+
return this.isOnTrail(entry.item) ? 'true' : null;
|
|
682
|
+
}
|
|
683
|
+
groupState(item) {
|
|
684
|
+
return this.store.state(item.id)();
|
|
685
|
+
}
|
|
686
|
+
/** Expanded while opening or open; the content stays rendered while it closes. */
|
|
687
|
+
isGroupExpanded(item) {
|
|
688
|
+
const state = this.groupState(item);
|
|
689
|
+
return state === 'opening' || state === 'open';
|
|
690
|
+
}
|
|
691
|
+
groupId(item) {
|
|
692
|
+
const key = String(item.id);
|
|
693
|
+
let id = this.groupIds.get(key);
|
|
694
|
+
if (!id) {
|
|
695
|
+
id = `${this.idPrefix}-group-${this.groupIds.size}`;
|
|
696
|
+
this.groupIds.set(key, id);
|
|
697
|
+
}
|
|
698
|
+
return id;
|
|
699
|
+
}
|
|
700
|
+
labelId(item) {
|
|
701
|
+
return `${this.groupId(item)}-label`;
|
|
702
|
+
}
|
|
703
|
+
toggleGroup(item) {
|
|
704
|
+
this.store.toggle(item.id);
|
|
705
|
+
if (this.prefersReducedMotion())
|
|
706
|
+
this.store.animationEnd(item.id);
|
|
707
|
+
}
|
|
708
|
+
/** `animationend` bubbles from nested groups: settle only this group's own open or close keyframes. */
|
|
709
|
+
onGroupAnimationEnd(event, item) {
|
|
710
|
+
if (event.target !== event.currentTarget)
|
|
711
|
+
return;
|
|
712
|
+
if (event.animationName !== GROUP_ANIMATIONS[this.groupState(item)])
|
|
713
|
+
return;
|
|
714
|
+
this.store.animationEnd(item.id);
|
|
715
|
+
}
|
|
716
|
+
toggleCollapsed() {
|
|
717
|
+
const collapsed = !this.isPinnedCollapsed();
|
|
718
|
+
this.layoutService.setSidebarCollapsed(collapsed);
|
|
719
|
+
if (collapsed)
|
|
720
|
+
this.search.set('');
|
|
721
|
+
}
|
|
722
|
+
/** The rail's search button expands the sidebar and moves focus into the search box. */
|
|
723
|
+
openSearch() {
|
|
724
|
+
this.layoutService.setSidebarCollapsed(false);
|
|
725
|
+
afterNextRender(() => this.host.nativeElement.querySelector('[data-st-side-menu-search] input')?.focus(), {
|
|
726
|
+
injector: this.injector,
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
prefersReducedMotion() {
|
|
730
|
+
return globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
731
|
+
}
|
|
732
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SideMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
733
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: SideMenuComponent, isStandalone: true, selector: "st-side-menu", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, topLevelGroups: { classPropertyName: "topLevelGroups", publicName: "topLevelGroups", isSignal: true, isRequired: false, transformFunction: null }, activeMatch: { classPropertyName: "activeMatch", publicName: "activeMatch", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, showCollapseToggle: { classPropertyName: "showCollapseToggle", publicName: "showCollapseToggle", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { search: "searchChange" }, host: { properties: { "class": "hostClass()", "attr.data-collapsed": "isCollapsed()" } }, ngImport: i0, template: "@let collapsedVar = isCollapsed();\n@let searchLabel = 'sdk.layout.search' | translate;\n\n<div class=\"flex min-h-0 flex-1 flex-col gap-4\">\n\t@if (searchable()) {\n\t\t<div\n\t\t\tclass=\"flex shrink-0 items-center\"\n\t\t\t[class.justify-center]=\"collapsedVar\"\n\t\t\t[attr.role]=\"collapsedVar ? null : 'search'\"\n\t\t\t[attr.aria-label]=\"collapsedVar ? null : searchLabel\"\n\t\t>\n\t\t\t@if (collapsedVar) {\n\t\t\t\t<st-tooltip [label]=\"searchLabel\" position=\"right\">\n\t\t\t\t\t<st-button\n\t\t\t\t\t\tdata-st-side-menu-search-trigger\n\t\t\t\t\t\tvariant=\"base\"\n\t\t\t\t\t\tsize=\"md\"\n\t\t\t\t\t\t[ghost]=\"true\"\n\t\t\t\t\t\t[circle]=\"true\"\n\t\t\t\t\t\t[icon]=\"searchIcon\"\n\t\t\t\t\t\t(triggered)=\"openSearch()\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"sr-only\">{{ searchLabel }}</span>\n\t\t\t\t\t</st-button>\n\t\t\t\t</st-tooltip>\n\t\t\t} @else {\n\t\t\t\t<st-input class=\"w-full\" data-st-side-menu-search [placeholder]=\"searchLabel\" [(value)]=\"search\">\n\t\t\t\t\t<st-input-content alignment=\"start\">\n\t\t\t\t\t\t<st-icon aria-hidden=\"true\" [icon]=\"searchIcon\" />\n\t\t\t\t\t</st-input-content>\n\t\t\t\t</st-input>\n\t\t\t}\n\t\t</div>\n\t\t<div class=\"bg-base-300 h-px shrink-0\" aria-hidden=\"true\"></div>\n\t}\n\n\t<nav class=\"min-h-0 flex-1 scrollbar-gutter-stable overflow-x-hidden overflow-y-auto\" [attr.aria-label]=\"'sdk.layout.navigation' | translate\">\n\t\t@if (collapsedVar) {\n\t\t\t<ul class=\"flex flex-col items-center gap-2 py-1\" data-st-side-menu-rail>\n\t\t\t\t@for (entry of railEntries(); track entry.item.id) {\n\t\t\t\t\t@let onTrail = isOnTrail(entry.item);\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<st-tooltip [label]=\"entry.item.label\" position=\"right\">\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclass=\"rounded-field grid size-10 place-items-center transition-[color,background-color,box-shadow] focus-visible:outline-2 motion-reduce:transition-none\"\n\t\t\t\t\t\t\t\t[class]=\"onTrail ? activeLinkClass : inactiveLinkClass\"\n\t\t\t\t\t\t\t\t[routerLink]=\"entry.target.route\"\n\t\t\t\t\t\t\t\t[queryParams]=\"linkQueryParams(entry.target)\"\n\t\t\t\t\t\t\t\t[attr.aria-current]=\"railCurrent(entry)\"\n\t\t\t\t\t\t\t\t[attr.aria-label]=\"entry.item.label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<st-icon aria-hidden=\"true\" [icon]=\"entry.item.icon || fallbackIcon\" size=\"md\" />\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</st-tooltip>\n\t\t\t\t\t</li>\n\t\t\t\t}\n\t\t\t</ul>\n\t\t} @else {\n\t\t\t<ul class=\"flex min-w-0 flex-col gap-1 pe-1\" data-st-side-menu-tree>\n\t\t\t\t@for (section of sections(); track section.item.id) {\n\t\t\t\t\t<li class=\"min-w-0\">\n\t\t\t\t\t\t@if (section.kind === 'label') {\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclass=\"text-base-content/60 block px-3 pt-4 pb-1 text-xs font-semibold tracking-wide uppercase select-none\"\n\t\t\t\t\t\t\t\tdata-st-side-menu-label\n\t\t\t\t\t\t\t\t[id]=\"labelId(section.item)\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{{ section.item.label }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<ul class=\"flex min-w-0 flex-col gap-1\" [attr.aria-labelledby]=\"labelId(section.item)\">\n\t\t\t\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"entries\" [ngTemplateOutletContext]=\"{ $implicit: section.children }\" />\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"entry\" [ngTemplateOutletContext]=\"{ $implicit: section.item }\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t</li>\n\t\t\t\t} @empty {\n\t\t\t\t\t<li class=\"text-base-content/60 px-3 py-2 text-sm\" role=\"status\">{{ 'sdk.layout.no_results' | translate }}</li>\n\t\t\t\t}\n\t\t\t</ul>\n\t\t}\n\t</nav>\n\n\t@if (showCollapseToggle()) {\n\t\t<div class=\"flex shrink-0 flex-col\">\n\t\t\t<div class=\"bg-base-300 h-px\" aria-hidden=\"true\"></div>\n\t\t\t@let pinnedCollapsedVar = isPinnedCollapsed();\n\t\t\t@let toggleLabel = (pinnedCollapsedVar ? 'sdk.layout.expand' : 'sdk.layout.collapse') | translate;\n\t\t\t<div class=\"flex items-center pt-4\" [class.justify-center]=\"collapsedVar\" [class.justify-end]=\"!collapsedVar\">\n\t\t\t\t<st-tooltip [label]=\"toggleLabel\" [position]=\"collapsedVar ? 'right' : 'top'\">\n\t\t\t\t\t<st-button\n\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tdata-st-side-menu-toggle\n\t\t\t\t\t\t[circle]=\"true\"\n\t\t\t\t\t\t[icon]=\"pinnedCollapsedVar ? expandIcon : collapseIcon\"\n\t\t\t\t\t\t(triggered)=\"toggleCollapsed()\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"sr-only\">{{ toggleLabel }}</span>\n\t\t\t\t\t</st-button>\n\t\t\t\t</st-tooltip>\n\t\t\t</div>\n\t\t</div>\n\t}\n</div>\n\n<ng-template #entries let-items>\n\t@for (item of items; track item.id) {\n\t\t<li class=\"min-w-0\">\n\t\t\t<ng-container [ngTemplateOutlet]=\"entry\" [ngTemplateOutletContext]=\"{ $implicit: item }\" />\n\t\t</li>\n\t}\n</ng-template>\n\n<ng-template #entry let-item>\n\t@if (hasChildren(item)) {\n\t\t@let state = groupState(item);\n\t\t@let onTrail = isOnTrail(item);\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"rounded-field focus-visible:outline-primary flex min-h-10 w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-2 text-start transition-[color,background-color,box-shadow] focus-visible:outline-2 focus-visible:-outline-offset-2 motion-reduce:transition-none\"\n\t\t\t[class]=\"groupStateClass\"\n\t\t\t[class.font-semibold]=\"onTrail\"\n\t\t\t[attr.aria-expanded]=\"isGroupExpanded(item)\"\n\t\t\t[attr.aria-controls]=\"groupId(item)\"\n\t\t\t(click)=\"toggleGroup(item)\"\n\t\t>\n\t\t\t@if (item.icon) {\n\t\t\t\t<st-icon aria-hidden=\"true\" class=\"shrink-0\" [icon]=\"item.icon\" size=\"md\" />\n\t\t\t}\n\t\t\t<span class=\"block min-w-0 flex-1 wrap-anywhere\">{{ item.label }}</span>\n\t\t\t<span data-st-chevron class=\"inline-flex size-[1.2em] shrink-0 items-center justify-center\">\n\t\t\t\t<st-icon aria-hidden=\"true\" [icon]=\"chevronIcon\" size=\"sm\" />\n\t\t\t</span>\n\t\t</button>\n\t\t<ul\n\t\t\tclass=\"data-[state=closing]:animate-morph-out data-[state=opening]:animate-morph-in border-base-300 ms-5 mt-1 flex min-w-0 flex-col gap-1 border-s ps-2\"\n\t\t\tdata-st-menu-group\n\t\t\t[id]=\"groupId(item)\"\n\t\t\t[attr.data-state]=\"state\"\n\t\t\t[hidden]=\"state === 'closed'\"\n\t\t\t(animationend)=\"onGroupAnimationEnd($event, item)\"\n\t\t>\n\t\t\t<ng-container [ngTemplateOutlet]=\"entries\" [ngTemplateOutletContext]=\"{ $implicit: item.children }\" />\n\t\t</ul>\n\t} @else {\n\t\t@let activeVar = isActive(item);\n\t\t<a\n\t\t\tclass=\"rounded-field flex min-h-10 w-full min-w-0 items-center gap-2 px-3 py-2 transition-[color,background-color,box-shadow] focus-visible:outline-2 motion-reduce:transition-none\"\n\t\t\t[class]=\"activeVar ? activeLinkClass : inactiveLinkClass\"\n\t\t\t[routerLink]=\"item.route\"\n\t\t\t[queryParams]=\"linkQueryParams(item)\"\n\t\t\t[attr.aria-current]=\"activeVar ? 'page' : null\"\n\t\t>\n\t\t\t@if (item.icon) {\n\t\t\t\t<st-icon aria-hidden=\"true\" class=\"shrink-0\" [icon]=\"item.icon\" size=\"md\" />\n\t\t\t}\n\t\t\t<span class=\"block min-w-0 flex-1 wrap-anywhere\">{{ item.label }}</span>\n\t\t</a>\n\t}\n</ng-template>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: ButtonComponent, selector: "st-button", inputs: ["variant", "ghost", "outline", "link", "soft", "dash", "wide", "circle", "square", "glass", "block", "loader", "size", "shadow", "focusable", "icon", "iconPosition", "type", "disabled", "stopPropagation", "ariaLabel", "ariaExpanded", "ariaPressed"], outputs: ["clicked", "pointerDown", "keyDownEnter", "keyDownSpace", "triggered"] }, { kind: "component", type: IconComponent, selector: "st-icon", inputs: ["color", "size", "icon", "ariaLabel"] }, { kind: "component", type: InputComponent, selector: "st-input", inputs: ["variant", "size", "label", "showOptional", "optionalText", "type", "name", "placeholder", "readonly", "focus", "onlyNumbers", "ghost", "value", "parentForm", "formControlName", "disabled", "stopPropagation", "debounceTime"], outputs: ["valueChange", "disabledChange", "keyDownEnter", "triggered", "clicked", "blurred", "valueDebounced"] }, { kind: "component", type: InputContentComponent, selector: "st-input-content", inputs: ["alignment"] }, { kind: "component", type: TooltipComponent, selector: "st-tooltip", inputs: ["variant", "position", "label", "icon", "iconPosition"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
734
|
+
}
|
|
735
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SideMenuComponent, decorators: [{
|
|
736
|
+
type: Component,
|
|
737
|
+
args: [{ selector: 'st-side-menu', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet, RouterLink, ButtonComponent, IconComponent, InputComponent, InputContentComponent, TooltipComponent, TranslatePipe], host: {
|
|
738
|
+
'[class]': 'hostClass()',
|
|
739
|
+
'[attr.data-collapsed]': 'isCollapsed()',
|
|
740
|
+
}, template: "@let collapsedVar = isCollapsed();\n@let searchLabel = 'sdk.layout.search' | translate;\n\n<div class=\"flex min-h-0 flex-1 flex-col gap-4\">\n\t@if (searchable()) {\n\t\t<div\n\t\t\tclass=\"flex shrink-0 items-center\"\n\t\t\t[class.justify-center]=\"collapsedVar\"\n\t\t\t[attr.role]=\"collapsedVar ? null : 'search'\"\n\t\t\t[attr.aria-label]=\"collapsedVar ? null : searchLabel\"\n\t\t>\n\t\t\t@if (collapsedVar) {\n\t\t\t\t<st-tooltip [label]=\"searchLabel\" position=\"right\">\n\t\t\t\t\t<st-button\n\t\t\t\t\t\tdata-st-side-menu-search-trigger\n\t\t\t\t\t\tvariant=\"base\"\n\t\t\t\t\t\tsize=\"md\"\n\t\t\t\t\t\t[ghost]=\"true\"\n\t\t\t\t\t\t[circle]=\"true\"\n\t\t\t\t\t\t[icon]=\"searchIcon\"\n\t\t\t\t\t\t(triggered)=\"openSearch()\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"sr-only\">{{ searchLabel }}</span>\n\t\t\t\t\t</st-button>\n\t\t\t\t</st-tooltip>\n\t\t\t} @else {\n\t\t\t\t<st-input class=\"w-full\" data-st-side-menu-search [placeholder]=\"searchLabel\" [(value)]=\"search\">\n\t\t\t\t\t<st-input-content alignment=\"start\">\n\t\t\t\t\t\t<st-icon aria-hidden=\"true\" [icon]=\"searchIcon\" />\n\t\t\t\t\t</st-input-content>\n\t\t\t\t</st-input>\n\t\t\t}\n\t\t</div>\n\t\t<div class=\"bg-base-300 h-px shrink-0\" aria-hidden=\"true\"></div>\n\t}\n\n\t<nav class=\"min-h-0 flex-1 scrollbar-gutter-stable overflow-x-hidden overflow-y-auto\" [attr.aria-label]=\"'sdk.layout.navigation' | translate\">\n\t\t@if (collapsedVar) {\n\t\t\t<ul class=\"flex flex-col items-center gap-2 py-1\" data-st-side-menu-rail>\n\t\t\t\t@for (entry of railEntries(); track entry.item.id) {\n\t\t\t\t\t@let onTrail = isOnTrail(entry.item);\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<st-tooltip [label]=\"entry.item.label\" position=\"right\">\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclass=\"rounded-field grid size-10 place-items-center transition-[color,background-color,box-shadow] focus-visible:outline-2 motion-reduce:transition-none\"\n\t\t\t\t\t\t\t\t[class]=\"onTrail ? activeLinkClass : inactiveLinkClass\"\n\t\t\t\t\t\t\t\t[routerLink]=\"entry.target.route\"\n\t\t\t\t\t\t\t\t[queryParams]=\"linkQueryParams(entry.target)\"\n\t\t\t\t\t\t\t\t[attr.aria-current]=\"railCurrent(entry)\"\n\t\t\t\t\t\t\t\t[attr.aria-label]=\"entry.item.label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<st-icon aria-hidden=\"true\" [icon]=\"entry.item.icon || fallbackIcon\" size=\"md\" />\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</st-tooltip>\n\t\t\t\t\t</li>\n\t\t\t\t}\n\t\t\t</ul>\n\t\t} @else {\n\t\t\t<ul class=\"flex min-w-0 flex-col gap-1 pe-1\" data-st-side-menu-tree>\n\t\t\t\t@for (section of sections(); track section.item.id) {\n\t\t\t\t\t<li class=\"min-w-0\">\n\t\t\t\t\t\t@if (section.kind === 'label') {\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclass=\"text-base-content/60 block px-3 pt-4 pb-1 text-xs font-semibold tracking-wide uppercase select-none\"\n\t\t\t\t\t\t\t\tdata-st-side-menu-label\n\t\t\t\t\t\t\t\t[id]=\"labelId(section.item)\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{{ section.item.label }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<ul class=\"flex min-w-0 flex-col gap-1\" [attr.aria-labelledby]=\"labelId(section.item)\">\n\t\t\t\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"entries\" [ngTemplateOutletContext]=\"{ $implicit: section.children }\" />\n\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t<ng-container [ngTemplateOutlet]=\"entry\" [ngTemplateOutletContext]=\"{ $implicit: section.item }\" />\n\t\t\t\t\t\t}\n\t\t\t\t\t</li>\n\t\t\t\t} @empty {\n\t\t\t\t\t<li class=\"text-base-content/60 px-3 py-2 text-sm\" role=\"status\">{{ 'sdk.layout.no_results' | translate }}</li>\n\t\t\t\t}\n\t\t\t</ul>\n\t\t}\n\t</nav>\n\n\t@if (showCollapseToggle()) {\n\t\t<div class=\"flex shrink-0 flex-col\">\n\t\t\t<div class=\"bg-base-300 h-px\" aria-hidden=\"true\"></div>\n\t\t\t@let pinnedCollapsedVar = isPinnedCollapsed();\n\t\t\t@let toggleLabel = (pinnedCollapsedVar ? 'sdk.layout.expand' : 'sdk.layout.collapse') | translate;\n\t\t\t<div class=\"flex items-center pt-4\" [class.justify-center]=\"collapsedVar\" [class.justify-end]=\"!collapsedVar\">\n\t\t\t\t<st-tooltip [label]=\"toggleLabel\" [position]=\"collapsedVar ? 'right' : 'top'\">\n\t\t\t\t\t<st-button\n\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tdata-st-side-menu-toggle\n\t\t\t\t\t\t[circle]=\"true\"\n\t\t\t\t\t\t[icon]=\"pinnedCollapsedVar ? expandIcon : collapseIcon\"\n\t\t\t\t\t\t(triggered)=\"toggleCollapsed()\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"sr-only\">{{ toggleLabel }}</span>\n\t\t\t\t\t</st-button>\n\t\t\t\t</st-tooltip>\n\t\t\t</div>\n\t\t</div>\n\t}\n</div>\n\n<ng-template #entries let-items>\n\t@for (item of items; track item.id) {\n\t\t<li class=\"min-w-0\">\n\t\t\t<ng-container [ngTemplateOutlet]=\"entry\" [ngTemplateOutletContext]=\"{ $implicit: item }\" />\n\t\t</li>\n\t}\n</ng-template>\n\n<ng-template #entry let-item>\n\t@if (hasChildren(item)) {\n\t\t@let state = groupState(item);\n\t\t@let onTrail = isOnTrail(item);\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"rounded-field focus-visible:outline-primary flex min-h-10 w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-2 text-start transition-[color,background-color,box-shadow] focus-visible:outline-2 focus-visible:-outline-offset-2 motion-reduce:transition-none\"\n\t\t\t[class]=\"groupStateClass\"\n\t\t\t[class.font-semibold]=\"onTrail\"\n\t\t\t[attr.aria-expanded]=\"isGroupExpanded(item)\"\n\t\t\t[attr.aria-controls]=\"groupId(item)\"\n\t\t\t(click)=\"toggleGroup(item)\"\n\t\t>\n\t\t\t@if (item.icon) {\n\t\t\t\t<st-icon aria-hidden=\"true\" class=\"shrink-0\" [icon]=\"item.icon\" size=\"md\" />\n\t\t\t}\n\t\t\t<span class=\"block min-w-0 flex-1 wrap-anywhere\">{{ item.label }}</span>\n\t\t\t<span data-st-chevron class=\"inline-flex size-[1.2em] shrink-0 items-center justify-center\">\n\t\t\t\t<st-icon aria-hidden=\"true\" [icon]=\"chevronIcon\" size=\"sm\" />\n\t\t\t</span>\n\t\t</button>\n\t\t<ul\n\t\t\tclass=\"data-[state=closing]:animate-morph-out data-[state=opening]:animate-morph-in border-base-300 ms-5 mt-1 flex min-w-0 flex-col gap-1 border-s ps-2\"\n\t\t\tdata-st-menu-group\n\t\t\t[id]=\"groupId(item)\"\n\t\t\t[attr.data-state]=\"state\"\n\t\t\t[hidden]=\"state === 'closed'\"\n\t\t\t(animationend)=\"onGroupAnimationEnd($event, item)\"\n\t\t>\n\t\t\t<ng-container [ngTemplateOutlet]=\"entries\" [ngTemplateOutletContext]=\"{ $implicit: item.children }\" />\n\t\t</ul>\n\t} @else {\n\t\t@let activeVar = isActive(item);\n\t\t<a\n\t\t\tclass=\"rounded-field flex min-h-10 w-full min-w-0 items-center gap-2 px-3 py-2 transition-[color,background-color,box-shadow] focus-visible:outline-2 motion-reduce:transition-none\"\n\t\t\t[class]=\"activeVar ? activeLinkClass : inactiveLinkClass\"\n\t\t\t[routerLink]=\"item.route\"\n\t\t\t[queryParams]=\"linkQueryParams(item)\"\n\t\t\t[attr.aria-current]=\"activeVar ? 'page' : null\"\n\t\t>\n\t\t\t@if (item.icon) {\n\t\t\t\t<st-icon aria-hidden=\"true\" class=\"shrink-0\" [icon]=\"item.icon\" size=\"md\" />\n\t\t\t}\n\t\t\t<span class=\"block min-w-0 flex-1 wrap-anywhere\">{{ item.label }}</span>\n\t\t</a>\n\t}\n</ng-template>\n" }]
|
|
741
|
+
}], ctorParameters: () => [] });
|
|
742
|
+
|
|
743
|
+
const frameVariants = cva('relative grid min-h-screen', {
|
|
744
|
+
variants: {
|
|
745
|
+
layout: {
|
|
746
|
+
classic: "bg-base-100 grid-cols-[max-content_repeat(2,minmax(0,2fr))] [grid-template-areas:'aside_main_main''aside_main_main']",
|
|
747
|
+
modern: "bg-modern-gradient grid-rows-[auto_1fr] gap-4 p-4 [grid-template-areas:'header_header_header''aside_main_main'] min-[548px]:grid-cols-[max-content_repeat(2,minmax(0,2fr))]",
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
});
|
|
751
|
+
const asideVariants = cva('border-neutral bg-base-200 z-50 flex flex-col gap-4 self-start border-solid transition-[width] duration-300 [grid-area:aside] motion-reduce:transition-none', {
|
|
752
|
+
variants: {
|
|
753
|
+
layout: {
|
|
754
|
+
classic: 'sticky top-0 h-screen border-r p-6',
|
|
755
|
+
modern: 'rounded-box sticky top-4 h-[calc(100dvh-7rem)] max-h-[calc(100dvh-7rem)] overflow-hidden border py-6',
|
|
756
|
+
},
|
|
757
|
+
collapsed: { true: '', false: 'w-84' },
|
|
758
|
+
},
|
|
759
|
+
compoundVariants: [
|
|
760
|
+
{ layout: 'classic', collapsed: true, class: 'w-22' },
|
|
761
|
+
{ layout: 'modern', collapsed: true, class: 'w-20 px-2' },
|
|
762
|
+
{ layout: 'modern', collapsed: false, class: 'px-6' },
|
|
763
|
+
],
|
|
764
|
+
});
|
|
765
|
+
const mainVariants = cva('mx-auto w-full max-w-7xl [grid-area:main]', {
|
|
766
|
+
variants: { layout: { classic: 'p-6', modern: '' } },
|
|
767
|
+
});
|
|
768
|
+
/**
|
|
769
|
+
* Marks an `ng-template` (or, with `*stAppLayoutNavbarEnd`, an element) whose content `st-app-layout`
|
|
770
|
+
* renders at the end of the modern `st-navbar`, before the account menu. Modern only: the classic
|
|
771
|
+
* layout has no top bar and does not render it.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```html
|
|
775
|
+
* <st-app-layout [items]="menu()">
|
|
776
|
+
* <st-button *stAppLayoutNavbarEnd variant="base" [ghost]="true" ariaLabel="Notifications">…</st-button>
|
|
777
|
+
* <router-outlet />
|
|
778
|
+
* </st-app-layout>
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
class AppLayoutNavbarEndDirective {
|
|
782
|
+
template = inject(TemplateRef);
|
|
783
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AppLayoutNavbarEndDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
784
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: AppLayoutNavbarEndDirective, isStandalone: true, selector: "[stAppLayoutNavbarEnd]", ngImport: i0 });
|
|
785
|
+
}
|
|
786
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AppLayoutNavbarEndDirective, decorators: [{
|
|
787
|
+
type: Directive,
|
|
788
|
+
args: [{ selector: '[stAppLayoutNavbarEnd]' }]
|
|
789
|
+
}] });
|
|
790
|
+
/**
|
|
791
|
+
* The application shell: classic (full-height sidebar with logo, menu and account) or modern
|
|
792
|
+
* (gradient page, `st-navbar` banner and a rounded sidebar), following `LayoutService.selectedLayout()`.
|
|
793
|
+
* A pinned-collapsed sidebar expands while hovered, and in classic while its account menu is open.
|
|
794
|
+
* The projected content (usually a `router-outlet`) lives in one `main` that survives layout switches.
|
|
795
|
+
*/
|
|
796
|
+
class AppLayoutComponent {
|
|
797
|
+
layoutService = inject(LayoutService);
|
|
798
|
+
logo = injectLayoutLogo();
|
|
799
|
+
/** Menu tree with labels already translated, passed to `st-side-menu`. */
|
|
800
|
+
items = input.required();
|
|
801
|
+
/** `st-side-menu` `topLevelGroups`. */
|
|
802
|
+
topLevelGroups = input(DEFAULT_MENU_TOP_LEVEL_GROUPS);
|
|
803
|
+
/** `st-side-menu` `activeMatch`. */
|
|
804
|
+
activeMatch = input(DEFAULT_MENU_ACTIVE_MATCH);
|
|
805
|
+
/** `st-side-menu` `searchable`. */
|
|
806
|
+
searchable = input(true);
|
|
807
|
+
/** Route the logo links to. */
|
|
808
|
+
homeLink = input('/');
|
|
809
|
+
/** Alt text of the logo; defaults to the localized theme name. */
|
|
810
|
+
logoAlt = input(null);
|
|
811
|
+
/** `st-user-menu` `showLanguageSelector`, in both layouts. */
|
|
812
|
+
showLanguageSelector = input(true);
|
|
813
|
+
/** `st-user-menu` `showSchemeSelector`, in both layouts. */
|
|
814
|
+
showSchemeSelector = input(true);
|
|
815
|
+
/** `st-user-menu` `showThemeSelector`, in both layouts. */
|
|
816
|
+
showThemeSelector = input(true);
|
|
817
|
+
/** `st-user-menu` `showLayoutSelector`, in both layouts. */
|
|
818
|
+
showLayoutSelector = input(true);
|
|
819
|
+
/** Content for the end of the modern navbar; a template, so it can render inside the layout's `@switch`. */
|
|
820
|
+
navbarEnd = contentChild(AppLayoutNavbarEndDirective);
|
|
821
|
+
navbarEndTemplate = computed(() => this.navbarEnd()?.template ?? null);
|
|
822
|
+
layout = this.layoutService.selectedLayout;
|
|
823
|
+
switcherOpen = signal(false);
|
|
824
|
+
hovering = signal(false);
|
|
825
|
+
userMenuOpen = signal(false);
|
|
826
|
+
/** The pinned-collapsed rail expands while hovered, and stays expanded while the classic account menu is open. */
|
|
827
|
+
railCollapsed = computed(() => this.layoutService.sidebarCollapsed() && !this.hovering() && !this.userMenuOpen());
|
|
828
|
+
frameClass = computed(() => cn(frameVariants({ layout: this.layout() })));
|
|
829
|
+
asideClass = computed(() => cn(asideVariants({ layout: this.layout(), collapsed: this.railCollapsed() })));
|
|
830
|
+
mainClass = computed(() => cn(mainVariants({ layout: this.layout() })));
|
|
831
|
+
classicLogoUrl = computed(() => this.logo.assetUrl(this.railCollapsed() ? 'logo-icon' : 'logo'));
|
|
832
|
+
logoLabel = this.logo.alt(this.logoAlt);
|
|
833
|
+
openSwitcher() {
|
|
834
|
+
this.switcherOpen.set(true);
|
|
835
|
+
}
|
|
836
|
+
/** Hovering only expands a rail that is pinned collapsed, so pinning it collapsed takes effect at once. */
|
|
837
|
+
setHovering(hovering) {
|
|
838
|
+
this.hovering.set(hovering && this.layoutService.sidebarCollapsed());
|
|
839
|
+
}
|
|
840
|
+
setUserMenuOpen(open) {
|
|
841
|
+
this.userMenuOpen.set(open);
|
|
842
|
+
if (!open)
|
|
843
|
+
this.hovering.set(false);
|
|
844
|
+
}
|
|
845
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AppLayoutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
846
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: AppLayoutComponent, isStandalone: true, selector: "st-app-layout", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, topLevelGroups: { classPropertyName: "topLevelGroups", publicName: "topLevelGroups", isSignal: true, isRequired: false, transformFunction: null }, activeMatch: { classPropertyName: "activeMatch", publicName: "activeMatch", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, homeLink: { classPropertyName: "homeLink", publicName: "homeLink", isSignal: true, isRequired: false, transformFunction: null }, logoAlt: { classPropertyName: "logoAlt", publicName: "logoAlt", isSignal: true, isRequired: false, transformFunction: null }, showLanguageSelector: { classPropertyName: "showLanguageSelector", publicName: "showLanguageSelector", isSignal: true, isRequired: false, transformFunction: null }, showSchemeSelector: { classPropertyName: "showSchemeSelector", publicName: "showSchemeSelector", isSignal: true, isRequired: false, transformFunction: null }, showThemeSelector: { classPropertyName: "showThemeSelector", publicName: "showThemeSelector", isSignal: true, isRequired: false, transformFunction: null }, showLayoutSelector: { classPropertyName: "showLayoutSelector", publicName: "showLayoutSelector", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "block" }, queries: [{ propertyName: "navbarEnd", first: true, predicate: AppLayoutNavbarEndDirective, descendants: true, isSignal: true }], ngImport: i0, template: "@let collapsed = railCollapsed();\n\n<div [class]=\"frameClass()\" [attr.data-st-app-layout]=\"layout()\">\n\t@switch (layout()) {\n\t\t@case ('modern') {\n\t\t\t<header class=\"[grid-area:header]\">\n\t\t\t\t<st-navbar\n\t\t\t\t\t[homeLink]=\"homeLink()\"\n\t\t\t\t\t[logoAlt]=\"logoAlt()\"\n\t\t\t\t\t[showLanguageSelector]=\"showLanguageSelector()\"\n\t\t\t\t\t[showSchemeSelector]=\"showSchemeSelector()\"\n\t\t\t\t\t[showThemeSelector]=\"showThemeSelector()\"\n\t\t\t\t\t[showLayoutSelector]=\"showLayoutSelector()\"\n\t\t\t\t\t(openLayoutSwitcher)=\"openSwitcher()\"\n\t\t\t\t>\n\t\t\t\t\t<!-- ng-content cannot be re-projected from inside @switch, so the end slot is a template rendered here -->\n\t\t\t\t\t<ng-container ngProjectAs=\"[stNavbarEnd]\" [ngTemplateOutlet]=\"navbarEndTemplate()\" />\n\t\t\t\t</st-navbar>\n\t\t\t</header>\n\n\t\t\t<aside [class]=\"asideClass()\" (mouseenter)=\"setHovering(true)\" (mouseleave)=\"setHovering(false)\">\n\t\t\t\t<st-side-menu\n\t\t\t\t\t[items]=\"items()\"\n\t\t\t\t\t[topLevelGroups]=\"topLevelGroups()\"\n\t\t\t\t\t[activeMatch]=\"activeMatch()\"\n\t\t\t\t\t[searchable]=\"searchable()\"\n\t\t\t\t\t[collapsed]=\"collapsed\"\n\t\t\t\t/>\n\t\t\t</aside>\n\t\t}\n\t\t@default {\n\t\t\t<aside [class]=\"asideClass()\" (mouseenter)=\"setHovering(true)\" (mouseleave)=\"setHovering(false)\">\n\t\t\t\t<a\n\t\t\t\t\tclass=\"btn btn-ghost h-10 min-h-10 shrink-0 justify-start overflow-hidden\"\n\t\t\t\t\t[class.p-0]=\"collapsed\"\n\t\t\t\t\t[class.px-3]=\"!collapsed\"\n\t\t\t\t\t[routerLink]=\"homeLink()\"\n\t\t\t\t\tdata-st-app-layout-home\n\t\t\t\t>\n\t\t\t\t\t@if (classicLogoUrl(); as logo) {\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t[src]=\"logo\"\n\t\t\t\t\t\t\t[alt]=\"logoLabel()\"\n\t\t\t\t\t\t\tclass=\"h-10 object-contain object-left\"\n\t\t\t\t\t\t\t[class.w-10]=\"collapsed\"\n\t\t\t\t\t\t\t[class.w-auto]=\"!collapsed\"\n\t\t\t\t\t\t\t[class.max-w-full]=\"!collapsed\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t} @else {\n\t\t\t\t\t\t<span class=\"truncate font-semibold\" [class.sr-only]=\"collapsed\">{{ logoLabel() }}</span>\n\t\t\t\t\t}\n\t\t\t\t</a>\n\n\t\t\t\t<st-side-menu\n\t\t\t\t\t[items]=\"items()\"\n\t\t\t\t\t[topLevelGroups]=\"topLevelGroups()\"\n\t\t\t\t\t[activeMatch]=\"activeMatch()\"\n\t\t\t\t\t[searchable]=\"searchable()\"\n\t\t\t\t\t[collapsed]=\"collapsed\"\n\t\t\t\t/>\n\n\t\t\t\t<div class=\"bg-base-300 h-px shrink-0\" aria-hidden=\"true\"></div>\n\n\t\t\t\t<st-user-menu\n\t\t\t\t\tvariant=\"sidebar\"\n\t\t\t\t\t[collapsed]=\"collapsed\"\n\t\t\t\t\t[showLanguageSelector]=\"showLanguageSelector()\"\n\t\t\t\t\t[showSchemeSelector]=\"showSchemeSelector()\"\n\t\t\t\t\t[showThemeSelector]=\"showThemeSelector()\"\n\t\t\t\t\t[showLayoutSelector]=\"showLayoutSelector()\"\n\t\t\t\t\t(openChange)=\"setUserMenuOpen($event)\"\n\t\t\t\t\t(openLayoutSwitcher)=\"openSwitcher()\"\n\t\t\t\t/>\n\t\t\t</aside>\n\t\t}\n\t}\n\n\t<main [class]=\"mainClass()\">\n\t\t<ng-content />\n\t</main>\n</div>\n\n<st-layout-switcher [(opened)]=\"switcherOpen\" />\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: LayoutSwitcherComponent, selector: "st-layout-switcher", inputs: ["opened"], outputs: ["openedChange"] }, { kind: "component", type: NavbarComponent, selector: "st-navbar", inputs: ["homeLink", "showUserMenu", "logoAlt", "showLanguageSelector", "showSchemeSelector", "showThemeSelector", "showLayoutSelector", "class"], outputs: ["openLayoutSwitcher"] }, { kind: "component", type: SideMenuComponent, selector: "st-side-menu", inputs: ["items", "topLevelGroups", "activeMatch", "collapsed", "searchable", "showCollapseToggle", "class", "search"], outputs: ["searchChange"] }, { kind: "component", type: UserMenuComponent, selector: "st-user-menu", inputs: ["variant", "collapsed", "showLanguageSelector", "showSchemeSelector", "showThemeSelector", "showLayoutSelector", "class"], outputs: ["openLayoutSwitcher", "openChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
847
|
+
}
|
|
848
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AppLayoutComponent, decorators: [{
|
|
849
|
+
type: Component,
|
|
850
|
+
args: [{ selector: 'st-app-layout', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet, RouterLink, LayoutSwitcherComponent, NavbarComponent, SideMenuComponent, UserMenuComponent], host: {
|
|
851
|
+
class: 'block',
|
|
852
|
+
}, template: "@let collapsed = railCollapsed();\n\n<div [class]=\"frameClass()\" [attr.data-st-app-layout]=\"layout()\">\n\t@switch (layout()) {\n\t\t@case ('modern') {\n\t\t\t<header class=\"[grid-area:header]\">\n\t\t\t\t<st-navbar\n\t\t\t\t\t[homeLink]=\"homeLink()\"\n\t\t\t\t\t[logoAlt]=\"logoAlt()\"\n\t\t\t\t\t[showLanguageSelector]=\"showLanguageSelector()\"\n\t\t\t\t\t[showSchemeSelector]=\"showSchemeSelector()\"\n\t\t\t\t\t[showThemeSelector]=\"showThemeSelector()\"\n\t\t\t\t\t[showLayoutSelector]=\"showLayoutSelector()\"\n\t\t\t\t\t(openLayoutSwitcher)=\"openSwitcher()\"\n\t\t\t\t>\n\t\t\t\t\t<!-- ng-content cannot be re-projected from inside @switch, so the end slot is a template rendered here -->\n\t\t\t\t\t<ng-container ngProjectAs=\"[stNavbarEnd]\" [ngTemplateOutlet]=\"navbarEndTemplate()\" />\n\t\t\t\t</st-navbar>\n\t\t\t</header>\n\n\t\t\t<aside [class]=\"asideClass()\" (mouseenter)=\"setHovering(true)\" (mouseleave)=\"setHovering(false)\">\n\t\t\t\t<st-side-menu\n\t\t\t\t\t[items]=\"items()\"\n\t\t\t\t\t[topLevelGroups]=\"topLevelGroups()\"\n\t\t\t\t\t[activeMatch]=\"activeMatch()\"\n\t\t\t\t\t[searchable]=\"searchable()\"\n\t\t\t\t\t[collapsed]=\"collapsed\"\n\t\t\t\t/>\n\t\t\t</aside>\n\t\t}\n\t\t@default {\n\t\t\t<aside [class]=\"asideClass()\" (mouseenter)=\"setHovering(true)\" (mouseleave)=\"setHovering(false)\">\n\t\t\t\t<a\n\t\t\t\t\tclass=\"btn btn-ghost h-10 min-h-10 shrink-0 justify-start overflow-hidden\"\n\t\t\t\t\t[class.p-0]=\"collapsed\"\n\t\t\t\t\t[class.px-3]=\"!collapsed\"\n\t\t\t\t\t[routerLink]=\"homeLink()\"\n\t\t\t\t\tdata-st-app-layout-home\n\t\t\t\t>\n\t\t\t\t\t@if (classicLogoUrl(); as logo) {\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t[src]=\"logo\"\n\t\t\t\t\t\t\t[alt]=\"logoLabel()\"\n\t\t\t\t\t\t\tclass=\"h-10 object-contain object-left\"\n\t\t\t\t\t\t\t[class.w-10]=\"collapsed\"\n\t\t\t\t\t\t\t[class.w-auto]=\"!collapsed\"\n\t\t\t\t\t\t\t[class.max-w-full]=\"!collapsed\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t} @else {\n\t\t\t\t\t\t<span class=\"truncate font-semibold\" [class.sr-only]=\"collapsed\">{{ logoLabel() }}</span>\n\t\t\t\t\t}\n\t\t\t\t</a>\n\n\t\t\t\t<st-side-menu\n\t\t\t\t\t[items]=\"items()\"\n\t\t\t\t\t[topLevelGroups]=\"topLevelGroups()\"\n\t\t\t\t\t[activeMatch]=\"activeMatch()\"\n\t\t\t\t\t[searchable]=\"searchable()\"\n\t\t\t\t\t[collapsed]=\"collapsed\"\n\t\t\t\t/>\n\n\t\t\t\t<div class=\"bg-base-300 h-px shrink-0\" aria-hidden=\"true\"></div>\n\n\t\t\t\t<st-user-menu\n\t\t\t\t\tvariant=\"sidebar\"\n\t\t\t\t\t[collapsed]=\"collapsed\"\n\t\t\t\t\t[showLanguageSelector]=\"showLanguageSelector()\"\n\t\t\t\t\t[showSchemeSelector]=\"showSchemeSelector()\"\n\t\t\t\t\t[showThemeSelector]=\"showThemeSelector()\"\n\t\t\t\t\t[showLayoutSelector]=\"showLayoutSelector()\"\n\t\t\t\t\t(openChange)=\"setUserMenuOpen($event)\"\n\t\t\t\t\t(openLayoutSwitcher)=\"openSwitcher()\"\n\t\t\t\t/>\n\t\t\t</aside>\n\t\t}\n\t}\n\n\t<main [class]=\"mainClass()\">\n\t\t<ng-content />\n\t</main>\n</div>\n\n<st-layout-switcher [(opened)]=\"switcherOpen\" />\n" }]
|
|
853
|
+
}] });
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Page header for the SDK layouts. Classic shows the title over a theme banner image (or a plain
|
|
857
|
+
* surface when the theme has no such asset); modern shows it as light text on the brand gradient.
|
|
858
|
+
* Over an image, the title color follows the image tone the theme declares in its catalog
|
|
859
|
+
* (`tone`), and a surface scrim keeps it readable when no tone is known.
|
|
860
|
+
* Projected content (usually a `router-outlet`) fills the remaining height.
|
|
861
|
+
*/
|
|
862
|
+
class PageBannerComponent {
|
|
863
|
+
layoutService = inject(LayoutService);
|
|
864
|
+
themeAssetsService = inject(ThemeAssetsService);
|
|
865
|
+
themeService = inject(ThemeService);
|
|
866
|
+
router = inject(Router);
|
|
867
|
+
title = input('');
|
|
868
|
+
subtitle = input('');
|
|
869
|
+
/** URL the back button navigates to; no button when empty. */
|
|
870
|
+
backLink = input(null);
|
|
871
|
+
/** Theme asset key of the classic banner image; `null` for a plain surface. */
|
|
872
|
+
bannerAsset = input('banner');
|
|
873
|
+
/** Luminance of the banner image; overrides the tone the theme declares for the asset. */
|
|
874
|
+
bannerTone = input(null);
|
|
875
|
+
class = input('');
|
|
876
|
+
backIcon = matKeyboardBackspace;
|
|
877
|
+
/**
|
|
878
|
+
* Two-tone focus ring of the back button: a `base-content` outline over a `base-100` ring. One of the two
|
|
879
|
+
* contrasts with whatever is behind it (art, scrim, surface or the modern gradient), in both schemes.
|
|
880
|
+
*/
|
|
881
|
+
backFocusClass = '[&_.btn:focus-visible]:outline-base-content [&_.btn:focus-visible]:ring-4 [&_.btn:focus-visible]:ring-base-100';
|
|
882
|
+
/** Frosted surface for the back button over toned art. */
|
|
883
|
+
backClass = computed(() => cn('absolute top-5 right-6 z-1 flex gap-3', this.backFocusClass, this.imageTone() && '[&_.btn]:bg-base-100/80 [&_.btn]:border-base-content/10 [&_.btn:hover]:bg-base-100 [&_.btn]:backdrop-blur-sm'));
|
|
884
|
+
hostClass = computed(() => cn('flex min-h-full flex-1 flex-col', this.class()));
|
|
885
|
+
isClassic = computed(() => this.layoutService.selectedLayout() === 'classic');
|
|
886
|
+
bannerUrl = computed(() => {
|
|
887
|
+
const asset = this.bannerAsset();
|
|
888
|
+
return asset ? this.themeAssetsService.getAssetUrl(this.themeService.selectedTheme(), asset, this.themeService.resolvedScheme()) : null;
|
|
889
|
+
});
|
|
890
|
+
/** Tone of the image shown; `null` when neither the input nor the theme declares it. */
|
|
891
|
+
imageTone = computed(() => {
|
|
892
|
+
const override = this.bannerTone();
|
|
893
|
+
if (override)
|
|
894
|
+
return override;
|
|
895
|
+
const asset = this.bannerAsset();
|
|
896
|
+
return asset ? this.themeAssetsService.getAssetTone(this.themeService.selectedTheme(), asset, this.themeService.resolvedScheme()) : null;
|
|
897
|
+
});
|
|
898
|
+
goBack() {
|
|
899
|
+
const url = this.backLink();
|
|
900
|
+
if (url) {
|
|
901
|
+
void this.router.navigateByUrl(url);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PageBannerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
905
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: PageBannerComponent, isStandalone: true, selector: "st-page-banner", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, backLink: { classPropertyName: "backLink", publicName: "backLink", isSignal: true, isRequired: false, transformFunction: null }, bannerAsset: { classPropertyName: "bannerAsset", publicName: "bannerAsset", isSignal: true, isRequired: false, transformFunction: null }, bannerTone: { classPropertyName: "bannerTone", publicName: "bannerTone", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClass()" } }, ngImport: i0, template: "@if (isClassic()) {\n\t@if (bannerUrl(); as url) {\n\t\t<div\n\t\t\tdata-st-banner=\"image\"\n\t\t\t[style.background-image]=\"'url(' + url + ')'\"\n\t\t\tclass=\"rounded-box bg-neutral relative mb-6 flex h-30 items-end justify-between bg-cover bg-center px-6 py-5\"\n\t\t>\n\t\t\t@if (!imageTone()) {\n\t\t\t\t<!-- Unknown image tone: a surface scrim under the content makes base-content readable over any photo, in both schemes -->\n\t\t\t\t<div data-st-banner-scrim aria-hidden=\"true\" class=\"rounded-box bg-base-100/80 pointer-events-none absolute inset-0 z-0\"></div>\n\t\t\t}\n\n\t\t\t@if (backLink()) {\n\t\t\t\t<!-- Over toned art the button sits on a frosted base-100 surface with base-content text, so the label keeps 4.5:1 over any pixel in either scheme -->\n\t\t\t\t<div data-st-banner-back [class]=\"backClass()\">\n\t\t\t\t\t<st-button [variant]=\"imageTone() ? 'base' : 'tertiary'\" size=\"sm\" [icon]=\"backIcon\" (clicked)=\"goBack()\">\n\t\t\t\t\t\t{{ 'sdk.layout.back' | translate }}\n\t\t\t\t\t</st-button>\n\t\t\t\t</div>\n\t\t\t}\n\n\t\t\t<!-- With a known tone: fixed white/black opposite to the declared image luminance, not theme tokens -->\n\t\t\t<div\n\t\t\t\tclass=\"relative z-1 flex min-w-0 flex-col wrap-break-word\"\n\t\t\t\t[class.text-white]=\"imageTone() === 'dark'\"\n\t\t\t\t[class.text-black]=\"imageTone() === 'light'\"\n\t\t\t\t[class.text-base-content]=\"!imageTone()\"\n\t\t\t>\n\t\t\t\t<h1 stText=\"1\" stTextWeight=\"medium\">{{ title() }}</h1>\n\t\t\t\t@if (subtitle()) {\n\t\t\t\t\t<p class=\"opacity-80\" stText=\"7\" stTextWeight=\"medium\" stTextLineClamp=\"2\">{{ subtitle() }}</p>\n\t\t\t\t}\n\t\t\t</div>\n\t\t</div>\n\t} @else {\n\t\t<div data-st-banner=\"plain\" class=\"rounded-box bg-base-200 relative mb-6 flex h-30 items-end justify-between px-6 py-5\">\n\t\t\t@if (backLink()) {\n\t\t\t\t<div data-st-banner-back class=\"absolute top-5 right-6 flex gap-3\" [class]=\"backFocusClass\">\n\t\t\t\t\t<st-button variant=\"tertiary\" size=\"sm\" [icon]=\"backIcon\" (clicked)=\"goBack()\">\n\t\t\t\t\t\t{{ 'sdk.layout.back' | translate }}\n\t\t\t\t\t</st-button>\n\t\t\t\t</div>\n\t\t\t}\n\n\t\t\t<div class=\"text-base-content flex min-w-0 flex-col wrap-break-word\">\n\t\t\t\t<h1 stText=\"1\" stTextWeight=\"medium\">{{ title() }}</h1>\n\t\t\t\t@if (subtitle()) {\n\t\t\t\t\t<p class=\"text-base-content/80\" stText=\"7\" stTextWeight=\"medium\" stTextLineClamp=\"2\">{{ subtitle() }}</p>\n\t\t\t\t}\n\t\t\t</div>\n\t\t</div>\n\t}\n} @else if (title()) {\n\t<!-- Modern: on the brand gradient, primary-gradient-content stays light in both schemes -->\n\t<div data-st-banner=\"modern\" class=\"mb-4 flex items-end justify-between\">\n\t\t<div class=\"text-primary-gradient-content flex min-w-0 flex-col wrap-break-word\">\n\t\t\t<h1 stText=\"1\" stTextWeight=\"medium\">{{ title() }}</h1>\n\t\t\t@if (subtitle()) {\n\t\t\t\t<p class=\"text-primary-gradient-content/70\" stText=\"7\" stTextWeight=\"medium\" stTextLineClamp=\"2\">{{ subtitle() }}</p>\n\t\t\t}\n\t\t</div>\n\n\t\t@if (backLink()) {\n\t\t\t<div data-st-banner-back [class]=\"backFocusClass\">\n\t\t\t\t<st-button size=\"sm\" [icon]=\"backIcon\" (clicked)=\"goBack()\">\n\t\t\t\t\t{{ 'sdk.layout.back' | translate }}\n\t\t\t\t</st-button>\n\t\t\t</div>\n\t\t}\n\t</div>\n}\n\n<!-- Stretch the routed page (a sibling of router-outlet) so feature cards can fill the shell -->\n<div\n\tclass=\"flex min-h-0 flex-1 flex-col [&>*:not(router-outlet)]:flex [&>*:not(router-outlet)]:min-h-full [&>*:not(router-outlet)]:flex-1 [&>*:not(router-outlet)]:flex-col\"\n>\n\t<ng-content />\n</div>\n", dependencies: [{ kind: "component", type: ButtonComponent, selector: "st-button", inputs: ["variant", "ghost", "outline", "link", "soft", "dash", "wide", "circle", "square", "glass", "block", "loader", "size", "shadow", "focusable", "icon", "iconPosition", "type", "disabled", "stopPropagation", "ariaLabel", "ariaExpanded", "ariaPressed"], outputs: ["clicked", "pointerDown", "keyDownEnter", "keyDownSpace", "triggered"] }, { kind: "directive", type: TextDirective, selector: "[stText]", inputs: ["stText", "stTextWeight", "stTextColor", "stTextOverflow", "stTextLineClamp", "stTextClass"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
906
|
+
}
|
|
907
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PageBannerComponent, decorators: [{
|
|
908
|
+
type: Component,
|
|
909
|
+
args: [{ selector: 'st-page-banner', changeDetection: ChangeDetectionStrategy.OnPush, imports: [ButtonComponent, TextDirective, TranslatePipe], host: {
|
|
910
|
+
'[class]': 'hostClass()',
|
|
911
|
+
}, template: "@if (isClassic()) {\n\t@if (bannerUrl(); as url) {\n\t\t<div\n\t\t\tdata-st-banner=\"image\"\n\t\t\t[style.background-image]=\"'url(' + url + ')'\"\n\t\t\tclass=\"rounded-box bg-neutral relative mb-6 flex h-30 items-end justify-between bg-cover bg-center px-6 py-5\"\n\t\t>\n\t\t\t@if (!imageTone()) {\n\t\t\t\t<!-- Unknown image tone: a surface scrim under the content makes base-content readable over any photo, in both schemes -->\n\t\t\t\t<div data-st-banner-scrim aria-hidden=\"true\" class=\"rounded-box bg-base-100/80 pointer-events-none absolute inset-0 z-0\"></div>\n\t\t\t}\n\n\t\t\t@if (backLink()) {\n\t\t\t\t<!-- Over toned art the button sits on a frosted base-100 surface with base-content text, so the label keeps 4.5:1 over any pixel in either scheme -->\n\t\t\t\t<div data-st-banner-back [class]=\"backClass()\">\n\t\t\t\t\t<st-button [variant]=\"imageTone() ? 'base' : 'tertiary'\" size=\"sm\" [icon]=\"backIcon\" (clicked)=\"goBack()\">\n\t\t\t\t\t\t{{ 'sdk.layout.back' | translate }}\n\t\t\t\t\t</st-button>\n\t\t\t\t</div>\n\t\t\t}\n\n\t\t\t<!-- With a known tone: fixed white/black opposite to the declared image luminance, not theme tokens -->\n\t\t\t<div\n\t\t\t\tclass=\"relative z-1 flex min-w-0 flex-col wrap-break-word\"\n\t\t\t\t[class.text-white]=\"imageTone() === 'dark'\"\n\t\t\t\t[class.text-black]=\"imageTone() === 'light'\"\n\t\t\t\t[class.text-base-content]=\"!imageTone()\"\n\t\t\t>\n\t\t\t\t<h1 stText=\"1\" stTextWeight=\"medium\">{{ title() }}</h1>\n\t\t\t\t@if (subtitle()) {\n\t\t\t\t\t<p class=\"opacity-80\" stText=\"7\" stTextWeight=\"medium\" stTextLineClamp=\"2\">{{ subtitle() }}</p>\n\t\t\t\t}\n\t\t\t</div>\n\t\t</div>\n\t} @else {\n\t\t<div data-st-banner=\"plain\" class=\"rounded-box bg-base-200 relative mb-6 flex h-30 items-end justify-between px-6 py-5\">\n\t\t\t@if (backLink()) {\n\t\t\t\t<div data-st-banner-back class=\"absolute top-5 right-6 flex gap-3\" [class]=\"backFocusClass\">\n\t\t\t\t\t<st-button variant=\"tertiary\" size=\"sm\" [icon]=\"backIcon\" (clicked)=\"goBack()\">\n\t\t\t\t\t\t{{ 'sdk.layout.back' | translate }}\n\t\t\t\t\t</st-button>\n\t\t\t\t</div>\n\t\t\t}\n\n\t\t\t<div class=\"text-base-content flex min-w-0 flex-col wrap-break-word\">\n\t\t\t\t<h1 stText=\"1\" stTextWeight=\"medium\">{{ title() }}</h1>\n\t\t\t\t@if (subtitle()) {\n\t\t\t\t\t<p class=\"text-base-content/80\" stText=\"7\" stTextWeight=\"medium\" stTextLineClamp=\"2\">{{ subtitle() }}</p>\n\t\t\t\t}\n\t\t\t</div>\n\t\t</div>\n\t}\n} @else if (title()) {\n\t<!-- Modern: on the brand gradient, primary-gradient-content stays light in both schemes -->\n\t<div data-st-banner=\"modern\" class=\"mb-4 flex items-end justify-between\">\n\t\t<div class=\"text-primary-gradient-content flex min-w-0 flex-col wrap-break-word\">\n\t\t\t<h1 stText=\"1\" stTextWeight=\"medium\">{{ title() }}</h1>\n\t\t\t@if (subtitle()) {\n\t\t\t\t<p class=\"text-primary-gradient-content/70\" stText=\"7\" stTextWeight=\"medium\" stTextLineClamp=\"2\">{{ subtitle() }}</p>\n\t\t\t}\n\t\t</div>\n\n\t\t@if (backLink()) {\n\t\t\t<div data-st-banner-back [class]=\"backFocusClass\">\n\t\t\t\t<st-button size=\"sm\" [icon]=\"backIcon\" (clicked)=\"goBack()\">\n\t\t\t\t\t{{ 'sdk.layout.back' | translate }}\n\t\t\t\t</st-button>\n\t\t\t</div>\n\t\t}\n\t</div>\n}\n\n<!-- Stretch the routed page (a sibling of router-outlet) so feature cards can fill the shell -->\n<div\n\tclass=\"flex min-h-0 flex-1 flex-col [&>*:not(router-outlet)]:flex [&>*:not(router-outlet)]:min-h-full [&>*:not(router-outlet)]:flex-1 [&>*:not(router-outlet)]:flex-col\"\n>\n\t<ng-content />\n</div>\n" }]
|
|
912
|
+
}] });
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Generated bundle index. Do not edit.
|
|
916
|
+
*/
|
|
917
|
+
|
|
918
|
+
export { AppLayoutComponent, AppLayoutNavbarEndDirective, DEFAULT_MENU_ACTIVE_MATCH, DEFAULT_MENU_TOP_LEVEL_GROUPS, LAYOUT_ACCOUNT, LAYOUT_CONFIG, LAYOUT_OPTIONS, LayoutService, LayoutSwitcherComponent, MENU_QUERY_PARAM, NavbarComponent, PageBannerComponent, SideMenuComponent, UserMenuComponent, createMenuAnimationStore, findMenuIdTrail, findRouteTrail, firstNavigableMenuItem, isActiveMenuItem, menuIdFromUrl, menuItemHasChildren, menuLinkQueryParams, menuQueryParams, menuRoutesMatch, normalizeMenuRoute, normalizeMenuSearchText, provideLayout, provideLayoutAccount, resolveActiveMenu, searchMenu, shouldSyncActiveBranch, toMenuSections, toRailItems, walkMenuItems };
|
|
919
|
+
//# sourceMappingURL=sixbell-telco-sdk-layouts.mjs.map
|