igniteui-angular
Version:
Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps
639 lines (638 loc) • 21.3 kB
TypeScript
import { AfterContentInit, AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, OnInit, Renderer2, SimpleChanges, TemplateRef } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { Subject } from 'rxjs';
import { EditorProvider } from '../core/edit-provider';
import { IgxDirectionality } from '../services/direction/directionality';
import { IgxSliderType, IRangeSliderValue, ISliderValueChangeEventArgs, TickLabelsOrientation, TicksOrientation } from './slider.common';
import { IgxSliderThumbComponent } from './thumb/thumb-slider.component';
import * as i0 from "@angular/core";
/**
* **Ignite UI for Angular Slider** -
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/slider/slider)
*
* The Ignite UI Slider allows selection in a given range by moving the thumb along the track. The track
* can be defined as continuous or stepped, and you can choose between single and range slider types.
*
* Example:
* ```html
* <igx-slider id="slider"
* [minValue]="0" [maxValue]="100"
* [continuous]=true [(ngModel)]="volume">
* </igx-slider>
* ```
*/
export declare class IgxSliderComponent implements ControlValueAccessor, EditorProvider, OnInit, AfterViewInit, AfterContentInit, OnChanges, OnDestroy {
private renderer;
private _el;
private _cdr;
private _ngZone;
private _dir;
/**
* @hidden
*/
get thumbFrom(): IgxSliderThumbComponent;
/**
* @hidden
*/
get thumbTo(): IgxSliderThumbComponent;
private get labelFrom();
private get labelTo();
/**
* @hidden
*/
trackRef: ElementRef;
/**
* @hidden
*/
thumbFromTemplateRef: TemplateRef<any>;
/**
* @hidden
*/
thumbToTemplateRef: TemplateRef<any>;
/**
* @hidden
*/
tickLabelTemplateRef: TemplateRef<any>;
/**
* @hidden
*/
slierClass: boolean;
/**
* Sets the value of the `id` attribute.
* If not provided it will be automatically generated.
* ```html
* <igx-slider [id]="'igx-slider-32'" [(ngModel)]="task.percentCompleted" [step]="5" [lowerBound]="20">
* ```
*/
id: string;
/**
* Sets the duration visibility of thumbs labels. The default value is 750 milliseconds.
* ```html
* <igx-slider #slider [thumbLabelVisibilityDuration]="3000" [(ngModel)]="task.percentCompleted" [step]="5">
* ```
*/
thumbLabelVisibilityDuration: number;
/**
* @hidden
*/
get disabledClass(): boolean;
/**
* Gets the type of the `IgxSliderComponent`.
* The slider can be IgxSliderType.SLIDER(default) or IgxSliderType.RANGE.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let type = this.slider.type;
* }
*/
get type(): IgxSliderType;
/**
* Sets the type of the `IgxSliderComponent`.
* The slider can be IgxSliderType.SLIDER(default) or IgxSliderType.RANGE.
* ```typescript
* sliderType: IgxSliderType = IgxSliderType.RANGE;
* ```
* ```html
* <igx-slider #slider2 [type]="sliderType" [(ngModel)]="rangeValue" [minValue]="0" [maxValue]="100">
* ```
*/
set type(type: IgxSliderType);
/**
* Enables `labelView`, by accepting a collection of primitive values with more than one element.
* Each element will be equally spread over the slider and it will serve as a thumb label.
* Once the property is set, it will precendence over {@link maxValue}, {@link minValue}, {@link step}.
* This means that the manipulation for those properties won't be allowed.
*/
get labels(): Array<number | string | boolean | null | undefined>;
set labels(labels: Array<number | string | boolean | null | undefined>);
/**
* Returns the template context corresponding
* to {@link IgxThumbFromTemplateDirective} and {@link IgxThumbToTemplateDirective} templates.
*
* ```typescript
* return {
* $implicit // returns the value of the label,
* labels // returns the labels collection the user has passed.
* }
* ```
*/
get context(): any;
/**
* Sets the incremental/decremental step of the value when dragging the thumb.
* The default step is 1, and step should not be less or equal than 0.
* ```html
* <igx-slider #slider [(ngModel)]="task.percentCompleted" [step]="5">
* ```
*/
set step(step: number);
/**
* Returns the incremental/decremental dragging step of the {@link IgxSliderComponent}.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let step = this.slider.step;
* }
* ```
*/
get step(): number;
/**
* Returns if the {@link IgxSliderComponent} is disabled.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let isDisabled = this.slider.disabled;
* }
* ```
*/
get disabled(): boolean;
/**
* Disables the component.
* ```html
* <igx-slider #slider [disabled]="true" [(ngModel)]="task.percentCompleted" [step]="5" [lowerBound]="20">
* ```
*/
set disabled(disable: boolean);
/**
* Returns if the {@link IgxSliderComponent} is set as continuous.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let continuous = this.slider.continuous;
* }
* ```
*/
get continuous(): boolean;
/**
* Sets the {@link IgxSliderComponent} as continuous.
* By default is considered that the {@link IgxSliderComponent} is discrete.
* Discrete {@link IgxSliderComponent} slider has step indicators over the track and visible thumb labels during interaction.
* Continuous {@link IgxSliderComponent} does not have ticks and does not show bubble labels for values.
* ```html
* <igx-slider #slider [continuous]="'true'" [(ngModel)]="task.percentCompleted" [step]="5" [lowerBound]="20">
* ```
*/
set continuous(continuous: boolean);
/**
* Returns the minimal displayed track value of the `IgxSliderComponent`.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let sliderMin = this.slider.minValue;
* }
* ```
*/
get minValue(): number;
/**
* Sets the minimal displayed track value for the `IgxSliderComponent`.
* The default minimal value is 0.
* ```html
* <igx-slider [type]="sliderType" [minValue]="56" [maxValue]="100">
* ```
*/
set minValue(value: number);
/**
* Returns the maximum displayed track value for the {@link IgxSliderComponent}.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let sliderMax = this.slider.maxValue;
* }
* ```
*/
get maxValue(): number;
/**
* Sets the maximal displayed track value for the `IgxSliderComponent`.
* The default maximum value is 100.
* ```html
* <igx-slider [type]="sliderType" [minValue]="56" [maxValue]="256">
* ```
*/
set maxValue(value: number);
/**
* Returns the lower boundary of settable values of the `IgxSliderComponent`.
* If not set, will return `minValue`.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let sliderLowBound = this.slider.lowerBound;
* }
* ```
*/
get lowerBound(): number;
/**
* Sets the lower boundary of settable values of the `IgxSliderComponent`.
* If not set is the same as min value.
* ```html
* <igx-slider [step]="5" [lowerBound]="20">
* ```
*/
set lowerBound(value: number);
/**
* Returns the upper boundary of settable values of the `IgxSliderComponent`.
* If not set, will return `maxValue`
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let sliderUpBound = this.slider.upperBound;
* }
* ```
*/
get upperBound(): number;
/**
* Sets the upper boundary of the `IgxSliderComponent`.
* If not set is the same as max value.
* ```html
* <igx-slider [step]="5" [upperBound]="20">
* ```
*/
set upperBound(value: number);
/**
* Returns the slider value. If the slider is of type {@link IgxSliderType.SLIDER} the returned value is number.
* If the slider type is {@link IgxSliderType.RANGE}.
* The returned value represents an object of {@link lowerValue} and {@link upperValue}.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* public sliderValue(event){
* let sliderVal = this.slider.value;
* }
* ```
*/
get value(): number | IRangeSliderValue;
/**
* Sets the slider value.
* If the slider is of type {@link IgxSliderType.SLIDER}.
* The argument is number. By default the {@link value} gets the {@link lowerBound}.
* If the slider type is {@link IgxSliderType.RANGE} the argument
* represents an object of {@link lowerValue} and {@link upperValue} properties.
* By default the object is associated with the {@link lowerBound} and {@link upperBound} property values.
* ```typescript
* rangeValue = {
* lower: 30,
* upper: 60
* };
* ```
* ```html
* <igx-slider [type]="sliderType" [(ngModel)]="rangeValue" [minValue]="56" [maxValue]="256">
* ```
*/
set value(value: number | IRangeSliderValue);
/**
* Returns the number of the presented primary ticks.
* ```typescript
* const primaryTicks = this.slider.primaryTicks;
* ```
*/
get primaryTicks(): number;
/**
* Sets the number of primary ticks. If {@link @labels} is enabled, this property won't function.
* Insted enable ticks by {@link showTicks} property.
* ```typescript
* this.slider.primaryTicks = 5;
* ```
*/
set primaryTicks(val: number);
/**
* Returns the number of the presented secondary ticks.
* ```typescript
* const secondaryTicks = this.slider.secondaryTicks;
* ```
*/
get secondaryTicks(): number;
/**
* Sets the number of secondary ticks. The property functions even when {@link labels} is enabled,
* but all secondary ticks won't present any tick labels.
* ```typescript
* this.slider.secondaryTicks = 5;
* ```
*/
set secondaryTicks(val: number);
/**
* Show/hide slider ticks
* ```html
* <igx-slier [showTicks]="true" [primaryTicks]="5"></igx-slier>
* ```
*/
showTicks: boolean;
/**
* show/hide primary tick labels
* ```html
* <igx-slider [primaryTicks]="5" [primaryTickLabels]="false"></igx-slider>
* ```
*/
primaryTickLabels: boolean;
/**
* show/hide secondary tick labels
* ```html
* <igx-slider [secondaryTicks]="5" [secondaryTickLabels]="false"></igx-slider>
* ```
*/
secondaryTickLabels: boolean;
/**
* Changes ticks orientation:
* bottom - The default orienation, below the slider track.
* top - Above the slider track
* mirror - combines top and bottom orientation.
* ```html
* <igx-slider [primaryTicks]="5" [ticksOrientation]="ticksOrientation"></igx-slider>
* ```
*/
ticksOrientation: TicksOrientation;
/**
* Changes tick labels rotation:
* horizontal - The default rotation
* toptobottom - Rotates tick labels vertically to 90deg
* bottomtotop - Rotate tick labels vertically to -90deg
* ```html
* <igx-slider [primaryTicks]="5" [secondaryTicks]="3" [tickLabelsOrientation]="tickLabelsOrientaiton"></igx-slider>
* ```
*/
tickLabelsOrientation: TickLabelsOrientation;
/**
* @hidden
*/
get deactivateThumbLabel(): boolean;
/**
* This event is emitted every time the value is changed.
* ```typescript
* public change(event){
* alert("The value has been changed!");
* }
* ```
* ```html
* <igx-slider (valueChange)="change($event)" #slider [(ngModel)]="task.percentCompleted" [step]="5">
* ```
*/
valueChange: EventEmitter<ISliderValueChangeEventArgs>;
/**
* This event is emitted every time the lower value of a range slider is changed.
* ```typescript
* public change(value){
* alert(`The lower value has been changed to ${value}`);
* }
* ```
* ```html
* <igx-slider [(lowerValue)]="model.lowervalue" (lowerValueChange)="change($event)" [step]="5">
* ```
*/
lowerValueChange: EventEmitter<number>;
/**
* This event is emitted every time the upper value of a range slider is changed.
* ```typescript
* public change(value){
* alert(`The upper value has been changed to ${value}`);
* }
* ```
* ```html
* <igx-slider [(upperValue)]="model.uppervalue" (upperValueChange)="change($event)" [step]="5">
* ```
*/
upperValueChange: EventEmitter<number>;
/**
* This event is emitted at the end of every slide interaction.
* ```typescript
* public change(event){
* alert("The value has been changed!");
* }
* ```
* ```html
* <igx-slider (dragFinished)="change($event)" #slider [(ngModel)]="task.percentCompleted" [step]="5">
* ```
*/
dragFinished: EventEmitter<number | IRangeSliderValue>;
/**
* @hidden
*/
private ticks;
/**
* @hidden
*/
private thumbs;
/**
* @hidden
*/
private labelRefs;
/**
* @hidden
*/
onPan: Subject<number>;
/**
* @hidden
*/
stepDistance: number;
private _pMin;
private _pMax;
private _hasViewInit;
private _minValue;
private _maxValue;
private _lowerBound;
private _upperBound;
private _lowerValue;
private _upperValue;
private _continuous;
private _disabled;
private _step;
private _value;
private _primaryTicks;
private _secondaryTicks;
private _sliding;
private _labels;
private _type;
private _destroyer$;
private _indicatorsDestroyer$;
private _indicatorsTimer;
private _onChangeCallback;
private _onTouchedCallback;
constructor(renderer: Renderer2, _el: ElementRef, _cdr: ChangeDetectorRef, _ngZone: NgZone, _dir: IgxDirectionality);
/**
* @hidden
*/
onFocus(): void;
/**
* Returns whether the `IgxSliderComponent` type is RANGE.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* ngAfterViewInit(){
* let sliderRange = this.slider.isRange;
* }
* ```
*/
get isRange(): boolean;
/**
* Returns the lower value of a RANGE `IgxSliderComponent`.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* public lowValue(event){
* let sliderLowValue = this.slider.lowerValue;
* }
* ```
*/
get lowerValue(): number;
/**
* Sets the lower value of a RANGE `IgxSliderComponent`.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* public lowValue(event){
* this.slider.lowerValue = value;
* }
* ```
*/
set lowerValue(value: number);
/**
* Returns the upper value of a RANGE `IgxSliderComponent`.
* Returns `value` of a SLIDER `IgxSliderComponent`
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* public upperValue(event){
* let upperValue = this.slider.upperValue;
* }
* ```
*/
get upperValue(): number;
/**
* Sets the upper value of a RANGE `IgxSliderComponent`.
* ```typescript
* @ViewChild("slider2")
* public slider: IgxSliderComponent;
* public upperValue(event){
* this.slider.upperValue = value;
* }
* ```
*/
set upperValue(value: number);
/**
* Returns the value corresponding the lower label.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* let label = this.slider.lowerLabel;
* ```
*/
get lowerLabel(): string | number | boolean;
/**
* Returns the value corresponding the upper label.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* let label = this.slider.upperLabel;
* ```
*/
get upperLabel(): string | number | boolean;
/**
* Returns if label view is enabled.
* If the {@link labels} is set, the view is automatically activated.
* ```typescript
* @ViewChild("slider")
* public slider: IgxSliderComponent;
* let labelView = this.slider.labelsViewEnabled;
* ```
*/
get labelsViewEnabled(): boolean;
/**
* @hidden
*/
get showTopTicks(): boolean;
/**
* @hidden
*/
get showBottomTicks(): boolean;
/**
* @hidden
*/
ngOnChanges(changes: SimpleChanges): void;
/**
* @hidden
*/
ngOnInit(): void;
ngAfterContentInit(): void;
/**
* @hidden
*/
ngAfterViewInit(): void;
/**
* @hidden
*/
ngOnDestroy(): void;
/**
* @hidden
*/
writeValue(value: IRangeSliderValue | number): void;
/**
* @hidden
*/
registerOnChange(fn: any): void;
/**
* @hidden
*/
registerOnTouched(fn: any): void;
/** @hidden */
getEditElement(): any;
/**
*
* @hidden
*/
update(mouseX: any): void;
/**
* @hidden
*/
thumbChanged(value: number, thumbType: string): void;
/**
* @hidden
*/
onThumbChange(): void;
/**
* @hidden
*/
onHoverChange(state: boolean): void;
setValue(value: number | IRangeSliderValue, triggerChange: boolean): void;
private onPointerDown;
private onPointerMove;
private onPointerUp;
private validateInitialValue;
private findClosestThumb;
private updateLowerBoundAndMinTravelZone;
private updateUpperBoundAndMaxTravelZone;
private calculateStepDistance;
private valueInRange;
private positionHandler;
private positionHandlersAndUpdateTrack;
private closestHandle;
private setTickInterval;
private showSliderIndicators;
private hideSliderIndicators;
private toggleSliderIndicators;
private changeThumbFocusableState;
private closestTo;
private valueToFraction;
private isNullishButNotZero;
/**
* @hidden
* Normalizе the value when two-way data bind is used and {@link this.step} is set.
* @param value
*/
private normalizeByStep;
private updateTrack;
private subscribeToEvents;
private unsubscriber;
private hasValueChanged;
private emitValueChange;
static ɵfac: i0.ɵɵFactoryDeclaration<IgxSliderComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<IgxSliderComponent, "igx-slider", never, { "id": { "alias": "id"; "required": false; }; "thumbLabelVisibilityDuration": { "alias": "thumbLabelVisibilityDuration"; "required": false; }; "type": { "alias": "type"; "required": false; }; "labels": { "alias": "labels"; "required": false; }; "step": { "alias": "step"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "continuous": { "alias": "continuous"; "required": false; }; "minValue": { "alias": "minValue"; "required": false; }; "maxValue": { "alias": "maxValue"; "required": false; }; "lowerBound": { "alias": "lowerBound"; "required": false; }; "upperBound": { "alias": "upperBound"; "required": false; }; "value": { "alias": "value"; "required": false; }; "primaryTicks": { "alias": "primaryTicks"; "required": false; }; "secondaryTicks": { "alias": "secondaryTicks"; "required": false; }; "showTicks": { "alias": "showTicks"; "required": false; }; "primaryTickLabels": { "alias": "primaryTickLabels"; "required": false; }; "secondaryTickLabels": { "alias": "secondaryTickLabels"; "required": false; }; "ticksOrientation": { "alias": "ticksOrientation"; "required": false; }; "tickLabelsOrientation": { "alias": "tickLabelsOrientation"; "required": false; }; "lowerValue": { "alias": "lowerValue"; "required": false; }; "upperValue": { "alias": "upperValue"; "required": false; }; }, { "valueChange": "valueChange"; "lowerValueChange": "lowerValueChange"; "upperValueChange": "upperValueChange"; "dragFinished": "dragFinished"; }, ["thumbFromTemplateRef", "thumbToTemplateRef", "tickLabelTemplateRef"], never, true, never>;
static ngAcceptInputType_disabled: unknown;
static ngAcceptInputType_continuous: unknown;
static ngAcceptInputType_showTicks: unknown;
static ngAcceptInputType_primaryTickLabels: unknown;
static ngAcceptInputType_secondaryTickLabels: unknown;
}