@aquera/nile-elements 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/demo/nxtgen-classes.css +15 -12
- package/demo/nxtgen-dark.css +24 -24
- package/demo/nxtgen-properties.css +27 -24
- package/demo/nxtgen-utilities.css +39 -36
- package/demo/nxtgen.css +15 -12
- package/demo/utilities.css +3 -0
- package/demo/variables.css +3 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1353 -340
- package/dist/internal/glyph.cjs.js +1 -1
- package/dist/internal/glyph.cjs.js.map +1 -1
- package/dist/internal/glyph.esm.js +6 -5
- package/dist/nile-app-shell/index.cjs.js +2 -0
- package/dist/nile-app-shell/index.cjs.js.map +1 -0
- package/dist/nile-app-shell/index.esm.js +1 -0
- package/dist/nile-app-shell/nile-app-shell.cjs.js +2 -0
- package/dist/nile-app-shell/nile-app-shell.cjs.js.map +1 -0
- package/dist/nile-app-shell/nile-app-shell.css.cjs.js +2 -0
- package/dist/nile-app-shell/nile-app-shell.css.cjs.js.map +1 -0
- package/dist/nile-app-shell/nile-app-shell.css.esm.js +554 -0
- package/dist/nile-app-shell/nile-app-shell.esm.js +155 -0
- package/dist/nile-app-shell/shell-controller.cjs.js +2 -0
- package/dist/nile-app-shell/shell-controller.cjs.js.map +1 -0
- package/dist/nile-app-shell/shell-controller.esm.js +1 -0
- package/dist/nile-app-shell-main/index.cjs.js +2 -0
- package/dist/nile-app-shell-main/index.cjs.js.map +1 -0
- package/dist/nile-app-shell-main/index.esm.js +1 -0
- package/dist/nile-app-shell-main/nile-app-shell-main.cjs.js +2 -0
- package/dist/nile-app-shell-main/nile-app-shell-main.cjs.js.map +1 -0
- package/dist/nile-app-shell-main/nile-app-shell-main.css.cjs.js +2 -0
- package/dist/nile-app-shell-main/nile-app-shell-main.css.cjs.js.map +1 -0
- package/dist/nile-app-shell-main/nile-app-shell-main.css.esm.js +18 -0
- package/dist/nile-app-shell-main/nile-app-shell-main.esm.js +1 -0
- package/dist/nile-app-shell-nav-toggle/index.cjs.js +2 -0
- package/dist/nile-app-shell-nav-toggle/index.cjs.js.map +1 -0
- package/dist/nile-app-shell-nav-toggle/index.esm.js +1 -0
- package/dist/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.cjs.js +2 -0
- package/dist/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.cjs.js.map +1 -0
- package/dist/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.cjs.js +2 -0
- package/dist/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.cjs.js.map +1 -0
- package/dist/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.esm.js +29 -0
- package/dist/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.esm.js +16 -0
- package/dist/nile-app-shell-panel/index.cjs.js +2 -0
- package/dist/nile-app-shell-panel/index.cjs.js.map +1 -0
- package/dist/nile-app-shell-panel/index.esm.js +1 -0
- package/dist/nile-app-shell-panel/nile-app-shell-panel.cjs.js +2 -0
- package/dist/nile-app-shell-panel/nile-app-shell-panel.cjs.js.map +1 -0
- package/dist/nile-app-shell-panel/nile-app-shell-panel.css.cjs.js +2 -0
- package/dist/nile-app-shell-panel/nile-app-shell-panel.css.cjs.js.map +1 -0
- package/dist/nile-app-shell-panel/nile-app-shell-panel.css.esm.js +103 -0
- package/dist/nile-app-shell-panel/nile-app-shell-panel.esm.js +33 -0
- package/dist/nile-app-shell-side-nav/index.cjs.js +2 -0
- package/dist/nile-app-shell-side-nav/index.cjs.js.map +1 -0
- package/dist/nile-app-shell-side-nav/index.esm.js +1 -0
- package/dist/nile-app-shell-side-nav/nile-app-shell-side-nav.cjs.js +2 -0
- package/dist/nile-app-shell-side-nav/nile-app-shell-side-nav.cjs.js.map +1 -0
- package/dist/nile-app-shell-side-nav/nile-app-shell-side-nav.css.cjs.js +2 -0
- package/dist/nile-app-shell-side-nav/nile-app-shell-side-nav.css.cjs.js.map +1 -0
- package/dist/nile-app-shell-side-nav/nile-app-shell-side-nav.css.esm.js +55 -0
- package/dist/nile-app-shell-side-nav/nile-app-shell-side-nav.esm.js +5 -0
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js.map +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.cjs.js.map +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.esm.js +46 -8
- package/dist/nile-floating-panel/nile-floating-panel.esm.js +1 -1
- package/dist/nile-popover/nile-popover.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.cjs.js.map +1 -1
- package/dist/nile-popover/nile-popover.css.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.css.cjs.js.map +1 -1
- package/dist/nile-popover/nile-popover.css.esm.js +32 -17
- package/dist/nile-popover/nile-popover.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-menu.esm.js +2 -2
- package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/image-menu.esm.js +4 -4
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +1 -1
- package/dist/src/index.d.ts +7 -2
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/glyph.d.ts +6 -1
- package/dist/src/internal/glyph.js +8 -1
- package/dist/src/internal/glyph.js.map +1 -1
- package/dist/src/nile-app-shell/index.d.ts +7 -0
- package/dist/src/nile-app-shell/index.js +8 -0
- package/dist/src/nile-app-shell/index.js.map +1 -0
- package/dist/src/nile-app-shell/nile-app-shell-regions.test.d.ts +4 -0
- package/dist/src/nile-app-shell/nile-app-shell-regions.test.js +177 -0
- package/dist/src/nile-app-shell/nile-app-shell-regions.test.js.map +1 -0
- package/dist/src/nile-app-shell/nile-app-shell.css.d.ts +18 -0
- package/dist/src/nile-app-shell/nile-app-shell.css.js +572 -0
- package/dist/src/nile-app-shell/nile-app-shell.css.js.map +1 -0
- package/dist/src/nile-app-shell/nile-app-shell.d.ts +292 -0
- package/dist/src/nile-app-shell/nile-app-shell.js +796 -0
- package/dist/src/nile-app-shell/nile-app-shell.js.map +1 -0
- package/dist/src/nile-app-shell/nile-app-shell.test.d.ts +3 -0
- package/dist/src/nile-app-shell/nile-app-shell.test.js +454 -0
- package/dist/src/nile-app-shell/nile-app-shell.test.js.map +1 -0
- package/dist/src/nile-app-shell/shell-controller.d.ts +34 -0
- package/dist/src/nile-app-shell/shell-controller.js +80 -0
- package/dist/src/nile-app-shell/shell-controller.js.map +1 -0
- package/dist/src/nile-app-shell-main/index.d.ts +7 -0
- package/dist/src/nile-app-shell-main/index.js +8 -0
- package/dist/src/nile-app-shell-main/index.js.map +1 -0
- package/dist/src/nile-app-shell-main/nile-app-shell-main.css.d.ts +9 -0
- package/dist/src/nile-app-shell-main/nile-app-shell-main.css.js +27 -0
- package/dist/src/nile-app-shell-main/nile-app-shell-main.css.js.map +1 -0
- package/dist/src/nile-app-shell-main/nile-app-shell-main.d.ts +38 -0
- package/dist/src/nile-app-shell-main/nile-app-shell-main.js +51 -0
- package/dist/src/nile-app-shell-main/nile-app-shell-main.js.map +1 -0
- package/dist/src/nile-app-shell-nav-toggle/index.d.ts +7 -0
- package/dist/src/nile-app-shell-nav-toggle/index.js +8 -0
- package/dist/src/nile-app-shell-nav-toggle/index.js.map +1 -0
- package/dist/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.d.ts +13 -0
- package/dist/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.js +42 -0
- package/dist/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.js.map +1 -0
- package/dist/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.d.ts +56 -0
- package/dist/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.js +126 -0
- package/dist/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.js.map +1 -0
- package/dist/src/nile-app-shell-panel/index.d.ts +7 -0
- package/dist/src/nile-app-shell-panel/index.js +8 -0
- package/dist/src/nile-app-shell-panel/index.js.map +1 -0
- package/dist/src/nile-app-shell-panel/nile-app-shell-panel.css.d.ts +9 -0
- package/dist/src/nile-app-shell-panel/nile-app-shell-panel.css.js +112 -0
- package/dist/src/nile-app-shell-panel/nile-app-shell-panel.css.js.map +1 -0
- package/dist/src/nile-app-shell-panel/nile-app-shell-panel.d.ts +73 -0
- package/dist/src/nile-app-shell-panel/nile-app-shell-panel.js +158 -0
- package/dist/src/nile-app-shell-panel/nile-app-shell-panel.js.map +1 -0
- package/dist/src/nile-app-shell-side-nav/index.d.ts +7 -0
- package/dist/src/nile-app-shell-side-nav/index.js +8 -0
- package/dist/src/nile-app-shell-side-nav/index.js.map +1 -0
- package/dist/src/nile-app-shell-side-nav/nile-app-shell-side-nav.css.d.ts +13 -0
- package/dist/src/nile-app-shell-side-nav/nile-app-shell-side-nav.css.js +68 -0
- package/dist/src/nile-app-shell-side-nav/nile-app-shell-side-nav.css.js.map +1 -0
- package/dist/src/nile-app-shell-side-nav/nile-app-shell-side-nav.d.ts +54 -0
- package/dist/src/nile-app-shell-side-nav/nile-app-shell-side-nav.js +83 -0
- package/dist/src/nile-app-shell-side-nav/nile-app-shell-side-nav.js.map +1 -0
- package/dist/src/nile-floating-panel/nile-floating-panel.css.js +46 -8
- package/dist/src/nile-floating-panel/nile-floating-panel.css.js.map +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.js +13 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.js.map +1 -1
- package/dist/src/nile-popover/nile-popover.css.js +30 -15
- package/dist/src/nile-popover/nile-popover.css.js.map +1 -1
- package/dist/src/nile-popover/nile-popover.js +1 -1
- package/dist/src/nile-popover/nile-popover.js.map +1 -1
- package/dist/src/nile-popover/nile-popover.test.js +1 -1
- package/dist/src/nile-popover/nile-popover.test.js.map +1 -1
- package/dist/src/version.d.ts +11 -1
- package/dist/src/version.js +51 -8
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.cjs.js +1 -1
- package/dist/version.cjs.js.map +1 -1
- package/dist/version.esm.js +1 -1
- package/package.json +7 -2
- package/src/index.ts +16 -4
- package/src/internal/glyph.ts +12 -1
- package/src/nile-app-shell/index.ts +8 -0
- package/src/nile-app-shell/nile-app-shell-regions.test.ts +215 -0
- package/src/nile-app-shell/nile-app-shell.css.ts +574 -0
- package/src/nile-app-shell/nile-app-shell.test.ts +536 -0
- package/src/nile-app-shell/nile-app-shell.ts +838 -0
- package/src/nile-app-shell/shell-controller.ts +100 -0
- package/src/nile-app-shell-main/index.ts +8 -0
- package/src/nile-app-shell-main/nile-app-shell-main.css.ts +29 -0
- package/src/nile-app-shell-main/nile-app-shell-main.ts +52 -0
- package/src/nile-app-shell-nav-toggle/index.ts +8 -0
- package/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.css.ts +44 -0
- package/src/nile-app-shell-nav-toggle/nile-app-shell-nav-toggle.ts +138 -0
- package/src/nile-app-shell-panel/index.ts +8 -0
- package/src/nile-app-shell-panel/nile-app-shell-panel.css.ts +114 -0
- package/src/nile-app-shell-panel/nile-app-shell-panel.ts +161 -0
- package/src/nile-app-shell-side-nav/index.ts +8 -0
- package/src/nile-app-shell-side-nav/nile-app-shell-side-nav.css.ts +70 -0
- package/src/nile-app-shell-side-nav/nile-app-shell-side-nav.ts +86 -0
- package/src/nile-floating-panel/nile-floating-panel.css.ts +46 -8
- package/src/nile-floating-panel/nile-floating-panel.ts +19 -1
- package/src/nile-popover/nile-popover.css.ts +30 -15
- package/src/nile-popover/nile-popover.test.ts +1 -1
- package/src/nile-popover/nile-popover.ts +1 -1
- package/src/version.ts +55 -7
- package/vscode-html-custom-data.json +216 -5
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { html, CSSResultArray, TemplateResult, PropertyValues } from 'lit';
|
|
9
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { styles } from './nile-app-shell.css';
|
|
12
|
+
import { renderGlyph } from '../internal/glyph';
|
|
13
|
+
import NileElement from '../internal/nile-element';
|
|
14
|
+
import '../nile-button/nile-button';
|
|
15
|
+
|
|
16
|
+
/** The mode the AI panel is currently in. */
|
|
17
|
+
export type NileAppShellPanelMode = 'docked' | 'overlay';
|
|
18
|
+
|
|
19
|
+
/** Where the top bar is mounted. */
|
|
20
|
+
export type NileAppShellTopBarPlacement = 'content' | 'shell';
|
|
21
|
+
|
|
22
|
+
/** How the main region lays its content out. */
|
|
23
|
+
export type NileAppShellContentAlign = 'fluid' | 'centered';
|
|
24
|
+
|
|
25
|
+
/** The shell's own track and region widths, in px. */
|
|
26
|
+
interface ShellGeometry {
|
|
27
|
+
nav: number;
|
|
28
|
+
rail: number;
|
|
29
|
+
gutter: number;
|
|
30
|
+
content: number;
|
|
31
|
+
aside: number;
|
|
32
|
+
panel: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @summary The application frame every route inherits: a side nav, a content
|
|
37
|
+
* container, an optional aside and an AI assistant panel. It holds anything —
|
|
38
|
+
* the shell owns the boxes, the page owns what goes in them.
|
|
39
|
+
*
|
|
40
|
+
* @status stable
|
|
41
|
+
* @since 2.0
|
|
42
|
+
*
|
|
43
|
+
* @tag nile-app-shell
|
|
44
|
+
*
|
|
45
|
+
* @dependency nile-button
|
|
46
|
+
* @dependency nile-glyph
|
|
47
|
+
*
|
|
48
|
+
* @slot - The page body, inside the content container.
|
|
49
|
+
* @slot banner - A full-width strip above every other region.
|
|
50
|
+
* @slot top-bar - The page-title bar. Mounted inside the container by default,
|
|
51
|
+
* or spanning the shell when `top-bar-placement="shell"`. The nav toggle is
|
|
52
|
+
* rendered before whatever is slotted here.
|
|
53
|
+
* @slot top-bar-actions - Controls pinned to the end of the top bar.
|
|
54
|
+
* @slot tabs - A hoisted second-level tab strip, flush under the top bar and
|
|
55
|
+
* outside `<main>`'s scroller, so it never scrolls away. The region carries
|
|
56
|
+
* the strip's height, padding and rule, so slot a `<nile-tab-group>` or the
|
|
57
|
+
* tab controls themselves.
|
|
58
|
+
* @slot side-nav - The navigation track. Works best with `<nile-side-bar>`.
|
|
59
|
+
* @slot aside - A secondary column between the content container and the panel.
|
|
60
|
+
* @slot panel - The AI panel's body. When nothing is slotted here the panel is
|
|
61
|
+
* unmounted and `openPanel()` is a no-op.
|
|
62
|
+
* @slot panel-header - Replaces the default panel heading (mark plus title).
|
|
63
|
+
* @slot panel-actions - Controls added before the panel's close button.
|
|
64
|
+
* @slot panel-footer - A bar docked below the panel's scroll region, for a
|
|
65
|
+
* composer.
|
|
66
|
+
*
|
|
67
|
+
* @event nile-nav-toggle - Emitted after the nav's collapsed state or its
|
|
68
|
+
* forced-rail lock changes. `detail: { collapsed, locked }`.
|
|
69
|
+
* @event nile-panel-toggle - Emitted after the panel opens or closes.
|
|
70
|
+
* `detail: { open, mode }`.
|
|
71
|
+
* @event nile-panel-mode-change - Emitted when the panel flips between docked
|
|
72
|
+
* and overlay. `detail: { mode }`.
|
|
73
|
+
*
|
|
74
|
+
* @csspart skip-link - The skip-to-content link.
|
|
75
|
+
* @csspart banner - The banner region.
|
|
76
|
+
* @csspart shell-top-bar - The top bar when it spans the shell.
|
|
77
|
+
* @csspart top-bar - The top bar, in either placement.
|
|
78
|
+
* @csspart nav-toggle - The built-in nav toggle button.
|
|
79
|
+
* @csspart rule - The vertical rule after the nav toggle.
|
|
80
|
+
* @csspart top-bar-actions - The end-aligned top bar action group. Unmounted
|
|
81
|
+
* when it holds neither slotted actions nor the Ask button, so it reserves
|
|
82
|
+
* no gap.
|
|
83
|
+
* @csspart ask - The built-in Ask button, the shell's single door to the panel.
|
|
84
|
+
* A `<nile-button>`; its inner surface and label are exported as
|
|
85
|
+
* `ask__base` and `ask__label`.
|
|
86
|
+
* @csspart tabs - The hoisted tab-strip region, under the top bar.
|
|
87
|
+
* @csspart side-nav - The navigation track.
|
|
88
|
+
* @csspart content-section - The flex row holding container, aside and panel.
|
|
89
|
+
* @csspart container - The content container.
|
|
90
|
+
* @csspart main - The scrolling page body.
|
|
91
|
+
* @csspart aside - The aside region.
|
|
92
|
+
* @csspart panel - The AI panel.
|
|
93
|
+
* @csspart panel-header - The panel's header bar.
|
|
94
|
+
* @csspart panel-title - The panel's title text.
|
|
95
|
+
* @csspart panel-actions - The panel's header action group.
|
|
96
|
+
* @csspart panel-close - The panel's close button.
|
|
97
|
+
* @csspart panel-body - The panel's scroll region.
|
|
98
|
+
* @csspart panel-footer - The panel's footer.
|
|
99
|
+
*
|
|
100
|
+
* @cssproperty [--nile-app-shell-side-nav-width=260px] - Expanded nav track.
|
|
101
|
+
* @cssproperty [--nile-app-shell-side-nav-rail-width=64px] - Collapsed track.
|
|
102
|
+
* @cssproperty [--nile-app-shell-side-nav-bg=transparent] - Surface behind a
|
|
103
|
+
* slotted side nav. Transparent by default: the nav and the page share one
|
|
104
|
+
* surface.
|
|
105
|
+
* @cssproperty [--nile-app-shell-side-nav-border=0] - Edge on a slotted side
|
|
106
|
+
* nav.
|
|
107
|
+
* @cssproperty [--nile-app-shell-gutter=8px] - Content-section padding, and the
|
|
108
|
+
* gap between container, aside and panel.
|
|
109
|
+
* @cssproperty [--nile-app-shell-content-padding=24px] - Container inner
|
|
110
|
+
* padding. The origin every top bar starts at.
|
|
111
|
+
* @cssproperty [--nile-app-shell-top-bar-height=56px] - Top bar and panel
|
|
112
|
+
* header height. Drops to 48px under 600px of viewport height.
|
|
113
|
+
* @cssproperty [--nile-app-shell-tabs-height=48px] - Tab strip height.
|
|
114
|
+
* @cssproperty [--nile-app-shell-panel-width=480px] - Docked panel width, and
|
|
115
|
+
* the `min()` ceiling for the overlay drawer.
|
|
116
|
+
* @cssproperty [--nile-app-shell-panel-min-width=360px] - How far a docked
|
|
117
|
+
* panel shrinks to keep pushing rather than covering the page.
|
|
118
|
+
* @cssproperty [--nile-app-shell-aside-width=320px] - Aside width.
|
|
119
|
+
* @cssproperty [--nile-app-shell-aside-min-width=240px] - How far the aside
|
|
120
|
+
* shrinks before the page is asked for room.
|
|
121
|
+
* @cssproperty [--nile-app-shell-content-min-width=640px] - Container floor.
|
|
122
|
+
* @cssproperty [--nile-app-shell-min-width=768px] - Below this the window
|
|
123
|
+
* scrolls rather than the shell compressing.
|
|
124
|
+
* @cssproperty [--nile-app-shell-centered-width=824px] - Column width under
|
|
125
|
+
* `content-align="centered"`.
|
|
126
|
+
* @cssproperty [--nile-app-shell-utility-size=32px] - Height of the Ask
|
|
127
|
+
* button. The toggle and close controls are nile-buttons and size themselves.
|
|
128
|
+
* @cssproperty [--nile-app-shell-radius=16px] - Container, aside and panel
|
|
129
|
+
* radius.
|
|
130
|
+
* @cssproperty [--nile-app-shell-duration=250ms] - Track and panel motion.
|
|
131
|
+
* @cssproperty [--nile-app-shell-ease] - Easing for moves and resizes.
|
|
132
|
+
*
|
|
133
|
+
* @method openPanel() - Open the AI panel. No-op when the panel is unavailable.
|
|
134
|
+
* @method closePanel() - Close the AI panel.
|
|
135
|
+
* @method togglePanel(force?) - Toggle, or force a specific open state.
|
|
136
|
+
* @method expandNav() - Expand the side nav.
|
|
137
|
+
* @method collapseNav() - Collapse the side nav to a rail.
|
|
138
|
+
* @method toggleNav(force?) - Toggle, or force a specific collapsed state.
|
|
139
|
+
*/
|
|
140
|
+
@customElement('nile-app-shell')
|
|
141
|
+
export class NileAppShell extends NileElement {
|
|
142
|
+
public static get styles(): CSSResultArray {
|
|
143
|
+
return [styles];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The user's nav preference. The nav can still render as a rail while this is
|
|
148
|
+
* false — see `navLocked`.
|
|
149
|
+
*/
|
|
150
|
+
@property({ type: Boolean, reflect: true, attribute: 'nav-collapsed' })
|
|
151
|
+
navCollapsed: boolean = false;
|
|
152
|
+
|
|
153
|
+
/** Whether the AI panel is open. */
|
|
154
|
+
@property({ type: Boolean, reflect: true, attribute: 'panel-open' })
|
|
155
|
+
panelOpen: boolean = false;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Unmounts the AI panel for this route even when the `panel` slot is filled.
|
|
159
|
+
* `openPanel()` becomes a no-op.
|
|
160
|
+
*/
|
|
161
|
+
@property({ type: Boolean, reflect: true, attribute: 'no-panel' })
|
|
162
|
+
noPanel: boolean = false;
|
|
163
|
+
|
|
164
|
+
/** The default panel heading. Ignored when `panel-header` is slotted. */
|
|
165
|
+
@property({ type: String, attribute: 'panel-label' })
|
|
166
|
+
panelLabel: string = 'Ask Aquera';
|
|
167
|
+
|
|
168
|
+
/** Hides the built-in nav toggle. Mount `nile-app-shell-nav-toggle` yourself. */
|
|
169
|
+
@property({ type: Boolean, reflect: true, attribute: 'no-nav-toggle' })
|
|
170
|
+
noNavToggle: boolean = false;
|
|
171
|
+
|
|
172
|
+
/** Drops the Cmd/Ctrl+J and Escape panel shortcuts. */
|
|
173
|
+
@property({ type: Boolean, attribute: 'no-panel-shortcut' })
|
|
174
|
+
noPanelShortcut: boolean = false;
|
|
175
|
+
|
|
176
|
+
/** Hides the skip-to-content link. */
|
|
177
|
+
@property({ type: Boolean, reflect: true, attribute: 'no-skip-link' })
|
|
178
|
+
noSkipLink: boolean = false;
|
|
179
|
+
|
|
180
|
+
/** Label for the skip-to-content link. */
|
|
181
|
+
@property({ type: String, attribute: 'skip-link-label' })
|
|
182
|
+
skipLinkLabel: string = 'Skip to main content';
|
|
183
|
+
|
|
184
|
+
/** Where the top bar is mounted: inside the container, or spanning the shell. */
|
|
185
|
+
@property({ type: String, reflect: true, attribute: 'top-bar-placement' })
|
|
186
|
+
topBarPlacement: NileAppShellTopBarPlacement = 'content';
|
|
187
|
+
|
|
188
|
+
/** `centered` caps the page body at `--nile-app-shell-centered-width`. */
|
|
189
|
+
@property({ type: String, reflect: true, attribute: 'content-align' })
|
|
190
|
+
contentAlign: NileAppShellContentAlign = 'fluid';
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Makes the slotted page root a size query container, so page CSS can size
|
|
194
|
+
* against the content container instead of the viewport. Query it unnamed —
|
|
195
|
+
* `@container (min-width: 720px)` — because a container name declared inside
|
|
196
|
+
* the shell's shadow tree is not visible to page CSS. Opt-in, because it
|
|
197
|
+
* also applies layout containment to that element.
|
|
198
|
+
*/
|
|
199
|
+
@property({ type: Boolean, reflect: true, attribute: 'content-container' })
|
|
200
|
+
contentContainer: boolean = false;
|
|
201
|
+
|
|
202
|
+
/** Drops the container's card chrome for a full-bleed page. */
|
|
203
|
+
@property({ type: Boolean, reflect: true })
|
|
204
|
+
flat: boolean = false;
|
|
205
|
+
|
|
206
|
+
/** Removes the container's inner padding. */
|
|
207
|
+
@property({ type: Boolean, reflect: true, attribute: 'no-padding' })
|
|
208
|
+
noPadding: boolean = false;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The label on the built-in Ask button.
|
|
212
|
+
*
|
|
213
|
+
* The button is the shell's, not the app's: it is the one control that has
|
|
214
|
+
* to know whether a panel is mounted for this route and how to open it, and
|
|
215
|
+
* slotted content can see neither. Everything else in the bar — the
|
|
216
|
+
* breadcrumb, the page actions, the tab strip — is slotted markup.
|
|
217
|
+
*/
|
|
218
|
+
@property({ type: String, attribute: 'ask-label' })
|
|
219
|
+
askLabel: string = 'Ask';
|
|
220
|
+
|
|
221
|
+
/** Drops the built-in Ask button, for a bar that renders its own. */
|
|
222
|
+
@property({ type: Boolean, reflect: true, attribute: 'no-ask' })
|
|
223
|
+
noAsk: boolean = false;
|
|
224
|
+
|
|
225
|
+
/** Sizes the shell to the viewport instead of its parent. */
|
|
226
|
+
@property({ type: Boolean, reflect: true, attribute: 'full-height' })
|
|
227
|
+
fullHeight: boolean = false;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Below this shell width the panel overlays the content instead of pushing
|
|
231
|
+
* it, and the nav is forced to a rail.
|
|
232
|
+
*
|
|
233
|
+
* Zero — the default — means never: the panel is furniture that squeezes the
|
|
234
|
+
* page, at every width. It earns its room from the nav rail first and from
|
|
235
|
+
* its own width next (see `--nile-app-shell-panel-min-width`), so it does
|
|
236
|
+
* not have to cover the page to fit. Set a width here to opt back into an
|
|
237
|
+
* overlay drawer below it.
|
|
238
|
+
*/
|
|
239
|
+
@property({ type: Number, attribute: 'overlay-breakpoint' })
|
|
240
|
+
overlayBreakpoint: number = 0;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Below this shell width an open docked panel forces the nav to a rail.
|
|
244
|
+
* A floor, not the whole rule: the nav also rails as soon as the expanded
|
|
245
|
+
* track is what stops the row from fitting. This is the first thing the
|
|
246
|
+
* panel takes room from, so it can push rather than cover.
|
|
247
|
+
*/
|
|
248
|
+
@property({ type: Number, attribute: 'docked-rail-breakpoint' })
|
|
249
|
+
dockedRailBreakpoint: number = 1440;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Persists the nav preference and the docked panel state under this key.
|
|
253
|
+
* Overlay panel state is never persisted — a reload opens closed.
|
|
254
|
+
*/
|
|
255
|
+
@property({ type: String, attribute: 'persist-key' })
|
|
256
|
+
persistKey?: string;
|
|
257
|
+
|
|
258
|
+
/** The panel's current mode. Derived from the shell's width. */
|
|
259
|
+
@state() private _panelMode: NileAppShellPanelMode = 'docked';
|
|
260
|
+
|
|
261
|
+
/** Whether the nav is held at a rail by the shell's width. */
|
|
262
|
+
@state() private _navLocked: boolean = false;
|
|
263
|
+
|
|
264
|
+
@state() private _hasBanner: boolean = false;
|
|
265
|
+
@state() private _hasSideNav: boolean = false;
|
|
266
|
+
@state() private _hasTopBar: boolean = false;
|
|
267
|
+
@state() private _hasTopBarActions: boolean = false;
|
|
268
|
+
@state() private _hasTabs: boolean = false;
|
|
269
|
+
@state() private _hasPanel: boolean = false;
|
|
270
|
+
@state() private _hasPanelFooter: boolean = false;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* True when a `nile-app-shell-panel` is slotted. That component owns the
|
|
274
|
+
* panel's heading, actions, close button and footer, so the shell renders a
|
|
275
|
+
* bare region and keeps only the geometry and the open state — the same
|
|
276
|
+
* hand-off as `no-nav-toggle` plus `nile-app-shell-nav-toggle`.
|
|
277
|
+
*/
|
|
278
|
+
@state() private _panelOwnsChrome: boolean = false;
|
|
279
|
+
@state() private _hasAside: boolean = false;
|
|
280
|
+
|
|
281
|
+
@query('.main') private _main?: HTMLElement;
|
|
282
|
+
|
|
283
|
+
private _width: number = 0;
|
|
284
|
+
private _resizeObserver?: ResizeObserver;
|
|
285
|
+
private _restoredPanelOpen: boolean | null = null;
|
|
286
|
+
|
|
287
|
+
/** The panel's current mode: `docked` or `overlay`. */
|
|
288
|
+
public get panelMode(): NileAppShellPanelMode {
|
|
289
|
+
return this._panelMode;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Whether the shell is holding the nav at a rail. The toggle is disabled. */
|
|
293
|
+
public get navLocked(): boolean {
|
|
294
|
+
return this._navLocked;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Whether a panel is mounted for this route. */
|
|
298
|
+
public get panelAvailable(): boolean {
|
|
299
|
+
return this._hasPanel && !this.noPanel;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Whether the built-in Ask button is rendered. */
|
|
303
|
+
public get askVisible(): boolean {
|
|
304
|
+
return this.panelAvailable && !this.noAsk;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Whether the nav renders as a rail right now, preference or lock. */
|
|
308
|
+
public get rail(): boolean {
|
|
309
|
+
return this.navCollapsed || this._navLocked;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public connectedCallback(): void {
|
|
313
|
+
super.connectedCallback();
|
|
314
|
+
this._restore();
|
|
315
|
+
this._resizeObserver = new ResizeObserver(entries => {
|
|
316
|
+
const entry = entries[entries.length - 1];
|
|
317
|
+
this._measure(entry.contentRect.width);
|
|
318
|
+
});
|
|
319
|
+
this._resizeObserver.observe(this);
|
|
320
|
+
document.addEventListener('keydown', this._onKeyDown);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
public disconnectedCallback(): void {
|
|
324
|
+
super.disconnectedCallback();
|
|
325
|
+
this._resizeObserver?.disconnect();
|
|
326
|
+
this._resizeObserver = undefined;
|
|
327
|
+
document.removeEventListener('keydown', this._onKeyDown);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
protected willUpdate(changed: PropertyValues<this>): void {
|
|
331
|
+
if (
|
|
332
|
+
changed.has('panelOpen') ||
|
|
333
|
+
changed.has('noPanel') ||
|
|
334
|
+
changed.has('overlayBreakpoint') ||
|
|
335
|
+
changed.has('dockedRailBreakpoint') ||
|
|
336
|
+
// Mounting an aside changes what a docked panel has to fit beside.
|
|
337
|
+
// Private state is outside `keyof this`, so ask the map directly.
|
|
338
|
+
(changed as Map<string, unknown>).has('_hasAside') ||
|
|
339
|
+
(changed as Map<string, unknown>).has('_hasSideNav')
|
|
340
|
+
) {
|
|
341
|
+
this._recompute();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
protected updated(changed: PropertyValues<this>): void {
|
|
346
|
+
super.updated(changed);
|
|
347
|
+
|
|
348
|
+
// Derived state the stylesheet and consumers read off the host.
|
|
349
|
+
this.toggleAttribute('rail', this.rail);
|
|
350
|
+
this.toggleAttribute('nav-locked', this._navLocked);
|
|
351
|
+
this.toggleAttribute('has-banner', this._hasBanner);
|
|
352
|
+
this.toggleAttribute('has-side-nav', this._hasSideNav);
|
|
353
|
+
this.toggleAttribute(
|
|
354
|
+
'has-top-bar',
|
|
355
|
+
this._hasTopBar || (!this.noNavToggle && this._hasSideNav)
|
|
356
|
+
);
|
|
357
|
+
this.toggleAttribute('has-top-bar-actions', this._hasTopBarActions);
|
|
358
|
+
this.toggleAttribute('has-ask', this.askVisible);
|
|
359
|
+
this.toggleAttribute('has-tabs', this._hasTabs);
|
|
360
|
+
this.toggleAttribute('has-aside', this._hasAside);
|
|
361
|
+
this.toggleAttribute('has-panel', this.panelAvailable);
|
|
362
|
+
this.toggleAttribute('has-panel-footer', this._hasPanelFooter);
|
|
363
|
+
this.setAttribute('panel-mode', this._panelMode);
|
|
364
|
+
this.setAttribute(
|
|
365
|
+
'panel-chrome',
|
|
366
|
+
this._panelOwnsChrome ? 'external' : 'internal'
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
this._syncSideNav();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** Open the AI panel. No-op when no panel is mounted for this route. */
|
|
373
|
+
public openPanel(): void {
|
|
374
|
+
if (!this.panelAvailable) return;
|
|
375
|
+
this._setPanelOpen(true);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** Close the AI panel. */
|
|
379
|
+
public closePanel(): void {
|
|
380
|
+
this._setPanelOpen(false);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Toggle the panel, or force a state. Call `openPanel()` from a page action —
|
|
385
|
+
* a page action that toggles closes the panel for a user who already had it
|
|
386
|
+
* open.
|
|
387
|
+
*/
|
|
388
|
+
public togglePanel(force?: boolean): void {
|
|
389
|
+
const next = force ?? !this.panelOpen;
|
|
390
|
+
if (next) this.openPanel();
|
|
391
|
+
else this.closePanel();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** Expand the side nav. */
|
|
395
|
+
public expandNav(): void {
|
|
396
|
+
this._setNavCollapsed(false);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Collapse the side nav to a rail. */
|
|
400
|
+
public collapseNav(): void {
|
|
401
|
+
this._setNavCollapsed(true);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** Toggle the side nav, or force a collapsed state. */
|
|
405
|
+
public toggleNav(force?: boolean): void {
|
|
406
|
+
this._setNavCollapsed(force ?? !this.navCollapsed);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Move focus to the page body. */
|
|
410
|
+
public focusMain(): void {
|
|
411
|
+
this._main?.focus();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private _setPanelOpen(value: boolean): void {
|
|
415
|
+
if (this.panelOpen === value) return;
|
|
416
|
+
this.panelOpen = value;
|
|
417
|
+
this._persist();
|
|
418
|
+
this.emit('nile-panel-toggle', { open: value, mode: this._panelMode });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private _setNavCollapsed(value: boolean): void {
|
|
422
|
+
if (this.navCollapsed === value) return;
|
|
423
|
+
this.navCollapsed = value;
|
|
424
|
+
this._persist();
|
|
425
|
+
this.emit('nile-nav-toggle', {
|
|
426
|
+
collapsed: value,
|
|
427
|
+
locked: this._navLocked,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** Records the shell's width and re-derives everything that depends on it. */
|
|
432
|
+
private _measure(width: number): void {
|
|
433
|
+
if (width === this._width) return;
|
|
434
|
+
const first = this._width === 0;
|
|
435
|
+
this._width = width;
|
|
436
|
+
this._recompute();
|
|
437
|
+
|
|
438
|
+
// A persisted panel state only applies once we know the panel would dock.
|
|
439
|
+
if (first && this._restoredPanelOpen !== null) {
|
|
440
|
+
const open = this._restoredPanelOpen;
|
|
441
|
+
this._restoredPanelOpen = null;
|
|
442
|
+
if (open && this._panelMode === 'docked') this.openPanel();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The shell's geometry, read off its own custom properties so a consumer's
|
|
448
|
+
* overrides are part of the sum. Falls back to the stylesheet's defaults
|
|
449
|
+
* before the element has a computed style.
|
|
450
|
+
*/
|
|
451
|
+
private _geometry(): ShellGeometry {
|
|
452
|
+
const style = getComputedStyle(this);
|
|
453
|
+
const px = (name: string, fallback: number): number => {
|
|
454
|
+
const value = parseFloat(style.getPropertyValue(name));
|
|
455
|
+
return Number.isFinite(value) ? value : fallback;
|
|
456
|
+
};
|
|
457
|
+
return {
|
|
458
|
+
nav: px('--nile-app-shell-side-nav-width', 260),
|
|
459
|
+
rail: px('--nile-app-shell-side-nav-rail-width', 64),
|
|
460
|
+
gutter: px('--nile-app-shell-gutter', 8),
|
|
461
|
+
content: px('--nile-app-shell-content-min-width', 640),
|
|
462
|
+
aside: px('--nile-app-shell-aside-width', 320),
|
|
463
|
+
panel: px('--nile-app-shell-panel-width', 480),
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* The shell width a docked panel needs to sit beside the content floor, over
|
|
469
|
+
* a side-nav `track` wide.
|
|
470
|
+
*
|
|
471
|
+
* A fixed breakpoint cannot answer this: what shares the row changes per
|
|
472
|
+
* route. An aside alone adds 328px, so a shell wide enough to hold the
|
|
473
|
+
* expanded nav beside a docked panel on one route is 328px short on the
|
|
474
|
+
* next. Summing what is actually mounted rails the nav exactly when the
|
|
475
|
+
* track is what the row cannot afford.
|
|
476
|
+
*/
|
|
477
|
+
private _dockRequirement(geo: ShellGeometry, track: number): number {
|
|
478
|
+
const nav = this._hasSideNav ? track : 0;
|
|
479
|
+
const aside = this._hasAside ? geo.aside + geo.gutter : 0;
|
|
480
|
+
// Two gutters of padding on the content column, one between container and
|
|
481
|
+
// panel; the aside carries its own gutter above.
|
|
482
|
+
return nav + geo.content + aside + geo.panel + geo.gutter * 3;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
private _recompute(): void {
|
|
486
|
+
const width = this._width;
|
|
487
|
+
const geo = this._geometry();
|
|
488
|
+
|
|
489
|
+
/*
|
|
490
|
+
* Overlay is opt-in and nothing derives it: a panel that covers the page
|
|
491
|
+
* hides the thing the user is asking about. Running out of room is not a
|
|
492
|
+
* reason to switch — the rail and the panel's own min width absorb that —
|
|
493
|
+
* so the shell only overlays below a width the author names.
|
|
494
|
+
*/
|
|
495
|
+
const overlay =
|
|
496
|
+
this.overlayBreakpoint > 0 && width > 0 && width < this.overlayBreakpoint;
|
|
497
|
+
const mode: NileAppShellPanelMode = overlay ? 'overlay' : 'docked';
|
|
498
|
+
|
|
499
|
+
// A docked panel squeezes the container, so a narrow shell trades the
|
|
500
|
+
// expanded nav for content width before the page gives any up. Measured
|
|
501
|
+
// against the expanded track: the nav rails exactly when it is the track
|
|
502
|
+
// that stops the row from fitting.
|
|
503
|
+
const railAt = Math.max(
|
|
504
|
+
this.dockedRailBreakpoint,
|
|
505
|
+
this._dockRequirement(geo, geo.nav)
|
|
506
|
+
);
|
|
507
|
+
const squeezed =
|
|
508
|
+
!overlay &&
|
|
509
|
+
this.panelOpen &&
|
|
510
|
+
this.panelAvailable &&
|
|
511
|
+
width > 0 &&
|
|
512
|
+
width < railAt;
|
|
513
|
+
const locked = overlay || squeezed;
|
|
514
|
+
|
|
515
|
+
if (mode !== this._panelMode) {
|
|
516
|
+
this._panelMode = mode;
|
|
517
|
+
this.emit('nile-panel-mode-change', { mode });
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (locked !== this._navLocked) {
|
|
521
|
+
this._navLocked = locked;
|
|
522
|
+
this.emit('nile-nav-toggle', {
|
|
523
|
+
collapsed: this.navCollapsed,
|
|
524
|
+
locked,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** Mirrors the effective rail state onto a slotted `nile-side-bar`. */
|
|
530
|
+
private _syncSideNav(): void {
|
|
531
|
+
this.querySelectorAll('[slot="side-nav"]').forEach(el => {
|
|
532
|
+
if (el.tagName === 'NILE-SIDE-BAR')
|
|
533
|
+
el.toggleAttribute('collapsed', this.rail);
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** A slotted sidebar's own expand button is the same toggle. */
|
|
538
|
+
private _onSideNavToggle = (event: Event): void => {
|
|
539
|
+
const detail = (event as CustomEvent).detail;
|
|
540
|
+
if (detail && typeof detail.collapsed === 'boolean') {
|
|
541
|
+
this._setNavCollapsed(detail.collapsed);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
private _onKeyDown = (event: KeyboardEvent): void => {
|
|
546
|
+
if (this.noPanelShortcut || !this.panelAvailable) return;
|
|
547
|
+
|
|
548
|
+
const key = event.key ?? '';
|
|
549
|
+
|
|
550
|
+
if ((event.metaKey || event.ctrlKey) && key.toLowerCase() === 'j') {
|
|
551
|
+
event.preventDefault();
|
|
552
|
+
this.togglePanel();
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// A docked panel is furniture, not a dismissible overlay.
|
|
557
|
+
if (key === 'Escape' && this.panelOpen && this._panelMode === 'overlay') {
|
|
558
|
+
this.closePanel();
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
private _storageKey(part: string): string {
|
|
563
|
+
return `nile-app-shell:${this.persistKey}:${part}`;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
private _restore(): void {
|
|
567
|
+
if (!this.persistKey) return;
|
|
568
|
+
try {
|
|
569
|
+
const nav = localStorage.getItem(this._storageKey('nav-collapsed'));
|
|
570
|
+
if (nav !== null) this.navCollapsed = nav === 'true';
|
|
571
|
+
const panel = localStorage.getItem(this._storageKey('panel-open'));
|
|
572
|
+
if (panel !== null) this._restoredPanelOpen = panel === 'true';
|
|
573
|
+
} catch {
|
|
574
|
+
/* Storage can be blocked; the shell still works without it. */
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
private _persist(): void {
|
|
579
|
+
if (!this.persistKey) return;
|
|
580
|
+
try {
|
|
581
|
+
localStorage.setItem(
|
|
582
|
+
this._storageKey('nav-collapsed'),
|
|
583
|
+
String(this.navCollapsed)
|
|
584
|
+
);
|
|
585
|
+
if (this._panelMode === 'docked') {
|
|
586
|
+
localStorage.setItem(
|
|
587
|
+
this._storageKey('panel-open'),
|
|
588
|
+
String(this.panelOpen)
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
} catch {
|
|
592
|
+
/* Storage can be blocked; the shell still works without it. */
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
private _onSlotChange(slot: string, event: Event): void {
|
|
597
|
+
const assigned = (event.target as HTMLSlotElement).assignedNodes({
|
|
598
|
+
flatten: true,
|
|
599
|
+
});
|
|
600
|
+
const filled = assigned.some(
|
|
601
|
+
node =>
|
|
602
|
+
node.nodeType === Node.ELEMENT_NODE ||
|
|
603
|
+
(node.textContent ?? '').trim() !== ''
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
switch (slot) {
|
|
607
|
+
case 'banner':
|
|
608
|
+
this._hasBanner = filled;
|
|
609
|
+
break;
|
|
610
|
+
case 'side-nav':
|
|
611
|
+
this._hasSideNav = filled;
|
|
612
|
+
this._syncSideNav();
|
|
613
|
+
break;
|
|
614
|
+
case 'top-bar':
|
|
615
|
+
this._hasTopBar = filled;
|
|
616
|
+
break;
|
|
617
|
+
case 'top-bar-actions':
|
|
618
|
+
this._hasTopBarActions = filled;
|
|
619
|
+
break;
|
|
620
|
+
case 'tabs':
|
|
621
|
+
this._hasTabs = filled;
|
|
622
|
+
break;
|
|
623
|
+
case 'aside':
|
|
624
|
+
this._hasAside = filled;
|
|
625
|
+
break;
|
|
626
|
+
case 'panel':
|
|
627
|
+
this._hasPanel = filled;
|
|
628
|
+
this._panelOwnsChrome = assigned.some(
|
|
629
|
+
node =>
|
|
630
|
+
node.nodeType === Node.ELEMENT_NODE &&
|
|
631
|
+
(node as Element).tagName === 'NILE-APP-SHELL-PANEL'
|
|
632
|
+
);
|
|
633
|
+
this._recompute();
|
|
634
|
+
break;
|
|
635
|
+
case 'panel-footer':
|
|
636
|
+
this._hasPanelFooter = filled;
|
|
637
|
+
break;
|
|
638
|
+
default:
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
private _renderNavToggle(): TemplateResult | string {
|
|
644
|
+
if (this.noNavToggle || !this._hasSideNav) return '';
|
|
645
|
+
const expanded = !this.rail;
|
|
646
|
+
return html`
|
|
647
|
+
<div class="nav-toggle-group">
|
|
648
|
+
<nile-button
|
|
649
|
+
class="nav-toggle"
|
|
650
|
+
part="nav-toggle"
|
|
651
|
+
variant="ghost"
|
|
652
|
+
circle
|
|
653
|
+
aria-controls="side-nav"
|
|
654
|
+
aria-expanded=${expanded ? 'true' : 'false'}
|
|
655
|
+
?disabled=${this._navLocked}
|
|
656
|
+
title=${this._navLocked
|
|
657
|
+
? 'The navigation stays collapsed at this window width'
|
|
658
|
+
: expanded
|
|
659
|
+
? 'Collapse navigation'
|
|
660
|
+
: 'Expand navigation'}
|
|
661
|
+
aria-label=${expanded ? 'Collapse navigation' : 'Expand navigation'}
|
|
662
|
+
@click=${() => this.toggleNav()}
|
|
663
|
+
>
|
|
664
|
+
${renderGlyph(
|
|
665
|
+
expanded ? 'ng-panel-left-close' : 'ng-panel-left-open',
|
|
666
|
+
24,
|
|
667
|
+
'currentColor'
|
|
668
|
+
)}
|
|
669
|
+
</nile-button>
|
|
670
|
+
${this._hasTopBar ? html`<span class="rule" part="rule"></span>` : ''}
|
|
671
|
+
</div>
|
|
672
|
+
`;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
private _renderTopBar(
|
|
676
|
+
placement: NileAppShellTopBarPlacement
|
|
677
|
+
): TemplateResult {
|
|
678
|
+
return html`
|
|
679
|
+
<div
|
|
680
|
+
class=${placement === 'shell' ? 'top-bar shell-top-bar' : 'top-bar'}
|
|
681
|
+
part=${placement === 'shell' ? 'top-bar shell-top-bar' : 'top-bar'}
|
|
682
|
+
>
|
|
683
|
+
${this._renderNavToggle()}
|
|
684
|
+
<div class="top-bar-content">
|
|
685
|
+
<slot
|
|
686
|
+
name="top-bar"
|
|
687
|
+
@slotchange=${(e: Event) => this._onSlotChange('top-bar', e)}
|
|
688
|
+
></slot>
|
|
689
|
+
</div>
|
|
690
|
+
<div class="top-bar-actions" part="top-bar-actions">
|
|
691
|
+
<slot
|
|
692
|
+
name="top-bar-actions"
|
|
693
|
+
@slotchange=${(e: Event) =>
|
|
694
|
+
this._onSlotChange('top-bar-actions', e)}
|
|
695
|
+
></slot>
|
|
696
|
+
${this.askVisible
|
|
697
|
+
? html`
|
|
698
|
+
<nile-button
|
|
699
|
+
class="ask"
|
|
700
|
+
part="ask"
|
|
701
|
+
exportparts="base: ask__base, label: ask__label"
|
|
702
|
+
variant="primary"
|
|
703
|
+
@click=${() => this.openPanel()}
|
|
704
|
+
>
|
|
705
|
+
<span slot="prefix" class="ask-mark">
|
|
706
|
+
${renderGlyph('ng-sparkles', 16, 'currentColor')}
|
|
707
|
+
</span>
|
|
708
|
+
${this.askLabel}
|
|
709
|
+
</nile-button>
|
|
710
|
+
`
|
|
711
|
+
: ''}
|
|
712
|
+
</div>
|
|
713
|
+
</div>
|
|
714
|
+
`;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
public render(): TemplateResult {
|
|
718
|
+
const shellBar = this.topBarPlacement === 'shell';
|
|
719
|
+
|
|
720
|
+
return html`
|
|
721
|
+
<button
|
|
722
|
+
class="skip-link"
|
|
723
|
+
part="skip-link"
|
|
724
|
+
type="button"
|
|
725
|
+
@click=${() => this.focusMain()}
|
|
726
|
+
>
|
|
727
|
+
${this.skipLinkLabel}
|
|
728
|
+
</button>
|
|
729
|
+
|
|
730
|
+
<div class="banner" part="banner">
|
|
731
|
+
<slot
|
|
732
|
+
name="banner"
|
|
733
|
+
@slotchange=${(e: Event) => this._onSlotChange('banner', e)}
|
|
734
|
+
></slot>
|
|
735
|
+
</div>
|
|
736
|
+
|
|
737
|
+
${shellBar ? this._renderTopBar('shell') : ''}
|
|
738
|
+
|
|
739
|
+
<div
|
|
740
|
+
id="side-nav"
|
|
741
|
+
class="side-nav"
|
|
742
|
+
part="side-nav"
|
|
743
|
+
@nile-toggle=${this._onSideNavToggle}
|
|
744
|
+
>
|
|
745
|
+
<slot
|
|
746
|
+
name="side-nav"
|
|
747
|
+
@slotchange=${(e: Event) => this._onSlotChange('side-nav', e)}
|
|
748
|
+
></slot>
|
|
749
|
+
</div>
|
|
750
|
+
|
|
751
|
+
<div class="content-section" part="content-section">
|
|
752
|
+
<div class="container" part="container">
|
|
753
|
+
${shellBar ? '' : this._renderTopBar('content')}
|
|
754
|
+
<div class="tabs" part="tabs">
|
|
755
|
+
<slot
|
|
756
|
+
name="tabs"
|
|
757
|
+
@slotchange=${(e: Event) => this._onSlotChange('tabs', e)}
|
|
758
|
+
></slot>
|
|
759
|
+
</div>
|
|
760
|
+
<main class="main" part="main" tabindex="-1">
|
|
761
|
+
<div class="main-inner"><slot></slot></div>
|
|
762
|
+
</main>
|
|
763
|
+
</div>
|
|
764
|
+
|
|
765
|
+
<div class="aside" part="aside">
|
|
766
|
+
<slot
|
|
767
|
+
name="aside"
|
|
768
|
+
@slotchange=${(e: Event) => this._onSlotChange('aside', e)}
|
|
769
|
+
></slot>
|
|
770
|
+
</div>
|
|
771
|
+
|
|
772
|
+
<aside
|
|
773
|
+
class="panel"
|
|
774
|
+
part="panel"
|
|
775
|
+
aria-label=${ifDefined(
|
|
776
|
+
this._panelOwnsChrome ? undefined : this.panelLabel
|
|
777
|
+
)}
|
|
778
|
+
aria-hidden=${this.panelOpen ? 'false' : 'true'}
|
|
779
|
+
>
|
|
780
|
+
${this._panelOwnsChrome
|
|
781
|
+
? html`<slot
|
|
782
|
+
name="panel"
|
|
783
|
+
@slotchange=${(e: Event) => this._onSlotChange('panel', e)}
|
|
784
|
+
></slot>`
|
|
785
|
+
: html`
|
|
786
|
+
<header class="panel-header" part="panel-header">
|
|
787
|
+
<slot name="panel-header">
|
|
788
|
+
<span class="panel-heading">
|
|
789
|
+
<span class="panel-mark">
|
|
790
|
+
${renderGlyph('ng-sparkles', 20, 'currentColor')}
|
|
791
|
+
</span>
|
|
792
|
+
<h2 class="panel-title" part="panel-title">
|
|
793
|
+
${this.panelLabel}
|
|
794
|
+
</h2>
|
|
795
|
+
</span>
|
|
796
|
+
</slot>
|
|
797
|
+
<div class="panel-actions" part="panel-actions">
|
|
798
|
+
<slot name="panel-actions"></slot>
|
|
799
|
+
<nile-button
|
|
800
|
+
class="panel-close"
|
|
801
|
+
part="panel-close"
|
|
802
|
+
variant="ghost"
|
|
803
|
+
circle
|
|
804
|
+
title="Close ${this.panelLabel}"
|
|
805
|
+
aria-label="Close ${this.panelLabel}"
|
|
806
|
+
@click=${() => this.closePanel()}
|
|
807
|
+
>
|
|
808
|
+
${renderGlyph('ng-x-close', 24, 'currentColor')}
|
|
809
|
+
</nile-button>
|
|
810
|
+
</div>
|
|
811
|
+
</header>
|
|
812
|
+
<div class="panel-body" part="panel-body">
|
|
813
|
+
<slot
|
|
814
|
+
name="panel"
|
|
815
|
+
@slotchange=${(e: Event) => this._onSlotChange('panel', e)}
|
|
816
|
+
></slot>
|
|
817
|
+
</div>
|
|
818
|
+
<div class="panel-footer" part="panel-footer">
|
|
819
|
+
<slot
|
|
820
|
+
name="panel-footer"
|
|
821
|
+
@slotchange=${(e: Event) =>
|
|
822
|
+
this._onSlotChange('panel-footer', e)}
|
|
823
|
+
></slot>
|
|
824
|
+
</div>
|
|
825
|
+
`}
|
|
826
|
+
</aside>
|
|
827
|
+
</div>
|
|
828
|
+
`;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
export default NileAppShell;
|
|
833
|
+
|
|
834
|
+
declare global {
|
|
835
|
+
interface HTMLElementTagNameMap {
|
|
836
|
+
'nile-app-shell': NileAppShell;
|
|
837
|
+
}
|
|
838
|
+
}
|