UNPKG

13.9 kBTypeScriptView Raw
1import { AfterContentInit } from '@angular/core';
2import { AfterViewInit } from '@angular/core';
3import { BooleanInput } from '@angular/cdk/coercion';
4import { ChangeDetectorRef } from '@angular/core';
5import { Directionality } from '@angular/cdk/bidi';
6import { ElementRef } from '@angular/core';
7import { EventEmitter } from '@angular/core';
8import { FocusableOption } from '@angular/cdk/a11y';
9import * as i0 from '@angular/core';
10import * as i5 from '@angular/cdk/bidi';
11import { InjectionToken } from '@angular/core';
12import { NumberInput } from '@angular/cdk/coercion';
13import { Observable } from 'rxjs';
14import { OnChanges } from '@angular/core';
15import { OnDestroy } from '@angular/core';
16import { QueryList } from '@angular/core';
17import { Subject } from 'rxjs';
18import { TemplateRef } from '@angular/core';
19
20/**
21 * Simplified representation of an "AbstractControl" from @angular/forms.
22 * Used to avoid having to bring in @angular/forms for a single optional interface.
23 * @docs-private
24 */
25declare interface AbstractControlLike {
26 asyncValidator: ((control: any) => any) | null;
27 dirty: boolean;
28 disabled: boolean;
29 enabled: boolean;
30 errors: {
31 [key: string]: any;
32 } | null;
33 invalid: boolean;
34 parent: any;
35 pending: boolean;
36 pristine: boolean;
37 root: AbstractControlLike;
38 status: string;
39 readonly statusChanges: Observable<any>;
40 touched: boolean;
41 untouched: boolean;
42 updateOn: any;
43 valid: boolean;
44 validator: ((control: any) => any) | null;
45 value: any;
46 readonly valueChanges: Observable<any>;
47 clearAsyncValidators(): void;
48 clearValidators(): void;
49 disable(opts?: any): void;
50 enable(opts?: any): void;
51 get(path: (string | number)[] | string): AbstractControlLike | null;
52 getError(errorCode: string, path?: (string | number)[] | string): any;
53 hasError(errorCode: string, path?: (string | number)[] | string): boolean;
54 markAllAsTouched(): void;
55 markAsDirty(opts?: any): void;
56 markAsPending(opts?: any): void;
57 markAsPristine(opts?: any): void;
58 markAsTouched(opts?: any): void;
59 markAsUntouched(opts?: any): void;
60 patchValue(value: any, options?: Object): void;
61 reset(value?: any, options?: Object): void;
62 setAsyncValidators(newValidator: (control: any) => any | ((control: any) => any)[] | null): void;
63 setErrors(errors: {
64 [key: string]: any;
65 } | null, opts?: any): void;
66 setParent(parent: any): void;
67 setValidators(newValidator: (control: any) => any | ((control: any) => any)[] | null): void;
68 setValue(value: any, options?: Object): void;
69 updateValueAndValidity(opts?: any): void;
70 patchValue(value: any, options?: any): void;
71 reset(formState?: any, options?: any): void;
72 setValue(value: any, options?: any): void;
73}
74
75export declare class CdkStep implements OnChanges {
76 _stepper: CdkStepper;
77 private _stepperOptions;
78 _displayDefaultIndicatorType: boolean;
79 /** Template for step label if it exists. */
80 stepLabel: CdkStepLabel;
81 /** Template for step content. */
82 content: TemplateRef<any>;
83 /** The top level abstract control of the step. */
84 stepControl: AbstractControlLike;
85 /** Whether user has attempted to move away from the step. */
86 interacted: boolean;
87 /** Emits when the user has attempted to move away from the step. */
88 readonly interactedStream: EventEmitter<CdkStep>;
89 /** Plain text label of the step. */
90 label: string;
91 /** Error message to display when there's an error. */
92 errorMessage: string;
93 /** Aria label for the tab. */
94 ariaLabel: string;
95 /**
96 * Reference to the element that the tab is labelled by.
97 * Will be cleared if `aria-label` is set at the same time.
98 */
99 ariaLabelledby: string;
100 /** State of the step. */
101 state: StepState;
102 /** Whether the user can return to this step once it has been marked as completed. */
103 get editable(): boolean;
104 set editable(value: BooleanInput);
105 private _editable;
106 /** Whether the completion of step is optional. */
107 get optional(): boolean;
108 set optional(value: BooleanInput);
109 private _optional;
110 /** Whether step is marked as completed. */
111 get completed(): boolean;
112 set completed(value: BooleanInput);
113 _completedOverride: boolean | null;
114 private _getDefaultCompleted;
115 /** Whether step has an error. */
116 get hasError(): boolean;
117 set hasError(value: BooleanInput);
118 private _customError;
119 private _getDefaultError;
120 constructor(_stepper: CdkStepper, stepperOptions?: StepperOptions);
121 /** Selects this step component. */
122 select(): void;
123 /** Resets the step to its initial state. Note that this includes resetting form data. */
124 reset(): void;
125 ngOnChanges(): void;
126 _markAsInteracted(): void;
127 /** Determines whether the error state can be shown. */
128 _showError(): boolean;
129 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStep, [null, { optional: true; }]>;
130 static ɵcmp: i0.ɵɵComponentDeclaration<CdkStep, "cdk-step", ["cdkStep"], { "stepControl": { "alias": "stepControl"; "required": false; }; "label": { "alias": "label"; "required": false; }; "errorMessage": { "alias": "errorMessage"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "state": { "alias": "state"; "required": false; }; "editable": { "alias": "editable"; "required": false; }; "optional": { "alias": "optional"; "required": false; }; "completed": { "alias": "completed"; "required": false; }; "hasError": { "alias": "hasError"; "required": false; }; }, { "interactedStream": "interacted"; }, ["stepLabel"], ["*"], false, never>;
131}
132
133export declare class CdkStepHeader implements FocusableOption {
134 _elementRef: ElementRef<HTMLElement>;
135 constructor(_elementRef: ElementRef<HTMLElement>);
136 /** Focuses the step header. */
137 focus(): void;
138 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepHeader, never>;
139 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkStepHeader, "[cdkStepHeader]", never, {}, {}, never, never, false, never>;
140}
141
142export declare class CdkStepLabel {
143 template: TemplateRef<any>;
144 constructor(/** @docs-private */ template: TemplateRef<any>);
145 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepLabel, never>;
146 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkStepLabel, "[cdkStepLabel]", never, {}, {}, never, never, false, never>;
147}
148
149export declare class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
150 private _dir;
151 private _changeDetectorRef;
152 private _elementRef;
153 /** Emits when the component is destroyed. */
154 protected readonly _destroyed: Subject<void>;
155 /** Used for managing keyboard focus. */
156 private _keyManager;
157 /** Full list of steps inside the stepper, including inside nested steppers. */
158 _steps: QueryList<CdkStep>;
159 /** Steps that belong to the current stepper, excluding ones from nested steppers. */
160 readonly steps: QueryList<CdkStep>;
161 /** The list of step headers of the steps in the stepper. */
162 _stepHeader: QueryList<CdkStepHeader>;
163 /** List of step headers sorted based on their DOM order. */
164 private _sortedHeaders;
165 /** Whether the validity of previous steps should be checked or not. */
166 get linear(): boolean;
167 set linear(value: BooleanInput);
168 private _linear;
169 /** The index of the selected step. */
170 get selectedIndex(): number;
171 set selectedIndex(index: NumberInput);
172 private _selectedIndex;
173 /** The step that is selected. */
174 get selected(): CdkStep | undefined;
175 set selected(step: CdkStep | undefined);
176 /** Event emitted when the selected step has changed. */
177 readonly selectionChange: EventEmitter<StepperSelectionEvent>;
178 /** Used to track unique ID for each stepper component. */
179 _groupId: number;
180 /** Orientation of the stepper. */
181 get orientation(): StepperOrientation;
182 set orientation(value: StepperOrientation);
183 private _orientation;
184 constructor(_dir: Directionality, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef<HTMLElement>);
185 ngAfterContentInit(): void;
186 ngAfterViewInit(): void;
187 ngOnDestroy(): void;
188 /** Selects and focuses the next step in list. */
189 next(): void;
190 /** Selects and focuses the previous step in list. */
191 previous(): void;
192 /** Resets the stepper to its initial state. Note that this includes clearing form data. */
193 reset(): void;
194 /** Returns a unique id for each step label element. */
195 _getStepLabelId(i: number): string;
196 /** Returns unique id for each step content element. */
197 _getStepContentId(i: number): string;
198 /** Marks the component to be change detected. */
199 _stateChanged(): void;
200 /** Returns position state of the step with the given index. */
201 _getAnimationDirection(index: number): StepContentPositionState;
202 /** Returns the type of icon to be displayed. */
203 _getIndicatorType(index: number, state?: StepState): StepState;
204 private _getDefaultIndicatorLogic;
205 private _getGuidelineLogic;
206 private _isCurrentStep;
207 /** Returns the index of the currently-focused step header. */
208 _getFocusIndex(): number | null;
209 private _updateSelectedItemIndex;
210 _onKeydown(event: KeyboardEvent): void;
211 private _anyControlsInvalidOrPending;
212 private _layoutDirection;
213 /** Checks whether the stepper contains the focused element. */
214 private _containsFocus;
215 /** Checks whether the passed-in index is a valid step index. */
216 private _isValidIndex;
217 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepper, [{ optional: true; }, null, null]>;
218 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkStepper, "[cdkStepper]", ["cdkStepper"], { "linear": { "alias": "linear"; "required": false; }; "selectedIndex": { "alias": "selectedIndex"; "required": false; }; "selected": { "alias": "selected"; "required": false; }; "orientation": { "alias": "orientation"; "required": false; }; }, { "selectionChange": "selectionChange"; }, ["_steps", "_stepHeader"], never, false, never>;
219}
220
221export declare class CdkStepperModule {
222 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepperModule, never>;
223 static ɵmod: i0.ɵɵNgModuleDeclaration<CdkStepperModule, [typeof i1.CdkStep, typeof i1.CdkStepper, typeof i2.CdkStepHeader, typeof i3.CdkStepLabel, typeof i4.CdkStepperNext, typeof i4.CdkStepperPrevious], [typeof i5.BidiModule], [typeof i1.CdkStep, typeof i1.CdkStepper, typeof i2.CdkStepHeader, typeof i3.CdkStepLabel, typeof i4.CdkStepperNext, typeof i4.CdkStepperPrevious]>;
224 static ɵinj: i0.ɵɵInjectorDeclaration<CdkStepperModule>;
225}
226
227/** Button that moves to the next step in a stepper workflow. */
228export declare class CdkStepperNext {
229 _stepper: CdkStepper;
230 /** Type of the next button. Defaults to "submit" if not specified. */
231 type: string;
232 constructor(_stepper: CdkStepper);
233 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepperNext, never>;
234 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkStepperNext, "button[cdkStepperNext]", never, { "type": { "alias": "type"; "required": false; }; }, {}, never, never, false, never>;
235}
236
237/** Button that moves to the previous step in a stepper workflow. */
238export declare class CdkStepperPrevious {
239 _stepper: CdkStepper;
240 /** Type of the previous button. Defaults to "button" if not specified. */
241 type: string;
242 constructor(_stepper: CdkStepper);
243 static ɵfac: i0.ɵɵFactoryDeclaration<CdkStepperPrevious, never>;
244 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkStepperPrevious, "button[cdkStepperPrevious]", never, { "type": { "alias": "type"; "required": false; }; }, {}, never, never, false, never>;
245}
246
247declare namespace i1 {
248 export {
249 StepContentPositionState,
250 StepperOrientation,
251 StepperSelectionEvent,
252 StepState,
253 STEP_STATE,
254 STEPPER_GLOBAL_OPTIONS,
255 StepperOptions,
256 CdkStep,
257 CdkStepper
258 }
259}
260
261declare namespace i2 {
262 export {
263 CdkStepHeader
264 }
265}
266
267declare namespace i3 {
268 export {
269 CdkStepLabel
270 }
271}
272
273declare namespace i4 {
274 export {
275 CdkStepperNext,
276 CdkStepperPrevious
277 }
278}
279
280/** Enum to represent the different states of the steps. */
281export declare const STEP_STATE: {
282 NUMBER: string;
283 EDIT: string;
284 DONE: string;
285 ERROR: string;
286};
287
288/**
289 * Position state of the content of each step in stepper that is used for transitioning
290 * the content into correct position upon step selection change.
291 */
292export declare type StepContentPositionState = 'previous' | 'current' | 'next';
293
294/** InjectionToken that can be used to specify the global stepper options. */
295export declare const STEPPER_GLOBAL_OPTIONS: InjectionToken<StepperOptions>;
296
297/** Configurable options for stepper. */
298export declare interface StepperOptions {
299 /**
300 * Whether the stepper should display an error state or not.
301 * Default behavior is assumed to be false.
302 */
303 showError?: boolean;
304 /**
305 * Whether the stepper should display the default indicator type
306 * or not.
307 * Default behavior is assumed to be true.
308 */
309 displayDefaultIndicatorType?: boolean;
310}
311
312/** Possible orientation of a stepper. */
313export declare type StepperOrientation = 'horizontal' | 'vertical';
314
315/** Change event emitted on selection changes. */
316export declare class StepperSelectionEvent {
317 /** Index of the step now selected. */
318 selectedIndex: number;
319 /** Index of the step previously selected. */
320 previouslySelectedIndex: number;
321 /** The step instance now selected. */
322 selectedStep: CdkStep;
323 /** The step instance previously selected. */
324 previouslySelectedStep: CdkStep;
325}
326
327/** The state of each step. */
328export declare type StepState = 'number' | 'edit' | 'done' | 'error' | string;
329
330export { }
331
\No newline at end of file