UNPKG

11.1 kBTypeScriptView Raw
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 */
6import { AfterViewInit, ElementRef, OnDestroy, Renderer2, ViewContainerRef } from '@angular/core';
7import { BehaviorSubject } from 'rxjs';
8import { NbBooleanInput } from '../helpers';
9import { NbThemeService } from '../../services/theme.service';
10import { NbSpinnerService } from '../../services/spinner.service';
11import { NbLayoutDirectionService } from '../../services/direction.service';
12import { NbRestoreScrollTopHelper } from './restore-scroll-top.service';
13import { NbScrollPosition, NbLayoutScrollService } from '../../services/scroll.service';
14import { NbLayoutDimensions, NbLayoutRulerService } from '../../services/ruler.service';
15import { NbOverlayContainerAdapter } from '../cdk/adapter/overlay-container-adapter';
16/**
17 * Layout container component.
18 * When using with Nebular Theme System it is required that all child components should be placed inside.
19 *
20 * Basic example of two column layout with header:
21 *
22 * @stacked-example(Showcase, layout/layout-showcase.component)
23 *
24 * Can contain the following components inside:
25 *
26 * ```html
27 * <nb-layout>
28 * <nb-layout-header></nb-layout-header>
29 * <nb-layout-footer></nb-layout-footer>
30 * <nb-layout-column></nb-layout-column>
31 * <nb-sidebar></nb-sidebar>
32 * </nb-layout>
33 * ```
34 * ### Installation
35 *
36 * Import `NbLayoutModule` to your app module.
37 * ```ts
38 * @NgModule({
39 * imports: [
40 * // ...
41 * NbLayoutModule,
42 * ],
43 * })
44 * export class AppModule { }
45 * ```
46 * ### Usage
47 * By default the layout fills up the whole view-port.
48 * The window scrollbars are disabled on the body and moved inside of the nb-layout, so that the scrollbars
49 * won't mess with the fixed nb-header.
50 *
51 * The child components are projected into a flexible layout structure allowing to adjust the layout behavior
52 * based on the settings provided.
53 *
54 * The layout content (columns) becomes centered when the window width is more than
55 * the value specified in the theme variable `layout-content-width`.
56 *
57 * The layout also contains the area on the very top (the first child of the nb-layout), which could be used
58 * to dynamically append some components like modals or spinners/loaders
59 * so that they are located on top of the elements hierarchy.
60 * More details are under the `ThemeService` section.
61 *
62 * The layout component is also responsible for changing application themes.
63 * It listens to the `themeChange` event and change a theme CSS class appended to body.
64 * Based on the class appended, specific CSS-theme is applied to the application.
65 * More details of the Theme System could be found here [Enabling Theme System](#/docs/concepts/theme-system)
66 *
67 * A simple layout with footer:
68 *
69 * @stacked-example(Layout With Footer, layout/layout-w-footer.component)
70 *
71 * It is possible to ask the layout to center the columns (notice: we added a `center` attribute
72 * to the layout:
73 *
74 * ```html
75 * <nb-layout center>
76 * <nb-layout-header>Awesome Company</nb-layout-header>
77 *
78 * <nb-layout-column>
79 * Hello World!
80 * </nb-layout-column>
81 *
82 * <nb-layout-footer>Contact us</nb-layout-footer>
83 * </nb-layout>
84 * ```
85 *
86 * @styles
87 *
88 * layout-background-color:
89 * layout-text-color:
90 * layout-text-font-family:
91 * layout-text-font-size:
92 * layout-text-font-weight:
93 * layout-text-line-height:
94 * layout-min-height:
95 * layout-content-width:
96 * layout-window-mode-min-width:
97 * layout-window-mode-max-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 */
108export 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}
194/**
195 * A container component which determines a content position inside of the layout.
196 * The layout could contain unlimited columns (not including the sidebars).
197 *
198 * By default the columns are ordered from the left to the right,
199 * but it's also possible to overwrite this behavior by setting a `left` attribute to the column,
200 * moving it to the very first position:
201 *
202 * @stacked-example(Column Left, layout/layout-column-left.component)
203 */
204export declare class NbLayoutColumnComponent {
205 leftValue: boolean;
206 startValue: boolean;
207 /**
208 * Move the column to the very left position in the layout.
209 * @param {boolean} val
210 */
211 set left(val: boolean);
212 static ngAcceptInputType_left: NbBooleanInput;
213 /**
214 * Make column first in the layout.
215 * @param {boolean} val
216 */
217 set start(val: boolean);
218 static ngAcceptInputType_start: NbBooleanInput;
219}
220/**
221 * Page header component.
222 * Located on top of the page above the layout columns and sidebars.
223 * Could be made `fixed` by setting the corresponding property. In the fixed mode the header becomes
224 * sticky to the top of the nb-layout (to of the page). Here's an example:
225 *
226 * @stacked-example(Fixed Header, layout/layout-fixed-header.component)
227 *
228 * In a pair with sidebar it is possible to setup a configuration when header is placed on a side of the sidebar
229 * and not on top of it. To achieve this simply put a `subheader` property to the header like this:
230 * ```html
231 * <nb-layout-header subheader></nb-layout-header>
232 * ```
233 * @stacked-example(Subheader, layout/layout-sidebar-subheader.component)
234 * Note that in such configuration sidebar shadow is removed and header cannot be make `fixed`.
235 *
236 * Same way you can put both `fixed` and `clipped` headers adding creating a sub-header for your app:
237 *
238 * @stacked-example(Subheader, layout/layout-subheader.component)
239 *
240 * @styles
241 *
242 * header-background-color:
243 * header-text-color:
244 * header-text-font-family:
245 * header-text-font-size:
246 * header-text-font-weight:
247 * header-text-line-height:
248 * header-height:
249 * header-padding:
250 * header-shadow:
251 */
252export declare class NbLayoutHeaderComponent {
253 private layout;
254 fixedValue: boolean;
255 subheaderValue: boolean;
256 constructor(layout: NbLayoutComponent);
257 /**
258 * Makes the header sticky to the top of the nb-layout.
259 * @param {boolean} val
260 */
261 set fixed(val: boolean);
262 static ngAcceptInputType_fixed: NbBooleanInput;
263 /**
264 * Places header on a side of the sidebar, and not above.
265 * Disables fixed mode for this header and remove a shadow from the sidebar.
266 * @param {boolean} val
267 */
268 set subheader(val: boolean);
269 static ngAcceptInputType_subheader: NbBooleanInput;
270}
271/**
272 * Page footer.
273 * Located under the nb-layout content (specifically, under the columns).
274 * Could be made `fixed`, becoming sticky to the bottom of the view port (window).
275 *
276 * @styles
277 *
278 * footer-background-color:
279 * footer-text-color:
280 * footer-text-font-family:
281 * footer-text-font-size:
282 * footer-text-font-weight:
283 * footer-text-line-height:
284 * footer-text-highlight-color:
285 * footer-height:
286 * footer-padding:
287 * footer-divider-color:
288 * footer-divider-style:
289 * footer-divider-width:
290 * footer-shadow:
291 */
292export declare class NbLayoutFooterComponent {
293 fixedValue: boolean;
294 /**
295 * Makes the footer sticky to the bottom of the window.
296 * @param {boolean} val
297 */
298 set fixed(val: boolean);
299 static ngAcceptInputType_fixed: NbBooleanInput;
300}