index.d.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. import { _AbstractConstructor } from '@angular/material/core';
  2. import { AfterViewInit } from '@angular/core';
  3. import { BooleanInput } from '@angular/cdk/coercion';
  4. import { CanColor } from '@angular/material/core';
  5. import { CanDisable } from '@angular/material/core';
  6. import { ChangeDetectorRef } from '@angular/core';
  7. import { _Constructor } from '@angular/material/core';
  8. import { ControlValueAccessor } from '@angular/forms';
  9. import { Directionality } from '@angular/cdk/bidi';
  10. import { ElementRef } from '@angular/core';
  11. import { EventEmitter } from '@angular/core';
  12. import { FocusMonitor } from '@angular/cdk/a11y';
  13. import { HasTabIndex } from '@angular/material/core';
  14. import * as i0 from '@angular/core';
  15. import * as i2 from '@angular/common';
  16. import * as i3 from '@angular/material/core';
  17. import { NgZone } from '@angular/core';
  18. import { NumberInput } from '@angular/cdk/coercion';
  19. import { OnDestroy } from '@angular/core';
  20. declare namespace i1 {
  21. export {
  22. MAT_LEGACY_SLIDER_VALUE_ACCESSOR,
  23. MatLegacySliderChange,
  24. MatLegacySlider
  25. }
  26. }
  27. /**
  28. * Provider Expression that allows mat-slider to register as a ControlValueAccessor.
  29. * This allows it to support [(ngModel)] and [formControl].
  30. * @docs-private
  31. * @deprecated Use `MAT_SLIDER_VALUE_ACCESSOR` from `@angular/material/slider` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
  32. * @breaking-change 17.0.0
  33. */
  34. export declare const MAT_LEGACY_SLIDER_VALUE_ACCESSOR: any;
  35. /**
  36. * Allows users to select from a range of values by moving the slider thumb. It is similar in
  37. * behavior to the native `<input type="range">` element.
  38. * @deprecated Use `MatSlider` from `@angular/material/slider` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
  39. * @breaking-change 17.0.0
  40. */
  41. export declare class MatLegacySlider extends _MatSliderBase implements ControlValueAccessor, OnDestroy, CanDisable, CanColor, AfterViewInit, HasTabIndex {
  42. private _focusMonitor;
  43. private _changeDetectorRef;
  44. private _dir;
  45. private _ngZone;
  46. _animationMode?: string | undefined;
  47. /** Whether the slider is inverted. */
  48. get invert(): boolean;
  49. set invert(value: BooleanInput);
  50. private _invert;
  51. /** The maximum value that the slider can have. */
  52. get max(): number;
  53. set max(v: NumberInput);
  54. private _max;
  55. /** The minimum value that the slider can have. */
  56. get min(): number;
  57. set min(v: NumberInput);
  58. private _min;
  59. /** The values at which the thumb will snap. */
  60. get step(): number;
  61. set step(v: NumberInput);
  62. private _step;
  63. /** Whether or not to show the thumb label. */
  64. get thumbLabel(): boolean;
  65. set thumbLabel(value: BooleanInput);
  66. private _thumbLabel;
  67. /**
  68. * How often to show ticks. Relative to the step so that a tick always appears on a step.
  69. * Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values).
  70. */
  71. get tickInterval(): 'auto' | number;
  72. set tickInterval(value: 'auto' | NumberInput);
  73. private _tickInterval;
  74. /** Value of the slider. */
  75. get value(): number;
  76. set value(v: NumberInput);
  77. private _value;
  78. /**
  79. * Function that will be used to format the value before it is displayed
  80. * in the thumb label. Can be used to format very large number in order
  81. * for them to fit into the slider thumb.
  82. */
  83. displayWith: (value: number) => string | number;
  84. /** Text corresponding to the slider's value. Used primarily for improved accessibility. */
  85. valueText: string;
  86. /** Whether the slider is vertical. */
  87. get vertical(): boolean;
  88. set vertical(value: BooleanInput);
  89. private _vertical;
  90. /** Event emitted when the slider value has changed. */
  91. readonly change: EventEmitter<MatLegacySliderChange>;
  92. /** Event emitted when the slider thumb moves. */
  93. readonly input: EventEmitter<MatLegacySliderChange>;
  94. /**
  95. * Emits when the raw value of the slider changes. This is here primarily
  96. * to facilitate the two-way binding for the `value` input.
  97. * @docs-private
  98. */
  99. readonly valueChange: EventEmitter<number | null>;
  100. /** The value to be used for display purposes. */
  101. get displayValue(): string | number;
  102. /** set focus to the host element */
  103. focus(options?: FocusOptions): void;
  104. /** blur the host element */
  105. blur(): void;
  106. /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
  107. onTouched: () => any;
  108. /** The percentage of the slider that coincides with the value. */
  109. get percent(): number;
  110. private _percent;
  111. /**
  112. * Whether or not the thumb is sliding and what the user is using to slide it with.
  113. * Used to determine if there should be a transition for the thumb and fill track.
  114. */
  115. _isSliding: 'keyboard' | 'pointer' | null;
  116. /**
  117. * Whether or not the slider is active (clicked or sliding).
  118. * Used to shrink and grow the thumb as according to the Material Design spec.
  119. */
  120. _isActive: boolean;
  121. /**
  122. * Whether the axis of the slider is inverted.
  123. * (i.e. whether moving the thumb in the positive x or y direction decreases the slider's value).
  124. */
  125. _shouldInvertAxis(): boolean;
  126. /** Whether the slider is at its minimum value. */
  127. _isMinValue(): boolean;
  128. /**
  129. * The amount of space to leave between the slider thumb and the track fill & track background
  130. * elements.
  131. */
  132. _getThumbGap(): 7 | 10 | 0;
  133. /** CSS styles for the track background element. */
  134. _getTrackBackgroundStyles(): {
  135. [key: string]: string;
  136. };
  137. /** CSS styles for the track fill element. */
  138. _getTrackFillStyles(): {
  139. [key: string]: string;
  140. };
  141. /** CSS styles for the ticks container element. */
  142. _getTicksContainerStyles(): {
  143. [key: string]: string;
  144. };
  145. /** CSS styles for the ticks element. */
  146. _getTicksStyles(): {
  147. [key: string]: string;
  148. };
  149. _getThumbContainerStyles(): {
  150. [key: string]: string;
  151. };
  152. /** The size of a tick interval as a percentage of the size of the track. */
  153. private _tickIntervalPercent;
  154. /** The dimensions of the slider. */
  155. private _sliderDimensions;
  156. private _controlValueAccessorChangeFn;
  157. /** Decimal places to round to, based on the step amount. */
  158. private _roundToDecimal;
  159. /** Subscription to the Directionality change EventEmitter. */
  160. private _dirChangeSubscription;
  161. /** The value of the slider when the slide start event fires. */
  162. private _valueOnSlideStart;
  163. /** Reference to the inner slider wrapper element. */
  164. private _sliderWrapper;
  165. /**
  166. * Whether mouse events should be converted to a slider position by calculating their distance
  167. * from the right or bottom edge of the slider as opposed to the top or left.
  168. */
  169. _shouldInvertMouseCoords(): boolean;
  170. /** The language direction for this slider element. */
  171. private _getDirection;
  172. /** Keeps track of the last pointer event that was captured by the slider. */
  173. private _lastPointerEvent;
  174. /** Used to subscribe to global move and end events */
  175. protected _document: Document;
  176. /**
  177. * Identifier used to attribute a touch event to a particular slider.
  178. * Will be undefined if one of the following conditions is true:
  179. * - The user isn't dragging using a touch device.
  180. * - The browser doesn't support `Touch.identifier`.
  181. * - Dragging hasn't started yet.
  182. */
  183. private _touchId;
  184. constructor(elementRef: ElementRef, _focusMonitor: FocusMonitor, _changeDetectorRef: ChangeDetectorRef, _dir: Directionality, tabIndex: string, _ngZone: NgZone, _document: any, _animationMode?: string | undefined);
  185. ngAfterViewInit(): void;
  186. ngOnDestroy(): void;
  187. _onMouseenter(): void;
  188. _onFocus(): void;
  189. _onBlur(): void;
  190. _onKeydown(event: KeyboardEvent): void;
  191. _onKeyup(): void;
  192. /** Called when the user has put their pointer down on the slider. */
  193. private _pointerDown;
  194. /**
  195. * Called when the user has moved their pointer after
  196. * starting to drag. Bound on the document level.
  197. */
  198. private _pointerMove;
  199. /** Called when the user has lifted their pointer. Bound on the document level. */
  200. private _pointerUp;
  201. /** Called when the window has lost focus. */
  202. private _windowBlur;
  203. /** Use defaultView of injected document if available or fallback to global window reference */
  204. private _getWindow;
  205. /**
  206. * Binds our global move and end events. They're bound at the document level and only while
  207. * dragging so that the user doesn't have to keep their pointer exactly over the slider
  208. * as they're swiping across the screen.
  209. */
  210. private _bindGlobalEvents;
  211. /** Removes any global event listeners that we may have added. */
  212. private _removeGlobalEvents;
  213. /** Increments the slider by the given number of steps (negative number decrements). */
  214. private _increment;
  215. /** Calculate the new value from the new physical location. The value will always be snapped. */
  216. private _updateValueFromPosition;
  217. /** Emits a change event if the current value is different from the last emitted value. */
  218. private _emitChangeEvent;
  219. /** Emits an input event when the current value is different from the last emitted value. */
  220. private _emitInputEvent;
  221. /** Updates the amount of space between ticks as a percentage of the width of the slider. */
  222. private _updateTickIntervalPercent;
  223. /** Creates a slider change object from the specified value. */
  224. private _createChangeEvent;
  225. /** Calculates the percentage of the slider that a value is. */
  226. private _calculatePercentage;
  227. /** Calculates the value a percentage of the slider corresponds to. */
  228. private _calculateValue;
  229. /** Return a number between two numbers. */
  230. private _clamp;
  231. /**
  232. * Get the bounding client rect of the slider track element.
  233. * The track is used rather than the native element to ignore the extra space that the thumb can
  234. * take up.
  235. */
  236. private _getSliderDimensions;
  237. /**
  238. * Focuses the native element.
  239. * Currently only used to allow a blur event to fire but will be used with keyboard input later.
  240. */
  241. private _focusHostElement;
  242. /** Blurs the native element. */
  243. private _blurHostElement;
  244. /**
  245. * Sets the model value. Implemented as part of ControlValueAccessor.
  246. * @param value
  247. */
  248. writeValue(value: any): void;
  249. /**
  250. * Registers a callback to be triggered when the value has changed.
  251. * Implemented as part of ControlValueAccessor.
  252. * @param fn Callback to be registered.
  253. */
  254. registerOnChange(fn: (value: any) => void): void;
  255. /**
  256. * Registers a callback to be triggered when the component is touched.
  257. * Implemented as part of ControlValueAccessor.
  258. * @param fn Callback to be registered.
  259. */
  260. registerOnTouched(fn: any): void;
  261. /**
  262. * Sets whether the component should be disabled.
  263. * Implemented as part of ControlValueAccessor.
  264. * @param isDisabled
  265. */
  266. setDisabledState(isDisabled: boolean): void;
  267. static ɵfac: i0.ɵɵFactoryDeclaration<MatLegacySlider, [null, null, null, { optional: true; }, { attribute: "tabindex"; }, null, null, { optional: true; }]>;
  268. static ɵcmp: i0.ɵɵComponentDeclaration<MatLegacySlider, "mat-slider", ["matSlider"], { "disabled": { "alias": "disabled"; "required": false; }; "color": { "alias": "color"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "invert": { "alias": "invert"; "required": false; }; "max": { "alias": "max"; "required": false; }; "min": { "alias": "min"; "required": false; }; "step": { "alias": "step"; "required": false; }; "thumbLabel": { "alias": "thumbLabel"; "required": false; }; "tickInterval": { "alias": "tickInterval"; "required": false; }; "value": { "alias": "value"; "required": false; }; "displayWith": { "alias": "displayWith"; "required": false; }; "valueText": { "alias": "valueText"; "required": false; }; "vertical": { "alias": "vertical"; "required": false; }; }, { "change": "change"; "input": "input"; "valueChange": "valueChange"; }, never, never, false, never>;
  269. }
  270. /**
  271. * A simple change event emitted by the MatSlider component.
  272. * @deprecated Use `MatSliderChange` from `@angular/material/slider` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
  273. * @breaking-change 17.0.0
  274. */
  275. export declare class MatLegacySliderChange {
  276. /** The MatSlider that changed. */
  277. source: MatLegacySlider;
  278. /** The new value of the source slider. */
  279. value: number | null;
  280. }
  281. /**
  282. * @deprecated Use `MatSliderModule` from `@angular/material/slider` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
  283. * @breaking-change 17.0.0
  284. */
  285. export declare class MatLegacySliderModule {
  286. static ɵfac: i0.ɵɵFactoryDeclaration<MatLegacySliderModule, never>;
  287. static ɵmod: i0.ɵɵNgModuleDeclaration<MatLegacySliderModule, [typeof i1.MatLegacySlider], [typeof i2.CommonModule, typeof i3.MatCommonModule], [typeof i1.MatLegacySlider, typeof i3.MatCommonModule]>;
  288. static ɵinj: i0.ɵɵInjectorDeclaration<MatLegacySliderModule>;
  289. }
  290. /** @docs-private */
  291. declare const _MatSliderBase: _Constructor<HasTabIndex> & _AbstractConstructor<HasTabIndex> & _Constructor<CanColor> & _AbstractConstructor<CanColor> & _Constructor<CanDisable> & _AbstractConstructor<CanDisable> & {
  292. new (_elementRef: ElementRef): {
  293. _elementRef: ElementRef;
  294. };
  295. };
  296. export { }