index.d.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. import * as i0 from '@angular/core';
  2. import { OnDestroy, Signal, ModelSignal, InputSignal, InputSignalWithTransform, ElementRef, InjectionToken, TemplateRef, OutputEmitterRef } from '@angular/core';
  3. import { M as MatOption } from '../option.d-BVGX3edu.js';
  4. import { M as MatOptionParentComponent } from '../option-parent.d-CnYuuMkO.js';
  5. import { ScrollStrategy } from '@angular/cdk/overlay';
  6. import { ControlValueAccessor, Validator, AbstractControl, ValidationErrors } from '@angular/forms';
  7. import * as i5 from '@angular/cdk/scrolling';
  8. import '@angular/cdk/a11y';
  9. import 'rxjs';
  10. /**
  11. * Input that can be used to enter time and connect to a `mat-timepicker`.
  12. */
  13. declare class MatTimepickerInput<D> implements ControlValueAccessor, Validator, OnDestroy {
  14. private _elementRef;
  15. private _dateAdapter;
  16. private _dateFormats;
  17. private _formField;
  18. private _onChange;
  19. private _onTouched;
  20. private _validatorOnChange;
  21. private _cleanupClick;
  22. private _accessorDisabled;
  23. private _localeSubscription;
  24. private _timepickerSubscription;
  25. private _validator;
  26. private _lastValueValid;
  27. private _lastValidDate;
  28. /** Value of the `aria-activedescendant` attribute. */
  29. protected readonly _ariaActiveDescendant: Signal<string | null>;
  30. /** Value of the `aria-expanded` attribute. */
  31. protected readonly _ariaExpanded: Signal<string>;
  32. /** Value of the `aria-controls` attribute. */
  33. protected readonly _ariaControls: Signal<string | null>;
  34. /** Current value of the input. */
  35. readonly value: ModelSignal<D | null>;
  36. /** Timepicker that the input is associated with. */
  37. readonly timepicker: InputSignal<MatTimepicker<D>>;
  38. /**
  39. * Minimum time that can be selected or typed in. Can be either
  40. * a date object (only time will be used) or a valid time string.
  41. */
  42. readonly min: InputSignalWithTransform<D | null, unknown>;
  43. /**
  44. * Maximum time that can be selected or typed in. Can be either
  45. * a date object (only time will be used) or a valid time string.
  46. */
  47. readonly max: InputSignalWithTransform<D | null, unknown>;
  48. /** Whether the input is disabled. */
  49. readonly disabled: Signal<boolean>;
  50. /**
  51. * Whether the input should be disabled through the template.
  52. * @docs-private
  53. */
  54. readonly disabledInput: InputSignalWithTransform<boolean, unknown>;
  55. constructor();
  56. /**
  57. * Implemented as a part of `ControlValueAccessor`.
  58. * @docs-private
  59. */
  60. writeValue(value: any): void;
  61. /**
  62. * Implemented as a part of `ControlValueAccessor`.
  63. * @docs-private
  64. */
  65. registerOnChange(fn: (value: any) => void): void;
  66. /**
  67. * Implemented as a part of `ControlValueAccessor`.
  68. * @docs-private
  69. */
  70. registerOnTouched(fn: () => void): void;
  71. /**
  72. * Implemented as a part of `ControlValueAccessor`.
  73. * @docs-private
  74. */
  75. setDisabledState(isDisabled: boolean): void;
  76. /**
  77. * Implemented as a part of `Validator`.
  78. * @docs-private
  79. */
  80. validate(control: AbstractControl): ValidationErrors | null;
  81. /**
  82. * Implemented as a part of `Validator`.
  83. * @docs-private
  84. */
  85. registerOnValidatorChange(fn: () => void): void;
  86. /** Gets the element to which the timepicker popup should be attached. */
  87. getOverlayOrigin(): ElementRef<HTMLElement>;
  88. /** Focuses the input. */
  89. focus(): void;
  90. ngOnDestroy(): void;
  91. /** Gets the ID of the input's label. */
  92. _getLabelId(): string | null;
  93. /** Handles clicks on the input or the containing form field. */
  94. private _handleClick;
  95. /** Handles the `input` event. */
  96. protected _handleInput(value: string): void;
  97. /** Handles the `blur` event. */
  98. protected _handleBlur(): void;
  99. /** Handles the `keydown` event. */
  100. protected _handleKeydown(event: KeyboardEvent): void;
  101. /** Sets up the code that watches for changes in the value and adjusts the input. */
  102. private _respondToValueChanges;
  103. /** Sets up the logic that registers the input with the timepicker. */
  104. private _registerTimepicker;
  105. /** Sets up the logic that adjusts the input if the min/max changes. */
  106. private _respondToMinMaxChanges;
  107. /**
  108. * Assigns a value set by the user to the input's model.
  109. * @param selection Time selected by the user that should be assigned.
  110. * @param propagateToAccessor Whether the value should be propagated to the ControlValueAccessor.
  111. */
  112. private _assignUserSelection;
  113. /** Formats the current value and assigns it to the input. */
  114. private _formatValue;
  115. /** Checks whether a value is valid. */
  116. private _isValid;
  117. /** Transforms an arbitrary value into a value that can be assigned to a date-based input. */
  118. private _transformDateInput;
  119. /** Whether the input is currently focused. */
  120. private _hasFocus;
  121. /** Gets a function that can be used to validate the input. */
  122. private _getValidator;
  123. static ɵfac: i0.ɵɵFactoryDeclaration<MatTimepickerInput<any>, never>;
  124. static ɵdir: i0.ɵɵDirectiveDeclaration<MatTimepickerInput<any>, "input[matTimepicker]", ["matTimepickerInput"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "timepicker": { "alias": "matTimepicker"; "required": true; "isSignal": true; }; "min": { "alias": "matTimepickerMin"; "required": false; "isSignal": true; }; "max": { "alias": "matTimepickerMax"; "required": false; "isSignal": true; }; "disabledInput": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; }, never, never, true, never>;
  125. }
  126. /**
  127. * Object that can be used to configure the default options for the timepicker component.
  128. */
  129. interface MatTimepickerConfig {
  130. /** Default interval for all time pickers. */
  131. interval?: string | number;
  132. /** Whether ripples inside the timepicker should be disabled by default. */
  133. disableRipple?: boolean;
  134. }
  135. /**
  136. * Injection token that can be used to configure the default options for the timepicker component.
  137. */
  138. declare const MAT_TIMEPICKER_CONFIG: InjectionToken<MatTimepickerConfig>;
  139. /**
  140. * Time selection option that can be displayed within a `mat-timepicker`.
  141. */
  142. interface MatTimepickerOption<D = unknown> {
  143. /** Date value of the option. */
  144. value: D;
  145. /** Label to show to the user. */
  146. label: string;
  147. }
  148. /** Event emitted when a value is selected in the timepicker. */
  149. interface MatTimepickerSelected<D> {
  150. value: D;
  151. source: MatTimepicker<D>;
  152. }
  153. /** Injection token used to configure the behavior of the timepicker dropdown while scrolling. */
  154. declare const MAT_TIMEPICKER_SCROLL_STRATEGY: InjectionToken<() => ScrollStrategy>;
  155. /**
  156. * Renders out a listbox that can be used to select a time of day.
  157. * Intended to be used together with `MatTimepickerInput`.
  158. */
  159. declare class MatTimepicker<D> implements OnDestroy, MatOptionParentComponent {
  160. private _overlay;
  161. private _dir;
  162. private _viewContainerRef;
  163. private _injector;
  164. private _defaultConfig;
  165. private _dateAdapter;
  166. private _dateFormats;
  167. private _scrollStrategyFactory;
  168. protected _animationsDisabled: boolean;
  169. private _isOpen;
  170. private _activeDescendant;
  171. private _input;
  172. private _overlayRef;
  173. private _portal;
  174. private _optionsCacheKey;
  175. private _localeChanges;
  176. private _onOpenRender;
  177. protected _panelTemplate: Signal<TemplateRef<unknown>>;
  178. protected _timeOptions: readonly MatTimepickerOption<D>[];
  179. protected _options: Signal<readonly MatOption<any>[]>;
  180. private _keyManager;
  181. /**
  182. * Interval between each option in the timepicker. The value can either be an amount of
  183. * seconds (e.g. 90) or a number with a unit (e.g. 45m). Supported units are `s` for seconds,
  184. * `m` for minutes or `h` for hours.
  185. */
  186. readonly interval: InputSignalWithTransform<number | null, number | string | null>;
  187. /**
  188. * Array of pre-defined options that the user can select from, as an alternative to using the
  189. * `interval` input. An error will be thrown if both `options` and `interval` are specified.
  190. */
  191. readonly options: InputSignal<readonly MatTimepickerOption<D>[] | null>;
  192. /** Whether the timepicker is open. */
  193. readonly isOpen: Signal<boolean>;
  194. /** Emits when the user selects a time. */
  195. readonly selected: OutputEmitterRef<MatTimepickerSelected<D>>;
  196. /** Emits when the timepicker is opened. */
  197. readonly opened: OutputEmitterRef<void>;
  198. /** Emits when the timepicker is closed. */
  199. readonly closed: OutputEmitterRef<void>;
  200. /** ID of the active descendant option. */
  201. readonly activeDescendant: Signal<string | null>;
  202. /** Unique ID of the timepicker's panel */
  203. readonly panelId: string;
  204. /** Whether ripples within the timepicker should be disabled. */
  205. readonly disableRipple: InputSignalWithTransform<boolean, unknown>;
  206. /** ARIA label for the timepicker panel. */
  207. readonly ariaLabel: InputSignal<string | null>;
  208. /** ID of the label element for the timepicker panel. */
  209. readonly ariaLabelledby: InputSignal<string | null>;
  210. /** Whether the timepicker is currently disabled. */
  211. readonly disabled: Signal<boolean>;
  212. constructor();
  213. /** Opens the timepicker. */
  214. open(): void;
  215. /** Closes the timepicker. */
  216. close(): void;
  217. /** Registers an input with the timepicker. */
  218. registerInput(input: MatTimepickerInput<D>): void;
  219. ngOnDestroy(): void;
  220. /** Selects a specific time value. */
  221. protected _selectValue(option: MatOption<D>): void;
  222. /** Gets the value of the `aria-labelledby` attribute. */
  223. protected _getAriaLabelledby(): string | null;
  224. /** Handles animation events coming from the panel. */
  225. protected _handleAnimationEnd(event: AnimationEvent): void;
  226. /** Creates an overlay reference for the timepicker panel. */
  227. private _getOverlayRef;
  228. /** Generates the list of options from which the user can select.. */
  229. private _generateOptions;
  230. /**
  231. * Synchronizes the internal state of the component based on a specific selected date.
  232. * @param value Currently selected date.
  233. * @param options Options rendered out in the timepicker.
  234. * @param fallback Option to set as active if no option is selected.
  235. */
  236. private _syncSelectedState;
  237. /** Handles keyboard events while the overlay is open. */
  238. private _handleKeydown;
  239. /** Sets up the logic that updates the timepicker when the locale changes. */
  240. private _handleLocaleChanges;
  241. /**
  242. * Sets up the logic that updates the timepicker when the state of the connected input changes.
  243. */
  244. private _handleInputStateChanges;
  245. static ɵfac: i0.ɵɵFactoryDeclaration<MatTimepicker<any>, never>;
  246. static ɵcmp: i0.ɵɵComponentDeclaration<MatTimepicker<any>, "mat-timepicker", ["matTimepicker"], { "interval": { "alias": "interval"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "disableRipple": { "alias": "disableRipple"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; }, { "selected": "selected"; "opened": "opened"; "closed": "closed"; }, never, never, true, never>;
  247. }
  248. /** Button that can be used to open a `mat-timepicker`. */
  249. declare class MatTimepickerToggle<D> {
  250. private _defaultConfig;
  251. private _defaultTabIndex;
  252. protected _isDisabled: i0.Signal<boolean>;
  253. /** Timepicker instance that the button will toggle. */
  254. readonly timepicker: InputSignal<MatTimepicker<D>>;
  255. /** Screen-reader label for the button. */
  256. readonly ariaLabel: InputSignal<string | undefined>;
  257. /** Screen-reader labelled by id for the button. */
  258. readonly ariaLabelledby: InputSignal<string | undefined>;
  259. /** Default aria-label for the toggle if none is provided. */
  260. private readonly _defaultAriaLabel;
  261. /** Whether the toggle button is disabled. */
  262. readonly disabled: InputSignalWithTransform<boolean, unknown>;
  263. /** Tabindex for the toggle. */
  264. readonly tabIndex: InputSignal<number | null>;
  265. /** Whether ripples on the toggle should be disabled. */
  266. readonly disableRipple: InputSignalWithTransform<boolean, unknown>;
  267. /** Opens the connected timepicker. */
  268. protected _open(event: Event): void;
  269. /**
  270. * Checks for ariaLabelledby and if empty uses custom
  271. * aria-label or defaultAriaLabel if neither is provided.
  272. */
  273. getAriaLabel(): string | null;
  274. static ɵfac: i0.ɵɵFactoryDeclaration<MatTimepickerToggle<any>, never>;
  275. static ɵcmp: i0.ɵɵComponentDeclaration<MatTimepickerToggle<any>, "mat-timepicker-toggle", ["matTimepickerToggle"], { "timepicker": { "alias": "for"; "required": true; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "tabIndex": { "alias": "tabIndex"; "required": false; "isSignal": true; }; "disableRipple": { "alias": "disableRipple"; "required": false; "isSignal": true; }; }, {}, never, ["[matTimepickerToggleIcon]"], true, never>;
  276. }
  277. declare class MatTimepickerModule {
  278. static ɵfac: i0.ɵɵFactoryDeclaration<MatTimepickerModule, never>;
  279. static ɵmod: i0.ɵɵNgModuleDeclaration<MatTimepickerModule, never, [typeof MatTimepicker, typeof MatTimepickerInput, typeof MatTimepickerToggle], [typeof i5.CdkScrollableModule, typeof MatTimepicker, typeof MatTimepickerInput, typeof MatTimepickerToggle]>;
  280. static ɵinj: i0.ɵɵInjectorDeclaration<MatTimepickerModule>;
  281. }
  282. export { MAT_TIMEPICKER_CONFIG, MAT_TIMEPICKER_SCROLL_STRATEGY, MatTimepicker, MatTimepickerInput, MatTimepickerModule, MatTimepickerToggle };
  283. export type { MatTimepickerConfig, MatTimepickerOption, MatTimepickerSelected };