1 | /**
|
2 | * @license
|
3 | * Copyright Akveo. All Rights Reserved.
|
4 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
5 | */
|
6 | import { AfterViewInit, ElementRef, OnDestroy, Renderer2, ViewContainerRef } from '@angular/core';
|
7 | import { BehaviorSubject } from 'rxjs';
|
8 | import { NbBooleanInput } from '../helpers';
|
9 | import { NbThemeService } from '../../services/theme.service';
|
10 | import { NbSpinnerService } from '../../services/spinner.service';
|
11 | import { NbLayoutDirectionService } from '../../services/direction.service';
|
12 | import { NbRestoreScrollTopHelper } from './restore-scroll-top.service';
|
13 | import { NbScrollPosition, NbLayoutScrollService } from '../../services/scroll.service';
|
14 | import { NbLayoutDimensions, NbLayoutRulerService } from '../../services/ruler.service';
|
15 | import { NbOverlayContainerAdapter } from '../cdk/adapter/overlay-container-adapter';
|
16 | import * as i0 from "@angular/core";
|
17 | /**
|
18 | * Layout container component.
|
19 | * When using with Nebular Theme System it is required that all child components should be placed inside.
|
20 | *
|
21 | * Basic example of two column layout with header:
|
22 | *
|
23 | * @stacked-example(Showcase, layout/layout-showcase.component)
|
24 | *
|
25 | * Can contain the following components inside:
|
26 | *
|
27 | * ```html
|
28 | * <nb-layout>
|
29 | * <nb-layout-header></nb-layout-header>
|
30 | * <nb-layout-footer></nb-layout-footer>
|
31 | * <nb-layout-column></nb-layout-column>
|
32 | * <nb-sidebar></nb-sidebar>
|
33 | * </nb-layout>
|
34 | * ```
|
35 | * ### Installation
|
36 | *
|
37 | * Import `NbLayoutModule` to your app module.
|
38 | * ```ts
|
39 | * @NgModule({
|
40 | * imports: [
|
41 | * // ...
|
42 | * NbLayoutModule,
|
43 | * ],
|
44 | * })
|
45 | * export class AppModule { }
|
46 | * ```
|
47 | * ### Usage
|
48 | * By default the layout fills up the whole view-port.
|
49 | * The window scrollbars are disabled on the body and moved inside of the nb-layout, so that the scrollbars
|
50 | * won't mess with the fixed nb-header.
|
51 | *
|
52 | * The child components are projected into a flexible layout structure allowing to adjust the layout behavior
|
53 | * based on the settings provided.
|
54 | *
|
55 | * The layout content (columns) becomes centered when the window width is more than
|
56 | * the value specified in the theme variable `layout-content-width`.
|
57 | *
|
58 | * The layout also contains the area on the very top (the first child of the nb-layout), which could be used
|
59 | * to dynamically append some components like modals or spinners/loaders
|
60 | * so that they are located on top of the elements hierarchy.
|
61 | * More details are under the `ThemeService` section.
|
62 | *
|
63 | * The layout component is also responsible for changing application themes.
|
64 | * It listens to the `themeChange` event and change a theme CSS class appended to body.
|
65 | * Based on the class appended, specific CSS-theme is applied to the application.
|
66 | * More details of the Theme System could be found here [Enabling Theme System](#/docs/concepts/theme-system)
|
67 | *
|
68 | * A simple layout with footer:
|
69 | *
|
70 | * @stacked-example(Layout With Footer, layout/layout-w-footer.component)
|
71 | *
|
72 | * It is possible to ask the layout to center the columns (notice: we added a `center` attribute
|
73 | * to the layout:
|
74 | *
|
75 | * ```html
|
76 | * <nb-layout center>
|
77 | * <nb-layout-header>Awesome Company</nb-layout-header>
|
78 | *
|
79 | * <nb-layout-column>
|
80 | * Hello World!
|
81 | * </nb-layout-column>
|
82 | *
|
83 | * <nb-layout-footer>Contact us</nb-layout-footer>
|
84 | * </nb-layout>
|
85 | * ```
|
86 | *
|
87 | * @styles
|
88 | *
|
89 | * layout-background-color:
|
90 | * layout-text-color:
|
91 | * layout-text-font-family:
|
92 | * layout-text-font-size:
|
93 | * layout-text-font-weight:
|
94 | * layout-text-line-height:
|
95 | * layout-min-height:
|
96 | * layout-content-width:
|
97 | * layout-window-mode-min-width:
|
98 | * layout-window-mode-background-color:
|
99 | * layout-window-mode-padding-top:
|
100 | * layout-window-shadow:
|
101 | * layout-padding:
|
102 | * layout-medium-padding:
|
103 | * layout-small-padding:
|
104 | * layout-scrollbar-background-color:
|
105 | * layout-scrollbar-color:
|
106 | * layout-scrollbar-width:
|
107 | */
|
108 | export declare class NbLayoutComponent implements AfterViewInit, OnDestroy {
|
109 | protected themeService: NbThemeService;
|
110 | protected spinnerService: NbSpinnerService;
|
111 | protected elementRef: ElementRef;
|
112 | protected renderer: Renderer2;
|
113 | protected window: any;
|
114 | protected document: any;
|
115 | protected platformId: Object;
|
116 | protected layoutDirectionService: NbLayoutDirectionService;
|
117 | protected scrollService: NbLayoutScrollService;
|
118 | protected rulerService: NbLayoutRulerService;
|
119 | protected scrollTop: NbRestoreScrollTopHelper;
|
120 | protected overlayContainer: NbOverlayContainerAdapter;
|
121 | protected scrollBlockClass: string;
|
122 | protected isScrollBlocked: boolean;
|
123 | protected scrollableContainerOverflowOldValue: string;
|
124 | protected layoutPaddingOldValue: {
|
125 | left: string;
|
126 | right: string;
|
127 | };
|
128 | centerValue: boolean;
|
129 | restoreScrollTopValue: boolean;
|
130 | windowModeValue: boolean;
|
131 | withScrollValue: boolean;
|
132 | withSubheader: boolean;
|
133 | /**
|
134 | * Defines whether the layout columns will be centered after some width
|
135 | * @param {boolean} val
|
136 | */
|
137 | set center(val: boolean);
|
138 | static ngAcceptInputType_center: NbBooleanInput;
|
139 | /**
|
140 | * Defines whether the layout enters a 'window' mode, when the layout content (including sidebars and fixed header)
|
141 | * becomes centered by width with a margin from the top of the screen, like a floating window.
|
142 | * Automatically enables `withScroll` mode, as in the window mode scroll must be inside the layout and cannot be on
|
143 | * window. (TODO: check this)
|
144 | * @param {boolean} val
|
145 | */
|
146 | set windowMode(val: boolean);
|
147 | static ngAcceptInputType_windowMode: NbBooleanInput;
|
148 | /**
|
149 | * Defines whether to move the scrollbars to layout or leave it at the body level.
|
150 | * Automatically set to true when `windowMode` is enabled.
|
151 | * @param {boolean} val
|
152 | */
|
153 | set withScroll(val: boolean);
|
154 | static ngAcceptInputType_withScroll: NbBooleanInput;
|
155 | /**
|
156 | * Restores scroll to the top of the page after navigation
|
157 | * @param {boolean} val
|
158 | */
|
159 | set restoreScrollTop(val: boolean);
|
160 | static ngAcceptInputType_restoreScrollTop: NbBooleanInput;
|
161 | veryTopRef: ViewContainerRef;
|
162 | scrollableContainerRef: ElementRef<HTMLElement>;
|
163 | layoutContainerRef: ElementRef<HTMLElement>;
|
164 | protected afterViewInit$: BehaviorSubject<any>;
|
165 | private destroy$;
|
166 | constructor(themeService: NbThemeService, spinnerService: NbSpinnerService, elementRef: ElementRef, renderer: Renderer2, window: any, document: any, platformId: Object, layoutDirectionService: NbLayoutDirectionService, scrollService: NbLayoutScrollService, rulerService: NbLayoutRulerService, scrollTop: NbRestoreScrollTopHelper, overlayContainer: NbOverlayContainerAdapter);
|
167 | ngAfterViewInit(): void;
|
168 | ngOnDestroy(): void;
|
169 | onScroll($event: any): void;
|
170 | onResize(event: any): void;
|
171 | /**
|
172 | * Returns scroll and client height/width
|
173 | *
|
174 | * Depending on the current scroll mode (`withScroll=true`) returns sizes from the body element
|
175 | * or from the `.scrollable-container`
|
176 | * @returns {NbLayoutDimensions}
|
177 | */
|
178 | getDimensions(): NbLayoutDimensions;
|
179 | /**
|
180 | * Returns scroll position of current scroll container.
|
181 | *
|
182 | * If `withScroll` = true, returns scroll position of the `.scrollable-container` element,
|
183 | * otherwise - of the scrollable element of the window (which may be different depending of a browser)
|
184 | *
|
185 | * @returns {NbScrollPosition}
|
186 | */
|
187 | getScrollPosition(): NbScrollPosition;
|
188 | protected registerAsOverlayContainer(): void;
|
189 | protected unregisterAsOverlayContainer(): void;
|
190 | private scroll;
|
191 | protected blockScroll(): void;
|
192 | private enableScroll;
|
193 | static ɵfac: i0.ɵɵFactoryDeclaration<NbLayoutComponent, never>;
|
194 | static ɵcmp: i0.ɵɵComponentDeclaration<NbLayoutComponent, "nb-layout", never, { "center": { "alias": "center"; "required": false; }; "windowMode": { "alias": "windowMode"; "required": false; }; "withScroll": { "alias": "withScroll"; "required": false; }; "restoreScrollTop": { "alias": "restoreScrollTop"; "required": false; }; }, {}, never, ["nb-layout-header:not([subheader])", "nb-sidebar", "nb-layout-header[subheader]", "nb-layout-column", "nb-layout-footer"], false, never>;
|
195 | }
|
196 | /**
|
197 | * A container component which determines a content position inside of the layout.
|
198 | * The layout could contain unlimited columns (not including the sidebars).
|
199 | *
|
200 | * By default the columns are ordered from the left to the right,
|
201 | * but it's also possible to overwrite this behavior by setting a `left` attribute to the column,
|
202 | * moving it to the very first position:
|
203 | *
|
204 | * @stacked-example(Column Left, layout/layout-column-left.component)
|
205 | */
|
206 | export declare class NbLayoutColumnComponent {
|
207 | leftValue: boolean;
|
208 | startValue: boolean;
|
209 | /**
|
210 | * Move the column to the very left position in the layout.
|
211 | * @param {boolean} val
|
212 | */
|
213 | set left(val: boolean);
|
214 | static ngAcceptInputType_left: NbBooleanInput;
|
215 | /**
|
216 | * Make column first in the layout.
|
217 | * @param {boolean} val
|
218 | */
|
219 | set start(val: boolean);
|
220 | static ngAcceptInputType_start: NbBooleanInput;
|
221 | static ɵfac: i0.ɵɵFactoryDeclaration<NbLayoutColumnComponent, never>;
|
222 | static ɵcmp: i0.ɵɵComponentDeclaration<NbLayoutColumnComponent, "nb-layout-column", never, { "left": { "alias": "left"; "required": false; }; "start": { "alias": "start"; "required": false; }; }, {}, never, ["*"], false, never>;
|
223 | }
|
224 | /**
|
225 | * Page header component.
|
226 | * Located on top of the page above the layout columns and sidebars.
|
227 | * Could be made `fixed` by setting the corresponding property. In the fixed mode the header becomes
|
228 | * sticky to the top of the nb-layout (to of the page). Here's an example:
|
229 | *
|
230 | * @stacked-example(Fixed Header, layout/layout-fixed-header.component)
|
231 | *
|
232 | * In a pair with sidebar it is possible to setup a configuration when header is placed on a side of the sidebar
|
233 | * and not on top of it. To achieve this simply put a `subheader` property to the header like this:
|
234 | * ```html
|
235 | * <nb-layout-header subheader></nb-layout-header>
|
236 | * ```
|
237 | * @stacked-example(Subheader, layout/layout-sidebar-subheader.component)
|
238 | * Note that in such configuration sidebar shadow is removed and header cannot be make `fixed`.
|
239 | *
|
240 | * Same way you can put both `fixed` and `clipped` headers adding creating a sub-header for your app:
|
241 | *
|
242 | * @stacked-example(Subheader, layout/layout-subheader.component)
|
243 | *
|
244 | * @styles
|
245 | *
|
246 | * header-background-color:
|
247 | * header-text-color:
|
248 | * header-text-font-family:
|
249 | * header-text-font-size:
|
250 | * header-text-font-weight:
|
251 | * header-text-line-height:
|
252 | * header-height:
|
253 | * header-padding:
|
254 | * header-shadow:
|
255 | */
|
256 | export declare class NbLayoutHeaderComponent {
|
257 | private layout;
|
258 | fixedValue: boolean;
|
259 | subheaderValue: boolean;
|
260 | constructor(layout: NbLayoutComponent);
|
261 | /**
|
262 | * Makes the header sticky to the top of the nb-layout.
|
263 | * @param {boolean} val
|
264 | */
|
265 | set fixed(val: boolean);
|
266 | static ngAcceptInputType_fixed: NbBooleanInput;
|
267 | /**
|
268 | * Places header on a side of the sidebar, and not above.
|
269 | * Disables fixed mode for this header and remove a shadow from the sidebar.
|
270 | * @param {boolean} val
|
271 | */
|
272 | set subheader(val: boolean);
|
273 | static ngAcceptInputType_subheader: NbBooleanInput;
|
274 | static ɵfac: i0.ɵɵFactoryDeclaration<NbLayoutHeaderComponent, never>;
|
275 | static ɵcmp: i0.ɵɵComponentDeclaration<NbLayoutHeaderComponent, "nb-layout-header", never, { "fixed": { "alias": "fixed"; "required": false; }; "subheader": { "alias": "subheader"; "required": false; }; }, {}, never, ["*"], false, never>;
|
276 | }
|
277 | /**
|
278 | * Page footer.
|
279 | * Located under the nb-layout content (specifically, under the columns).
|
280 | * Could be made `fixed`, becoming sticky to the bottom of the view port (window).
|
281 | *
|
282 | * @styles
|
283 | *
|
284 | * footer-background-color:
|
285 | * footer-text-color:
|
286 | * footer-text-font-family:
|
287 | * footer-text-font-size:
|
288 | * footer-text-font-weight:
|
289 | * footer-text-line-height:
|
290 | * footer-text-highlight-color:
|
291 | * footer-height:
|
292 | * footer-padding:
|
293 | * footer-divider-color:
|
294 | * footer-divider-style:
|
295 | * footer-divider-width:
|
296 | * footer-shadow:
|
297 | */
|
298 | export declare class NbLayoutFooterComponent {
|
299 | fixedValue: boolean;
|
300 | /**
|
301 | * Makes the footer sticky to the bottom of the window.
|
302 | * @param {boolean} val
|
303 | */
|
304 | set fixed(val: boolean);
|
305 | static ngAcceptInputType_fixed: NbBooleanInput;
|
306 | static ɵfac: i0.ɵɵFactoryDeclaration<NbLayoutFooterComponent, never>;
|
307 | static ɵcmp: i0.ɵɵComponentDeclaration<NbLayoutFooterComponent, "nb-layout-footer", never, { "fixed": { "alias": "fixed"; "required": false; }; }, {}, never, ["*"], false, never>;
|
308 | }
|