@juice-js/layout 2.1.0-alpha.1 → 2.1.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/fesm2022/juice-js-layout.mjs +473 -49
- package/fesm2022/juice-js-layout.mjs.map +1 -1
- package/package.json +4 -4
- package/styles/_theming.scss +9 -0
- package/types/juice-js-layout.d.ts +160 -23
|
@@ -2,21 +2,22 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, Type, Signal, ChangeDetectorRef, ComponentRef, ElementRef, ViewContainerRef, OnInit, ModuleWithProviders } from '@angular/core';
|
|
3
3
|
import { TenantService, MenuItem, MenuService, AsyncDialog } from '@juice-js/core';
|
|
4
4
|
import { BreakpointObserver } from '@angular/cdk/layout';
|
|
5
|
-
import * as
|
|
5
|
+
import * as i9 from '@angular/router';
|
|
6
6
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
7
7
|
import { OAuthService } from 'angular-oauth2-oidc';
|
|
8
|
-
import * as
|
|
9
|
-
import * as i10 from '@
|
|
10
|
-
import * as i11 from '@
|
|
11
|
-
import * as i12 from '@angular/material/
|
|
12
|
-
import * as i13 from '@angular/material/
|
|
13
|
-
import * as i14 from '@angular/material/
|
|
14
|
-
import * as i15 from '@angular/material/
|
|
15
|
-
import * as i16 from '@angular/material/
|
|
16
|
-
import * as i17 from '@angular/material/
|
|
17
|
-
import * as i18 from '@angular/material/
|
|
18
|
-
import * as i19 from '@angular/material/
|
|
19
|
-
import * as
|
|
8
|
+
import * as _juice_js_layout from '@juice-js/layout';
|
|
9
|
+
import * as i10 from '@angular/common';
|
|
10
|
+
import * as i11 from '@ngx-translate/core';
|
|
11
|
+
import * as i12 from '@angular/material/icon';
|
|
12
|
+
import * as i13 from '@angular/material/toolbar';
|
|
13
|
+
import * as i14 from '@angular/material/sidenav';
|
|
14
|
+
import * as i15 from '@angular/material/button';
|
|
15
|
+
import * as i16 from '@angular/material/expansion';
|
|
16
|
+
import * as i17 from '@angular/material/list';
|
|
17
|
+
import * as i18 from '@angular/material/form-field';
|
|
18
|
+
import * as i19 from '@angular/material/input';
|
|
19
|
+
import * as i20 from '@angular/material/tooltip';
|
|
20
|
+
import * as i21 from '@angular/material/dialog';
|
|
20
21
|
|
|
21
22
|
declare enum ThemeMode {
|
|
22
23
|
Light = "light",
|
|
@@ -32,6 +33,7 @@ declare class LayoutConfig {
|
|
|
32
33
|
defaultMenuOpen: boolean;
|
|
33
34
|
settingUrl: string | undefined;
|
|
34
35
|
userImageUrl: string | undefined;
|
|
36
|
+
pageSwitcher: boolean;
|
|
35
37
|
constructor(options?: ILayoutConfig);
|
|
36
38
|
}
|
|
37
39
|
interface ILayoutConfig {
|
|
@@ -43,6 +45,11 @@ interface ILayoutConfig {
|
|
|
43
45
|
defaultMenuOpen?: boolean;
|
|
44
46
|
settingUrl?: string;
|
|
45
47
|
userImageUrl?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The page switcher (Ctrl+K or ⌘K, and a toolbar button) and the menu's go-to keys (`shortcut` on a menu item).
|
|
50
|
+
* Default true.
|
|
51
|
+
*/
|
|
52
|
+
pageSwitcher?: boolean;
|
|
46
53
|
}
|
|
47
54
|
/**
|
|
48
55
|
* Components an app adds to the toolbar, before the dark mode switch (a notification bell): provide each with `multi: true`.
|
|
@@ -129,15 +136,93 @@ declare class SearchService {
|
|
|
129
136
|
static ɵprov: i0.ɵɵInjectableDeclaration<SearchService>;
|
|
130
137
|
}
|
|
131
138
|
|
|
139
|
+
/** A page the switcher offers: a menu item with a page of its own. */
|
|
140
|
+
interface PageEntry {
|
|
141
|
+
id: string;
|
|
142
|
+
label: string;
|
|
143
|
+
icon: string;
|
|
144
|
+
routerLink: string;
|
|
145
|
+
/** The label of the menu group it sits in, if any. */
|
|
146
|
+
group?: string;
|
|
147
|
+
/** Its go-to keys, such as `g s`. */
|
|
148
|
+
shortcut?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The page switcher (Ctrl+K or ⌘K) and the go-to keys (`g` then a letter) over the app's menu. Every menu entry with a
|
|
152
|
+
* page of its own is offered, also those kept out of the side menu (`inMenu: false`); a group that only links to its
|
|
153
|
+
* first page is offered as that page.
|
|
154
|
+
*
|
|
155
|
+
* Part of the shell ({@link PageComponent}): the pages are its side menu's own items ({@link setItems}), so they
|
|
156
|
+
* follow it (loaded once, and again when the shell is built again for another tenant), and the keys are live only
|
|
157
|
+
* while the shell is on screen ({@link attach}); the shell also shows the switcher while {@link isOpen}.
|
|
158
|
+
* Keys typed into a field or a widget that takes letters are left alone, and so is a Ctrl+K a page already handled.
|
|
159
|
+
*/
|
|
160
|
+
declare class PageSwitcherService {
|
|
161
|
+
private readonly router;
|
|
162
|
+
private readonly document;
|
|
163
|
+
private readonly tenants;
|
|
164
|
+
private readonly enabled;
|
|
165
|
+
private readonly _open;
|
|
166
|
+
private readonly _pages;
|
|
167
|
+
private ready;
|
|
168
|
+
private readyPromise;
|
|
169
|
+
private attached;
|
|
170
|
+
/** Counts menu loads, so a slower earlier one can't replace a later one's pages. */
|
|
171
|
+
private loads;
|
|
172
|
+
private readonly onKey;
|
|
173
|
+
private sequence;
|
|
174
|
+
private sequenceTimer;
|
|
175
|
+
/** Whether the switcher is on display. */
|
|
176
|
+
readonly isOpen: i0.Signal<boolean>;
|
|
177
|
+
/** The pages, in menu order; empty until the side menu has loaded. */
|
|
178
|
+
readonly pages: i0.Signal<PageEntry[]>;
|
|
179
|
+
/** Whether the app has the switcher (`LayoutConfig.pageSwitcher`, default true). */
|
|
180
|
+
get isEnabled(): boolean;
|
|
181
|
+
/** The menu's items, from the side menu once it has loaded them. Their links are resolved for the tenant. */
|
|
182
|
+
setItems(items: MenuItem[]): Promise<void>;
|
|
183
|
+
/** Resolves once the pages are known. */
|
|
184
|
+
whenReady(): Promise<void>;
|
|
185
|
+
/** Starts listening for the keys, for the shell on screen; the returned function stops. */
|
|
186
|
+
attach(): () => void;
|
|
187
|
+
open(): void;
|
|
188
|
+
close(): void;
|
|
189
|
+
/** Opens a page the switcher offered, and closes it. */
|
|
190
|
+
go(page: PageEntry): void;
|
|
191
|
+
/** The pages matching what was typed, best first: label starts with it, then a word in it does, then it contains it. */
|
|
192
|
+
filter(query: string): PageEntry[];
|
|
193
|
+
private onKeydown;
|
|
194
|
+
/** Takes the keys typed so far: goes, waits for more, or (false) leads nowhere. */
|
|
195
|
+
private step;
|
|
196
|
+
/** Whether another dialog is open: the keys are its, and a page change would happen behind it. */
|
|
197
|
+
private modalOpen;
|
|
198
|
+
private resetSequence;
|
|
199
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PageSwitcherService, never>;
|
|
200
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PageSwitcherService>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The menu's pages: those with a page of their own (see `MenuItem.hasOwnPage`), each in the group it sits in, with
|
|
204
|
+
* its link resolved for the tenant (a top-level page's link is still as written: `''` is the home page).
|
|
205
|
+
*/
|
|
206
|
+
declare function flatten(items: MenuItem[], tenant?: string | null, group?: string): PageEntry[];
|
|
207
|
+
|
|
132
208
|
declare class PageComponent {
|
|
133
209
|
service: LayoutService;
|
|
134
210
|
private search;
|
|
211
|
+
/** The page switcher: its keys are live while the shell is, and the shell shows it (see the constructor). */
|
|
212
|
+
switcher: PageSwitcherService;
|
|
135
213
|
private breakpointObserver;
|
|
136
214
|
/** The app's own toolbar items ({@link LAYOUT_TOOLBAR_ITEMS}). */
|
|
137
215
|
readonly toolbarItems: Type<unknown>[];
|
|
138
216
|
isMobile: boolean;
|
|
139
217
|
isSnavOpenned: boolean;
|
|
140
|
-
constructor(service: LayoutService, search: SearchService,
|
|
218
|
+
constructor(service: LayoutService, search: SearchService,
|
|
219
|
+
/** The page switcher: its keys are live while the shell is, and the shell shows it (see the constructor). */
|
|
220
|
+
switcher: PageSwitcherService, breakpointObserver: BreakpointObserver, cdr: ChangeDetectorRef);
|
|
221
|
+
/**
|
|
222
|
+
* Shows the page switcher in a dialog while it is open (the dialog brings the focus trap, Escape, the backdrop and
|
|
223
|
+
* gives focus back), and its keys while the shell is on screen.
|
|
224
|
+
*/
|
|
225
|
+
private hostPageSwitcher;
|
|
141
226
|
hideSidenavOnMobile(): void;
|
|
142
227
|
toggleSidenav(): void;
|
|
143
228
|
toolbarHeight(): string;
|
|
@@ -204,12 +289,17 @@ declare class NavMenuComponent {
|
|
|
204
289
|
private route;
|
|
205
290
|
private breakpointObserver;
|
|
206
291
|
private cdr;
|
|
292
|
+
private switcher;
|
|
207
293
|
isExpanded: boolean;
|
|
208
294
|
isMobile: boolean;
|
|
209
295
|
items: MenuItem[];
|
|
296
|
+
/** The items the side menu shows: all but those marked `inMenu: false` (the page switcher still offers them). */
|
|
297
|
+
menuItems: MenuItem[];
|
|
210
298
|
TooltipPosition: typeof TooltipPosition;
|
|
211
299
|
settingUrl: string | null | undefined;
|
|
212
|
-
constructor(service: MenuService, layout: LayoutService, tenantService: TenantService, route: ActivatedRoute, breakpointObserver: BreakpointObserver, cdr: ChangeDetectorRef);
|
|
300
|
+
constructor(service: MenuService, layout: LayoutService, tenantService: TenantService, route: ActivatedRoute, breakpointObserver: BreakpointObserver, cdr: ChangeDetectorRef, switcher: PageSwitcherService);
|
|
301
|
+
/** The items that show as a group: they have pages the side menu shows. */
|
|
302
|
+
groups: Set<MenuItem>;
|
|
213
303
|
toggle(): void;
|
|
214
304
|
mouseEnter(): void;
|
|
215
305
|
mouseLeave(): void;
|
|
@@ -217,12 +307,38 @@ declare class NavMenuComponent {
|
|
|
217
307
|
static ɵcmp: i0.ɵɵComponentDeclaration<NavMenuComponent, "juice-nav-menu", never, {}, {}, never, never, false, never>;
|
|
218
308
|
}
|
|
219
309
|
|
|
310
|
+
/**
|
|
311
|
+
* A menu item with children: a header that opens and closes them. The group opens itself whenever a navigation lands
|
|
312
|
+
* on one of its pages (also one kept out of the menu, `inMenu: false`), even if it was closed by hand. A header with a
|
|
313
|
+
* page of its own opens that page too; one without (`routerLink: ''`) only opens and closes.
|
|
314
|
+
*/
|
|
220
315
|
declare class ExpandableMenuComponent {
|
|
221
|
-
router
|
|
316
|
+
private readonly router;
|
|
317
|
+
private readonly cdr;
|
|
318
|
+
private readonly panel;
|
|
319
|
+
private _item;
|
|
222
320
|
isExpanded: boolean;
|
|
223
|
-
item: MenuItem;
|
|
321
|
+
set item(value: MenuItem);
|
|
322
|
+
get item(): MenuItem;
|
|
224
323
|
TooltipPosition: typeof TooltipPosition;
|
|
225
|
-
|
|
324
|
+
/** The children the side menu shows. */
|
|
325
|
+
children: MenuItem[];
|
|
326
|
+
/** Whether a page of the group (its own, or any child's, or one under them) is on display. */
|
|
327
|
+
open: boolean;
|
|
328
|
+
/** Whether to highlight the header: it has a page of its own and that page is on display. */
|
|
329
|
+
headerActive: boolean;
|
|
330
|
+
/** The header's own page, or null: a header without one (or linking to a child's page) only opens and closes. */
|
|
331
|
+
headerLink: string | null;
|
|
332
|
+
constructor();
|
|
333
|
+
private update;
|
|
334
|
+
/** The URL's path, without query string or fragment. */
|
|
335
|
+
private path;
|
|
336
|
+
/**
|
|
337
|
+
* How a child's link matches: with the pages under it, unless other pages of the group sit under it too (a link to
|
|
338
|
+
* `/` or to the tenant's root), which would make it match every page.
|
|
339
|
+
*/
|
|
340
|
+
private matching;
|
|
341
|
+
private isActive;
|
|
226
342
|
static ɵfac: i0.ɵɵFactoryDeclaration<ExpandableMenuComponent, never>;
|
|
227
343
|
static ɵcmp: i0.ɵɵComponentDeclaration<ExpandableMenuComponent, "juice-expandable-menu", never, { "isExpanded": { "alias": "isExpanded"; "required": false; }; "item": { "alias": "item"; "required": false; }; }, {}, never, never, false, never>;
|
|
228
344
|
}
|
|
@@ -289,10 +405,31 @@ declare class UserProfileComponent implements OnInit {
|
|
|
289
405
|
static ɵcmp: i0.ɵɵComponentDeclaration<UserProfileComponent, "juice-user-profile", never, {}, {}, never, never, false, never>;
|
|
290
406
|
}
|
|
291
407
|
|
|
408
|
+
/**
|
|
409
|
+
* The page switcher's content: a box to type a page's name in and the pages that match, with their group and go-to
|
|
410
|
+
* keys. Arrow keys move, Enter opens. The shell shows it in a dialog (which brings the focus trap, Escape and the
|
|
411
|
+
* backdrop) while {@link PageSwitcherService.isOpen}.
|
|
412
|
+
*/
|
|
413
|
+
declare class PageSwitcherComponent {
|
|
414
|
+
readonly service: PageSwitcherService;
|
|
415
|
+
readonly query: i0.WritableSignal<string>;
|
|
416
|
+
readonly selected: i0.WritableSignal<number>;
|
|
417
|
+
readonly results: i0.Signal<_juice_js_layout.PageEntry[]>;
|
|
418
|
+
private readonly list;
|
|
419
|
+
onInput(value: string): void;
|
|
420
|
+
onKeydown(e: KeyboardEvent): void;
|
|
421
|
+
/** Unique per row (menu ids need not be). */
|
|
422
|
+
optionId(index: number): string;
|
|
423
|
+
keys(shortcut: string): string[];
|
|
424
|
+
private select;
|
|
425
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PageSwitcherComponent, never>;
|
|
426
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PageSwitcherComponent, "juice-page-switcher", never, {}, {}, never, never, false, never>;
|
|
427
|
+
}
|
|
428
|
+
|
|
292
429
|
declare class LayoutModule {
|
|
293
430
|
static forRoot(production: boolean, options: ILayoutConfig): ModuleWithProviders<LayoutModule>;
|
|
294
431
|
static ɵfac: i0.ɵɵFactoryDeclaration<LayoutModule, never>;
|
|
295
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<LayoutModule, [typeof PageComponent, typeof DarkModeComponent, typeof NavMenuComponent, typeof ExpandableMenuComponent, typeof PageNotfoundComponent, typeof SearchBarComponent, typeof UserProfileComponent], [typeof
|
|
432
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<LayoutModule, [typeof PageComponent, typeof DarkModeComponent, typeof NavMenuComponent, typeof ExpandableMenuComponent, typeof PageNotfoundComponent, typeof SearchBarComponent, typeof UserProfileComponent, typeof PageSwitcherComponent], [typeof i9.RouterModule, typeof i10.CommonModule, typeof i11.TranslatePipe, typeof i11.TranslateDirective, typeof i12.MatIconModule, typeof i13.MatToolbarModule, typeof i14.MatSidenavModule, typeof i15.MatButtonModule, typeof i16.MatExpansionModule, typeof i17.MatListModule, typeof i18.MatFormFieldModule, typeof i19.MatInputModule, typeof i20.MatTooltipModule, typeof i21.MatDialogModule], [typeof PageComponent, typeof i9.RouterModule]>;
|
|
296
433
|
static ɵinj: i0.ɵɵInjectorDeclaration<LayoutModule>;
|
|
297
434
|
}
|
|
298
435
|
|
|
@@ -311,7 +448,7 @@ declare class TooltipComponent {
|
|
|
311
448
|
|
|
312
449
|
declare class TooltipModule {
|
|
313
450
|
static ɵfac: i0.ɵɵFactoryDeclaration<TooltipModule, never>;
|
|
314
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<TooltipModule, [typeof TooltipComponent, typeof TooltipDirective], [typeof
|
|
451
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<TooltipModule, [typeof TooltipComponent, typeof TooltipDirective], [typeof i10.CommonModule], [typeof TooltipDirective]>;
|
|
315
452
|
static ɵinj: i0.ɵɵInjectorDeclaration<TooltipModule>;
|
|
316
453
|
}
|
|
317
454
|
|
|
@@ -380,9 +517,9 @@ declare class UserProfileDialogComponent implements OnInit {
|
|
|
380
517
|
|
|
381
518
|
declare class UserProfileDialogModule {
|
|
382
519
|
static ɵfac: i0.ɵɵFactoryDeclaration<UserProfileDialogModule, never>;
|
|
383
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<UserProfileDialogModule, [typeof UserProfileDialogComponent], [typeof
|
|
520
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<UserProfileDialogModule, [typeof UserProfileDialogComponent], [typeof i21.MatDialogModule, typeof i15.MatButtonModule, typeof i11.TranslatePipe, typeof i11.TranslateDirective, typeof i10.CommonModule], never>;
|
|
384
521
|
static ɵinj: i0.ɵɵInjectorDeclaration<UserProfileDialogModule>;
|
|
385
522
|
}
|
|
386
523
|
|
|
387
|
-
export { DevGuard, ExpandableMenuComponent, LAYOUT_TOOLBAR_ITEMS, LayoutModule, LayoutService, NavMenuComponent, PageComponent, PageNotfoundComponent, ProfileDialogService, SearchService, TooltipDirective, TooltipModule, TooltipPosition, UserProfileDialogModule, isSearchablePage };
|
|
388
|
-
export type { SearchablePage };
|
|
524
|
+
export { DevGuard, ExpandableMenuComponent, LAYOUT_TOOLBAR_ITEMS, LayoutModule, LayoutService, NavMenuComponent, PageComponent, PageNotfoundComponent, PageSwitcherComponent, PageSwitcherService, ProfileDialogService, SearchService, TooltipDirective, TooltipModule, TooltipPosition, UserProfileDialogModule, flatten, isSearchablePage };
|
|
525
|
+
export type { PageEntry, SearchablePage };
|