UNPKG

11.9 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, OnInit, EventEmitter, OnDestroy, Renderer2, ElementRef, AfterViewInit, NgZone } from '@angular/core';
7import { ControlValueAccessor } from '@angular/forms';
8import { NbStatusService } from '../../services/status.service';
9import { NbLayoutDirectionService } from '../../services/direction.service';
10import { NbComponentOrCustomStatus } from '../component-status';
11import { NbBooleanInput } from '../helpers';
12import * as i0 from "@angular/core";
13/**
14 * Toggle is a control representing `on` and `off` states.
15 *
16 * @stacked-example(Showcase, toggle/toggle-showcase.component)
17 *
18 * ### Installation
19 *
20 * Import `NbToggleComponent` to your feature module.
21 * ```ts
22 * @NgModule({
23 * imports: [
24 * // ...
25 * NbToggleModule,
26 * ],
27 * })
28 * export class PageModule { }
29 * ```
30 * ### Usage
31 *
32 * Toggle may have one of the following statuses: `basic`, `primary`, `success`, `warning`, `danger`, `info`, `control`
33 *
34 * @stacked-example(Toggle status, toggle/toggle-status.component)
35 *
36 * Toggle can be disabled via `disabled` input.
37 *
38 * @stacked-example(Disabled Toggles, toggle/toggle-disabled.component)
39 *
40 * Toggle may have a label with following positions: `left`, `right`, `start`, `end` (default)
41 *
42 * @stacked-example(Toggles With Labels, toggle/toggle-label-position.component.ts)
43 *
44 * You can set control state via `checked` binding:
45 *
46 * ```html
47 * <nb-toggle [(checked)]="checked"></nb-toggle>
48 * ```
49 *
50 * Or it could be set via reactive forms or ngModel bindings:
51 *
52 * @stacked-example(Toggle form binding, toggle/toggle-form.component)
53 *
54 * @styles
55 *
56 * toggle-height:
57 * toggle-width:
58 * toggle-border-width:
59 * toggle-border-radius:
60 * toggle-outline-width:
61 * toggle-outline-color:
62 * toggle-switcher-size:
63 * toggle-switcher-icon-size:
64 * toggle-text-font-family:
65 * toggle-text-font-size:
66 * toggle-text-font-weight:
67 * toggle-text-line-height:
68 * toggle-cursor:
69 * toggle-disabled-cursor:
70 * toggle-basic-text-color:
71 * toggle-basic-background-color:
72 * toggle-basic-border-color:
73 * toggle-basic-checked-background-color:
74 * toggle-basic-checked-border-color:
75 * toggle-basic-checked-switcher-background-color:
76 * toggle-basic-checked-switcher-checkmark-color:
77 * toggle-basic-focus-background-color:
78 * toggle-basic-focus-border-color:
79 * toggle-basic-focus-checked-background-color:
80 * toggle-basic-focus-checked-border-color:
81 * toggle-basic-hover-background-color:
82 * toggle-basic-hover-border-color:
83 * toggle-basic-hover-checked-background-color:
84 * toggle-basic-hover-checked-border-color:
85 * toggle-basic-active-background-color:
86 * toggle-basic-active-border-color:
87 * toggle-basic-active-checked-background-color:
88 * toggle-basic-active-checked-border-color:
89 * toggle-basic-disabled-background-color:
90 * toggle-basic-disabled-border-color:
91 * toggle-basic-disabled-switcher-background-color:
92 * toggle-basic-disabled-checked-switcher-checkmark-color:
93 * toggle-basic-disabled-text-color:
94 * toggle-primary-text-color:
95 * toggle-primary-background-color:
96 * toggle-primary-border-color:
97 * toggle-primary-checked-background-color:
98 * toggle-primary-checked-border-color:
99 * toggle-primary-checked-switcher-background-color:
100 * toggle-primary-checked-switcher-checkmark-color:
101 * toggle-primary-focus-background-color:
102 * toggle-primary-focus-border-color:
103 * toggle-primary-focus-checked-background-color:
104 * toggle-primary-focus-checked-border-color:
105 * toggle-primary-hover-background-color:
106 * toggle-primary-hover-border-color:
107 * toggle-primary-hover-checked-background-color:
108 * toggle-primary-hover-checked-border-color:
109 * toggle-primary-active-background-color:
110 * toggle-primary-active-border-color:
111 * toggle-primary-active-checked-background-color:
112 * toggle-primary-active-checked-border-color:
113 * toggle-primary-disabled-background-color:
114 * toggle-primary-disabled-border-color:
115 * toggle-primary-disabled-switcher-background-color:
116 * toggle-primary-disabled-checked-switcher-checkmark-color:
117 * toggle-primary-disabled-text-color:
118 * toggle-success-text-color:
119 * toggle-success-background-color:
120 * toggle-success-border-color:
121 * toggle-success-checked-background-color:
122 * toggle-success-checked-border-color:
123 * toggle-success-checked-switcher-background-color:
124 * toggle-success-checked-switcher-checkmark-color:
125 * toggle-success-focus-background-color:
126 * toggle-success-focus-border-color:
127 * toggle-success-focus-checked-background-color:
128 * toggle-success-focus-checked-border-color:
129 * toggle-success-hover-background-color:
130 * toggle-success-hover-border-color:
131 * toggle-success-hover-checked-background-color:
132 * toggle-success-hover-checked-border-color:
133 * toggle-success-active-background-color:
134 * toggle-success-active-border-color:
135 * toggle-success-active-checked-background-color:
136 * toggle-success-active-checked-border-color:
137 * toggle-success-disabled-background-color:
138 * toggle-success-disabled-border-color:
139 * toggle-success-disabled-switcher-background-color:
140 * toggle-success-disabled-checked-switcher-checkmark-color:
141 * toggle-success-disabled-text-color:
142 * toggle-info-text-color:
143 * toggle-info-background-color:
144 * toggle-info-border-color:
145 * toggle-info-checked-background-color:
146 * toggle-info-checked-border-color:
147 * toggle-info-checked-switcher-background-color:
148 * toggle-info-checked-switcher-checkmark-color:
149 * toggle-info-focus-background-color:
150 * toggle-info-focus-border-color:
151 * toggle-info-focus-checked-background-color:
152 * toggle-info-focus-checked-border-color:
153 * toggle-info-hover-background-color:
154 * toggle-info-hover-border-color:
155 * toggle-info-hover-checked-background-color:
156 * toggle-info-hover-checked-border-color:
157 * toggle-info-active-background-color:
158 * toggle-info-active-border-color:
159 * toggle-info-active-checked-background-color:
160 * toggle-info-active-checked-border-color:
161 * toggle-info-disabled-background-color:
162 * toggle-info-disabled-border-color:
163 * toggle-info-disabled-switcher-background-color:
164 * toggle-info-disabled-checked-switcher-checkmark-color:
165 * toggle-info-disabled-text-color:
166 * toggle-warning-text-color:
167 * toggle-warning-background-color:
168 * toggle-warning-border-color:
169 * toggle-warning-checked-background-color:
170 * toggle-warning-checked-border-color:
171 * toggle-warning-checked-switcher-background-color:
172 * toggle-warning-checked-switcher-checkmark-color:
173 * toggle-warning-focus-background-color:
174 * toggle-warning-focus-border-color:
175 * toggle-warning-focus-checked-background-color:
176 * toggle-warning-focus-checked-border-color:
177 * toggle-warning-hover-background-color:
178 * toggle-warning-hover-border-color:
179 * toggle-warning-hover-checked-background-color:
180 * toggle-warning-hover-checked-border-color:
181 * toggle-warning-active-background-color:
182 * toggle-warning-active-border-color:
183 * toggle-warning-active-checked-background-color:
184 * toggle-warning-active-checked-border-color:
185 * toggle-warning-disabled-background-color:
186 * toggle-warning-disabled-border-color:
187 * toggle-warning-disabled-switcher-background-color:
188 * toggle-warning-disabled-checked-switcher-checkmark-color:
189 * toggle-warning-disabled-text-color:
190 * toggle-danger-text-color:
191 * toggle-danger-background-color:
192 * toggle-danger-border-color:
193 * toggle-danger-checked-background-color:
194 * toggle-danger-checked-border-color:
195 * toggle-danger-checked-switcher-background-color:
196 * toggle-danger-checked-switcher-checkmark-color:
197 * toggle-danger-focus-background-color:
198 * toggle-danger-focus-border-color:
199 * toggle-danger-focus-checked-background-color:
200 * toggle-danger-focus-checked-border-color:
201 * toggle-danger-hover-background-color:
202 * toggle-danger-hover-border-color:
203 * toggle-danger-hover-checked-background-color:
204 * toggle-danger-hover-checked-border-color:
205 * toggle-danger-active-background-color:
206 * toggle-danger-active-border-color:
207 * toggle-danger-active-checked-background-color:
208 * toggle-danger-active-checked-border-color:
209 * toggle-danger-disabled-background-color:
210 * toggle-danger-disabled-border-color:
211 * toggle-danger-disabled-switcher-background-color:
212 * toggle-danger-disabled-checked-switcher-checkmark-color:
213 * toggle-danger-disabled-text-color:
214 * toggle-control-text-color:
215 * toggle-control-background-color:
216 * toggle-control-border-color:
217 * toggle-control-checked-background-color:
218 * toggle-control-checked-border-color:
219 * toggle-control-checked-switcher-background-color:
220 * toggle-control-checked-switcher-checkmark-color:
221 * toggle-control-focus-background-color:
222 * toggle-control-focus-border-color:
223 * toggle-control-focus-checked-background-color:
224 * toggle-control-focus-checked-border-color:
225 * toggle-control-hover-background-color:
226 * toggle-control-hover-border-color:
227 * toggle-control-hover-checked-background-color:
228 * toggle-control-hover-checked-border-color:
229 * toggle-control-active-background-color:
230 * toggle-control-active-border-color:
231 * toggle-control-active-checked-background-color:
232 * toggle-control-active-checked-border-color:
233 * toggle-control-disabled-background-color:
234 * toggle-control-disabled-border-color:
235 * toggle-control-disabled-switcher-background-color:
236 * toggle-control-disabled-checked-switcher-checkmark-color:
237 * toggle-control-disabled-text-color:
238 */
239export declare class NbToggleComponent implements OnInit, AfterViewInit, OnDestroy, ControlValueAccessor {
240 private changeDetector;
241 private layoutDirection;
242 private renderer;
243 private hostElement;
244 private zone;
245 protected statusService: NbStatusService;
246 onChange: any;
247 onTouched: any;
248 private destroy$;
249 /**
250 * Toggle checked
251 * @type {boolean}
252 */
253 get checked(): boolean;
254 set checked(value: boolean);
255 private _checked;
256 static ngAcceptInputType_checked: NbBooleanInput;
257 /**
258 * Controls input disabled state
259 */
260 get disabled(): boolean;
261 set disabled(value: boolean);
262 private _disabled;
263 static ngAcceptInputType_disabled: NbBooleanInput;
264 /**
265 * Toggle status.
266 * Possible values are: `basic`, `primary`, `success`, `warning`, `danger`, `info`, `control`.
267 */
268 status: NbComponentOrCustomStatus;
269 /**
270 * Toggle label position.
271 * Possible values are: `left`, `right`, `start`, `end` (default)
272 */
273 labelPosition: 'left' | 'right' | 'start' | 'end';
274 /**
275 * Output when checked state is changed by a user
276 * @type EventEmitter<boolean>
277 */
278 checkedChange: EventEmitter<boolean>;
279 get primary(): boolean;
280 get success(): boolean;
281 get warning(): boolean;
282 get danger(): boolean;
283 get info(): boolean;
284 get basic(): boolean;
285 get control(): boolean;
286 get additionalClasses(): string[];
287 get labelLeft(): boolean;
288 get labelRight(): boolean;
289 get labelStart(): boolean;
290 get labelEnd(): boolean;
291 constructor(changeDetector: ChangeDetectorRef, layoutDirection: NbLayoutDirectionService, renderer: Renderer2, hostElement: ElementRef<HTMLElement>, zone: NgZone, statusService: NbStatusService);
292 ngOnInit(): void;
293 ngAfterViewInit(): void;
294 ngOnDestroy(): void;
295 checkState(): string;
296 registerOnChange(fn: any): void;
297 registerOnTouched(fn: any): void;
298 writeValue(val: any): void;
299 setDisabledState(val: boolean): void;
300 updateValue(event: Event): void;
301 onInputClick(event: Event): void;
302 static ɵfac: i0.ɵɵFactoryDeclaration<NbToggleComponent, never>;
303 static ɵcmp: i0.ɵɵComponentDeclaration<NbToggleComponent, "nb-toggle", never, { "checked": { "alias": "checked"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "status": { "alias": "status"; "required": false; }; "labelPosition": { "alias": "labelPosition"; "required": false; }; }, { "checkedChange": "checkedChange"; }, never, ["*"], false, never>;
304}