index.d.ts 14 KB

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