UNPKG

23.7 kBTypeScriptView Raw
1// Generated by dts-bundle v0.7.3
2// Dependencies for this module:
3// ../../@material/base/types
4// ../../@material/base/component
5// ../../@material/base/foundation
6
7declare module '@material/slider' {
8 /**
9 * @license
10 * Copyright 2020 Google Inc.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this software and associated documentation files (the "Software"), to deal
14 * in the Software without restriction, including without limitation the rights
15 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 * copies of the Software, and to permit persons to whom the Software is
17 * furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 * THE SOFTWARE.
29 */
30 export * from '@material/slider/adapter';
31 export * from '@material/slider/component';
32 export * from '@material/slider/constants';
33 export * from '@material/slider/foundation';
34 export * from '@material/slider/types';
35}
36
37declare module '@material/slider/adapter' {
38 /**
39 * @license
40 * Copyright 2020 Google Inc.
41 *
42 * Permission is hereby granted, free of charge, to any person obtaining a copy
43 * of this software and associated documentation files (the "Software"), to deal
44 * in the Software without restriction, including without limitation the rights
45 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46 * copies of the Software, and to permit persons to whom the Software is
47 * furnished to do so, subject to the following conditions:
48 *
49 * The above copyright notice and this permission notice shall be included in
50 * all copies or substantial portions of the Software.
51 *
52 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58 * THE SOFTWARE.
59 */
60 import { EventType, SpecificEventListener } from '@material/base/types';
61 import { Thumb, TickMark } from '@material/slider/types';
62 /**
63 * Defines the shape of the adapter expected by the foundation.
64 * Implement this adapter for your framework of choice to delegate updates to
65 * the component in your framework of choice. See architecture documentation
66 * for more details.
67 * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
68 */
69 export interface MDCSliderAdapter {
70 /**
71 * @return Returns true if the slider root element has the given class.
72 */
73 hasClass(className: string): boolean;
74 /**
75 * Adds the given class to the slider root element.
76 */
77 addClass(className: string): void;
78 /**
79 * Removes the given class from the slider root element.
80 */
81 removeClass(className: string): void;
82 /**
83 * @return Returns the given attribute value on the slider root element.
84 */
85 getAttribute(attribute: string): string | null;
86 /**
87 * Adds the class to the given thumb element.
88 */
89 addThumbClass(className: string, thumb: Thumb): void;
90 /**
91 * Removes the class from the given thumb element.
92 */
93 removeThumbClass(className: string, thumb: Thumb): void;
94 /**
95 * - If thumb is `Thumb.START`, returns the value property on the start input
96 * (for range slider variant).
97 * - If thumb is `Thumb.END`, returns the value property on the end input (or
98 * only input for single point slider).
99 */
100 getInputValue(thumb: Thumb): string;
101 /**
102 * - If thumb is `Thumb.START`, sets the value property on the start input
103 * (for range slider variant).
104 * - If thumb is `Thumb.END`, sets the value property on the end input (or
105 * only input for single point slider).
106 */
107 setInputValue(value: string, thumb: Thumb): void;
108 /**
109 * - If thumb is `Thumb.START`, returns the attribute value on the start input
110 * (for range slider variant).
111 * - If thumb is `Thumb.END`, returns the attribute value on the end input (or
112 * only input for single point slider).
113 */
114 getInputAttribute(attribute: string, thumb: Thumb): string | null;
115 /**
116 * - If thumb is `Thumb.START`, sets the attribute on the start input
117 * (for range slider variant).
118 * - If thumb is `Thumb.END`, sets the attribute on the end input (or
119 * only input for single point slider).
120 */
121 setInputAttribute(attribute: string, value: string, thumb: Thumb): void;
122 /**
123 * - If thumb is `Thumb.START`, removes the attribute on the start input
124 * (for range slider variant).
125 * - If thumb is `Thumb.END`, removes the attribute on the end input (or
126 * only input for single point slider).
127 */
128 removeInputAttribute(attribute: string, thumb: Thumb): void;
129 /**
130 * - If thumb is `Thumb.START`, focuses start input (range slider variant).
131 * - If thumb is `Thumb.END`, focuses end input (or only input for single
132 * point slider).
133 */
134 focusInput(thumb: Thumb): void;
135 /**
136 * @return Returns true if the given input is focused.
137 */
138 isInputFocused(thumb: Thumb): boolean;
139 /**
140 * @return Returns the width of the given thumb knob.
141 */
142 getThumbKnobWidth(thumb: Thumb): number;
143 /**
144 * @return Returns the bounding client rect of the given thumb.
145 */
146 getThumbBoundingClientRect(thumb: Thumb): ClientRect;
147 /**
148 * @return Returns the bounding client rect for the slider root element.
149 */
150 getBoundingClientRect(): ClientRect;
151 /**
152 * @return Returns true if the root element is RTL, otherwise false
153 */
154 isRTL(): boolean;
155 /**
156 * Sets a style property of the thumb element to the passed value.
157 * - If thumb is `Thumb.START`, sets style on the start thumb (for
158 * range slider variant).
159 * - If thumb is `Thumb.END`, sets style on the end thumb (or only thumb
160 * for single point slider).
161 */
162 setThumbStyleProperty(propertyName: string, value: string, thumb: Thumb): void;
163 /**
164 * Removes the given style property from the thumb element.
165 * - If thumb is `Thumb.START`, removes style from the start thumb (for
166 * range slider variant).
167 * - If thumb is `Thumb.END`, removes style from the end thumb (or only thumb
168 * for single point slider).
169 */
170 removeThumbStyleProperty(propertyName: string, thumb: Thumb): void;
171 /**
172 * Sets a style property of the active track element to the passed value.
173 */
174 setTrackActiveStyleProperty(propertyName: string, value: string): void;
175 /**
176 * Removes the given style property from the active track element.
177 */
178 removeTrackActiveStyleProperty(propertyName: string): void;
179 /**
180 * Sets value indicator text based on the given value.
181 * - If thumb is `Thumb.START`, updates value indicator on start thumb
182 * (for range slider variant).
183 * - If thumb is `Thumb.END`, updates value indicator on end thumb (or
184 * only thumb for single point slider).
185 */
186 setValueIndicatorText(value: number, thumb: Thumb): void;
187 /**
188 * Returns a function that maps the slider value to the value of the
189 * `aria-valuetext` attribute on the thumb element. If null, the
190 * `aria-valuetext` attribute is unchanged when the value changes.
191 */
192 getValueToAriaValueTextFn(): ((value: number) => string) | null;
193 /**
194 * Updates tick marks container element with tick mark elements and their
195 * active/inactive classes, based on the given mappings:
196 * - TickMark.ACTIVE => `cssClasses.TICK_MARK_ACTIVE`
197 * - TickMark.INACTIVE => `cssClasses.TICK_MARK_INACTIVE`
198 */
199 updateTickMarks(tickMarks: TickMark[]): void;
200 /**
201 * Sets pointer capture on the slider root.
202 * https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture
203 */
204 setPointerCapture(pointerId: number): void;
205 /**
206 * Emits a `change` event from the slider root, indicating that the value
207 * has been changed and committed on the given thumb, from a user event.
208 * Mirrors the native `change` event:
209 * https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event
210 */
211 emitChangeEvent(value: number, thumb: Thumb): void;
212 /**
213 * Emits an `input` event from the slider root, indicating that the value
214 * has been changed on the given thumb, from a user event.
215 * Mirrors the native `input` event:
216 * https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event
217 */
218 emitInputEvent(value: number, thumb: Thumb): void;
219 /**
220 * Emits an event on drag start, containing the current value on the
221 * thumb being dragged.
222 */
223 emitDragStartEvent(value: number, thumb: Thumb): void;
224 /**
225 * Emits an event on drag end, containing the final value on the
226 * thumb that was dragged.
227 */
228 emitDragEndEvent(value: number, thumb: Thumb): void;
229 /**
230 * Registers an event listener on the root element.
231 */
232 registerEventHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
233 /**
234 * Deregisters an event listener on the root element.
235 */
236 deregisterEventHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
237 /**
238 * Registers an event listener on the given thumb element.
239 */
240 registerThumbEventHandler<K extends EventType>(thumb: Thumb, evtType: K, handler: SpecificEventListener<K>): void;
241 /**
242 * Deregisters an event listener on the given thumb element.
243 */
244 deregisterThumbEventHandler<K extends EventType>(thumb: Thumb, evtType: K, handler: SpecificEventListener<K>): void;
245 /**
246 * Registers an event listener on the given input element.
247 */
248 registerInputEventHandler<K extends EventType>(thumb: Thumb, evtType: K, handler: SpecificEventListener<K>): void;
249 /**
250 * Deregisters an event listener on the given input element.
251 */
252 deregisterInputEventHandler<K extends EventType>(thumb: Thumb, evtType: K, handler: SpecificEventListener<K>): void;
253 /**
254 * Registers an event listener on the body element.
255 */
256 registerBodyEventHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
257 /**
258 * Deregisters an event listener on the body element.
259 */
260 deregisterBodyEventHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
261 /**
262 * Registers an event listener on the window.
263 */
264 registerWindowEventHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
265 /**
266 * Deregisters an event listener on the window.
267 */
268 deregisterWindowEventHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
269 }
270}
271
272declare module '@material/slider/component' {
273 /**
274 * @license
275 * Copyright 2020 Google Inc.
276 *
277 * Permission is hereby granted, free of charge, to any person obtaining a copy
278 * of this software and associated documentation files (the "Software"), to deal
279 * in the Software without restriction, including without limitation the rights
280 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
281 * copies of the Software, and to permit persons to whom the Software is
282 * furnished to do so, subject to the following conditions:
283 *
284 * The above copyright notice and this permission notice shall be included in
285 * all copies or substantial portions of the Software.
286 *
287 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
288 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
289 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
290 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
291 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
292 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
293 * THE SOFTWARE.
294 */
295 import { MDCComponent } from '@material/base/component';
296 import { MDCSliderFoundation } from '@material/slider/foundation';
297 /** Vanilla JS implementation of slider component. */
298 export class MDCSlider extends MDCComponent<MDCSliderFoundation> {
299 static attachTo(root: Element, options?: {
300 skipInitialUIUpdate?: boolean;
301 }): MDCSlider;
302 root: HTMLElement;
303 getDefaultFoundation(): MDCSliderFoundation;
304 /**
305 * Initializes component, with the following options:
306 * - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
307 * syncing with the DOM. This should be enabled when the slider position
308 * is set before component initialization.
309 */
310 initialize({ skipInitialUIUpdate }?: {
311 skipInitialUIUpdate?: boolean;
312 }): void;
313 initialSyncWithDOM(): void;
314 /** Redraws UI based on DOM (e.g. element dimensions, RTL). */
315 layout(): void;
316 getValueStart(): number;
317 setValueStart(valueStart: number): void;
318 getValue(): number;
319 setValue(value: number): void;
320 /** @return Slider disabled state. */
321 getDisabled(): boolean;
322 /** Sets slider disabled state. */
323 setDisabled(disabled: boolean): void;
324 /**
325 * Sets a function that maps the slider value to the value of the
326 * `aria-valuetext` attribute on the thumb element.
327 */
328 setValueToAriaValueTextFn(mapFn: ((value: number) => string) | null): void;
329 }
330}
331
332declare module '@material/slider/constants' {
333 /** Slider element classes. */
334 export const cssClasses: {
335 DISABLED: string;
336 DISCRETE: string;
337 INPUT: string;
338 RANGE: string;
339 THUMB: string;
340 THUMB_FOCUSED: string;
341 THUMB_KNOB: string;
342 THUMB_TOP: string;
343 THUMB_WITH_INDICATOR: string;
344 TICK_MARKS: string;
345 TICK_MARKS_CONTAINER: string;
346 TICK_MARK_ACTIVE: string;
347 TICK_MARK_INACTIVE: string;
348 TRACK: string;
349 TRACK_ACTIVE: string;
350 VALUE_INDICATOR_TEXT: string;
351 };
352 /** Slider numbers. */
353 export const numbers: {
354 STEP_SIZE: number;
355 THUMB_UPDATE_MIN_PX: number;
356 };
357 /** Slider attributes. */
358 export const attributes: {
359 ARIA_VALUETEXT: string;
360 INPUT_DISABLED: string;
361 INPUT_MIN: string;
362 INPUT_MAX: string;
363 INPUT_VALUE: string;
364 INPUT_STEP: string;
365 };
366 /** Slider events. */
367 export const events: {
368 CHANGE: string;
369 INPUT: string;
370 };
371}
372
373declare module '@material/slider/foundation' {
374 /**
375 * @license
376 * Copyright 2020 Google Inc.
377 *
378 * Permission is hereby granted, free of charge, to any person obtaining a copy
379 * of this software and associated documentation files (the "Software"), to deal
380 * in the Software without restriction, including without limitation the rights
381 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
382 * copies of the Software, and to permit persons to whom the Software is
383 * furnished to do so, subject to the following conditions:
384 *
385 * The above copyright notice and this permission notice shall be included in
386 * all copies or substantial portions of the Software.
387 *
388 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
389 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
390 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
391 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
392 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
393 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
394 * THE SOFTWARE.
395 */
396 import { MDCFoundation } from '@material/base/foundation';
397 import { MDCSliderAdapter } from '@material/slider/adapter';
398 import { Thumb } from '@material/slider/types';
399 /**
400 * Foundation class for slider. Responsibilities include:
401 * - Updating slider values (internal state and DOM updates) based on client
402 * 'x' position.
403 * - Updating DOM after slider property updates (e.g. min, max).
404 */
405 export class MDCSliderFoundation extends MDCFoundation<MDCSliderAdapter> {
406 static SUPPORTS_POINTER_EVENTS: boolean;
407 constructor(adapter?: Partial<MDCSliderAdapter>);
408 static get defaultAdapter(): MDCSliderAdapter;
409 init(): void;
410 destroy(): void;
411 getMin(): number;
412 getMax(): number;
413 /**
414 * - For single point sliders, returns the thumb value.
415 * - For range (two-thumb) sliders, returns the end thumb's value.
416 */
417 getValue(): number;
418 /**
419 * - For single point sliders, sets the thumb value.
420 * - For range (two-thumb) sliders, sets the end thumb's value.
421 */
422 setValue(value: number): void;
423 /**
424 * Only applicable for range sliders.
425 * @return The start thumb's value.
426 */
427 getValueStart(): number;
428 /**
429 * Only applicable for range sliders. Sets the start thumb's value.
430 */
431 setValueStart(valueStart: number): void;
432 getStep(): number;
433 getDisabled(): boolean;
434 /**
435 * Sets disabled state, including updating styles and thumb tabindex.
436 */
437 setDisabled(disabled: boolean): void;
438 /** @return Whether the slider is a range slider. */
439 getIsRange(): boolean;
440 /**
441 * - Syncs slider boundingClientRect with the current DOM.
442 * - Updates UI based on internal state.
443 */
444 layout({ skipUpdateUI }?: {
445 skipUpdateUI?: boolean;
446 }): void;
447 /** Handles resize events on the window. */
448 handleResize(): void;
449 /**
450 * Handles pointer down events on the slider root element.
451 */
452 handleDown(event: PointerEvent | MouseEvent | TouchEvent): void;
453 /**
454 * Handles pointer move events on the slider root element.
455 */
456 handleMove(event: PointerEvent | MouseEvent | TouchEvent): void;
457 /**
458 * Handles pointer up events on the slider root element.
459 */
460 handleUp(): void;
461 /**
462 * For range, discrete slider, shows the value indicator on both thumbs.
463 */
464 handleThumbMouseenter(): void;
465 /**
466 * For range, discrete slider, hides the value indicator on both thumbs.
467 */
468 handleThumbMouseleave(): void;
469 handleMousedownOrTouchstart(event: MouseEvent | TouchEvent): void;
470 handlePointerdown(event: PointerEvent): void;
471 /**
472 * Handles input `change` event by setting internal slider value to match
473 * input's new value.
474 */
475 handleInputChange(thumb: Thumb): void;
476 /** Shows activated state and value indicator on thumb(s). */
477 handleInputFocus(thumb: Thumb): void;
478 /** Removes activated state and value indicator from thumb(s). */
479 handleInputBlur(thumb: Thumb): void;
480 }
481}
482
483declare module '@material/slider/types' {
484 /** Tick mark enum, for discrete sliders. */
485 export enum TickMark {
486 ACTIVE = 0,
487 INACTIVE = 1
488 }
489 /**
490 * Thumb types: range slider has two thumbs (START, END) whereas single point
491 * slider only has one thumb (END).
492 */
493 export enum Thumb {
494 START = 1,
495 END = 2
496 }
497 /** Interface for `detail` of slider custom change and input events. */
498 export interface MDCSliderChangeEventDetail {
499 value: number;
500 thumb: Thumb;
501 }
502}
503
504
\No newline at end of file