UNPKG

8.78 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 { ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, OnInit } from '@angular/core';
7import { Subject } from 'rxjs';
8import { NbBooleanInput } from '../helpers';
9import { NbThemeService } from '../../services/theme.service';
10import { NbSidebarService } from './sidebar.service';
11import * as i0 from "@angular/core";
12export type NbSidebarState = 'expanded' | 'collapsed' | 'compacted';
13export type NbSidebarResponsiveState = 'mobile' | 'tablet' | 'pc';
14/**
15 * Sidebar header container.
16 *
17 * Placeholder which contains a sidebar header content,
18 * placed at the very top of the sidebar outside of the scroll area.
19 */
20export declare class NbSidebarHeaderComponent {
21 static ɵfac: i0.ɵɵFactoryDeclaration<NbSidebarHeaderComponent, never>;
22 static ɵcmp: i0.ɵɵComponentDeclaration<NbSidebarHeaderComponent, "nb-sidebar-header", never, {}, {}, never, ["*"], false, never>;
23}
24/**
25 * Sidebar footer container.
26 *
27 * Placeholder which contains a sidebar footer content,
28 * placed at the very bottom of the sidebar outside of the scroll area.
29 */
30export declare class NbSidebarFooterComponent {
31 static ɵfac: i0.ɵɵFactoryDeclaration<NbSidebarFooterComponent, never>;
32 static ɵcmp: i0.ɵɵComponentDeclaration<NbSidebarFooterComponent, "nb-sidebar-footer", never, {}, {}, never, ["*"], false, never>;
33}
34/**
35 * Layout sidebar component.
36 *
37 * @stacked-example(Showcase, sidebar/sidebar-showcase.component)
38 *
39 * ### Installation
40 *
41 * Import `NbSidebarModule.forRoot()` to your app module.
42 * ```ts
43 * @NgModule({
44 * imports: [
45 * // ...
46 * NbSidebarModule.forRoot(),
47 * ],
48 * })
49 * export class AppModule { }
50 * ```
51 * and `NbSidebarModule` to your feature module where the component should be shown:
52 * ```ts
53 * @NgModule({
54 * imports: [
55 * // ...
56 * NbSidebarModule,
57 * ],
58 * })
59 * export class PageModule { }
60 * ```
61 * ### Usage
62 *
63 * Sidebar can be placed on the left or the right side of the layout,
64 * or on start/end position of layout (depends on document direction, left to right or right to left)
65 * It can be fixed (shown above the content) or can push the layout when opened.
66 *
67 * There are three states - `expanded`, `collapsed`, `compacted`.
68 * By default sidebar content is fixed and saves its position while the page is being scrolled.
69 *
70 * Compacted sidebar example:
71 * @stacked-example(Compacted Sidebar, sidebar/sidebar-compacted.component)
72 *
73 * Sidebar also supports a `responsive` behavior, listening to window size change and changing its size respectably.
74 *
75 * In a pair with header it is possible to setup a configuration when header is placed on a side of the sidebar
76 * and not on top of it. To achieve this simply put a `subheader` property to the header like this:
77 * ```html
78 * <nb-layout-header subheader></nb-layout-header>
79 * ```
80 * @stacked-example(Subheader, layout/layout-sidebar-subheader.component)
81 * Note that in such configuration sidebar shadow is removed and header cannot be make `fixed`.
82 *
83 * @additional-example(Right Sidebar, sidebar/sidebar-right.component)
84 * @additional-example(Fixed Sidebar, sidebar/sidebar-fixed.component)
85 *
86 * @styles
87 *
88 * sidebar-background-color:
89 * sidebar-text-color:
90 * sidebar-text-font-family:
91 * sidebar-text-font-size:
92 * sidebar-text-font-weight:
93 * sidebar-text-line-height:
94 * sidebar-height:
95 * sidebar-width:
96 * sidebar-width-compact:
97 * sidebar-padding:
98 * sidebar-header-height:
99 * sidebar-footer-height:
100 * sidebar-shadow:
101 * sidebar-menu-item-highlight-color:
102 * sidebar-scrollbar-background-color:
103 * sidebar-scrollbar-color:
104 * sidebar-scrollbar-width:
105 */
106export declare class NbSidebarComponent implements OnInit, OnDestroy {
107 private sidebarService;
108 private themeService;
109 private element;
110 private cd;
111 protected readonly responsiveValueChange$: Subject<boolean>;
112 protected responsiveState: NbSidebarResponsiveState;
113 protected destroy$: Subject<void>;
114 containerFixedValue: boolean;
115 fixedValue: boolean;
116 rightValue: boolean;
117 leftValue: boolean;
118 startValue: boolean;
119 endValue: boolean;
120 get expanded(): boolean;
121 get collapsed(): boolean;
122 get compacted(): boolean;
123 /**
124 * Places sidebar on the right side
125 * @type {boolean}
126 */
127 set right(val: boolean);
128 static ngAcceptInputType_right: NbBooleanInput;
129 /**
130 * Places sidebar on the left side
131 * @type {boolean}
132 */
133 set left(val: boolean);
134 static ngAcceptInputType_left: NbBooleanInput;
135 /**
136 * Places sidebar on the start edge of layout
137 * @type {boolean}
138 */
139 set start(val: boolean);
140 static ngAcceptInputType_start: NbBooleanInput;
141 /**
142 * Places sidebar on the end edge of layout
143 * @type {boolean}
144 */
145 set end(val: boolean);
146 static ngAcceptInputType_end: NbBooleanInput;
147 /**
148 * Makes sidebar fixed (shown above the layout content)
149 * @type {boolean}
150 */
151 set fixed(val: boolean);
152 static ngAcceptInputType_fixed: NbBooleanInput;
153 /**
154 * Makes sidebar container fixed
155 * @type {boolean}
156 */
157 set containerFixed(val: boolean);
158 static ngAcceptInputType_containerFixed: NbBooleanInput;
159 /**
160 * Initial sidebar state, `expanded`|`collapsed`|`compacted`
161 * @type {string}
162 */
163 get state(): NbSidebarState;
164 set state(value: NbSidebarState);
165 protected _state: NbSidebarState;
166 /**
167 * Makes sidebar listen to media query events and change its behaviour
168 * @type {boolean}
169 */
170 get responsive(): boolean;
171 set responsive(value: boolean);
172 protected _responsive: boolean;
173 static ngAcceptInputType_responsive: NbBooleanInput;
174 /**
175 * Tags a sidebar with some ID, can be later used in the sidebar service
176 * to determine which sidebar triggered the action, if multiple sidebars exist on the page.
177 *
178 * @type {string}
179 */
180 tag: string;
181 /**
182 * Controls on which screen sizes sidebar should be switched to compacted state.
183 * Works only when responsive mode is on.
184 * Default values are `['xs', 'is', 'sm', 'md', 'lg']`.
185 *
186 * @type string[]
187 */
188 compactedBreakpoints: string[];
189 /**
190 * Controls on which screen sizes sidebar should be switched to collapsed state.
191 * Works only when responsive mode is on.
192 * Default values are `['xs', 'is']`.
193 *
194 * @type string[]
195 */
196 collapsedBreakpoints: string[];
197 /**
198 * Emits whenever sidebar state change.
199 */
200 readonly stateChange: EventEmitter<NbSidebarState>;
201 /**
202 * Emits whenever sidebar responsive state change.
203 */
204 readonly responsiveStateChange: EventEmitter<NbSidebarResponsiveState>;
205 constructor(sidebarService: NbSidebarService, themeService: NbThemeService, element: ElementRef, cd: ChangeDetectorRef);
206 ngOnInit(): void;
207 ngOnDestroy(): void;
208 onClick(event: any): void;
209 /**
210 * Collapses the sidebar
211 */
212 collapse(): void;
213 /**
214 * Expands the sidebar
215 */
216 expand(): void;
217 /**
218 * Compacts the sidebar (minimizes)
219 */
220 compact(): void;
221 /**
222 * Toggles sidebar state (expanded|collapsed|compacted)
223 * @param {boolean} compact If true, then sidebar state will be changed between expanded & compacted,
224 * otherwise - between expanded & collapsed. False by default.
225 *
226 * Toggle sidebar state
227 *
228 * ```ts
229 * this.sidebar.toggle(true);
230 * ```
231 */
232 toggle(compact?: boolean): void;
233 protected subscribeToMediaQueryChange(): void;
234 protected getMenuLink(element: HTMLElement): HTMLElement | undefined;
235 protected updateState(state: NbSidebarState): void;
236 static ɵfac: i0.ɵɵFactoryDeclaration<NbSidebarComponent, never>;
237 static ɵcmp: i0.ɵɵComponentDeclaration<NbSidebarComponent, "nb-sidebar", never, { "right": { "alias": "right"; "required": false; }; "left": { "alias": "left"; "required": false; }; "start": { "alias": "start"; "required": false; }; "end": { "alias": "end"; "required": false; }; "fixed": { "alias": "fixed"; "required": false; }; "containerFixed": { "alias": "containerFixed"; "required": false; }; "state": { "alias": "state"; "required": false; }; "responsive": { "alias": "responsive"; "required": false; }; "tag": { "alias": "tag"; "required": false; }; "compactedBreakpoints": { "alias": "compactedBreakpoints"; "required": false; }; "collapsedBreakpoints": { "alias": "collapsedBreakpoints"; "required": false; }; }, { "stateChange": "stateChange"; "responsiveStateChange": "responsiveStateChange"; }, never, ["nb-sidebar-header", "*", "nb-sidebar-footer"], false, never>;
238}