UNPKG

igniteui-webcomponents

Version:

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.

73 lines 2.93 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { property } from 'lit/decorators.js'; import { registerComponent } from '../common/definitions/register.js'; import { EventEmitterMixin } from '../common/mixins/event-emitter.js'; import { FormAssociatedMixin } from '../common/mixins/forms/associated.js'; import { createFormValueState, defaultNumberTransformers, } from '../common/mixins/forms/form-value.js'; import { asNumber, asPercent, clamp } from '../common/util.js'; import { IgcSliderBaseComponent } from './slider-base.js'; import IgcSliderLabelComponent from './slider-label.js'; class IgcSliderComponent extends FormAssociatedMixin(EventEmitterMixin(IgcSliderBaseComponent)) { static register() { registerComponent(IgcSliderComponent, IgcSliderLabelComponent); } set value(value) { this._formValue.setValueAndFormState(this.validateValue(asNumber(value, this._formValue.value))); } get value() { return this._formValue.value; } get activeValue() { return this.value; } constructor() { super(); this._formValue = createFormValueState(this, { initialValue: 0, transformers: defaultNumberTransformers, }); } normalizeValue() { this.value = this.validateValue(this.value); } getTrackStyle() { return { width: `${asPercent(this.value - this.min, this.distance)}%`, }; } updateValue(increment) { const value = clamp(this.value + increment, this.lowerBound, this.upperBound); if (this.value === value) { return false; } this.value = value; this.emitInputEvent(); return true; } emitInputEvent() { this.emitEvent('igcInput', { detail: this.value }); } emitChangeEvent() { this.emitEvent('igcChange', { detail: this.value }); } stepUp(stepIncrement = 1) { this.value = this.value + stepIncrement * this.step; } stepDown(stepDecrement = 1) { this.value = this.value - stepDecrement * this.step; } renderThumbs() { return this.renderThumb(this.value, this.ariaLabel); } } IgcSliderComponent.tagName = 'igc-slider'; export default IgcSliderComponent; __decorate([ property({ type: Number }) ], IgcSliderComponent.prototype, "value", null); //# sourceMappingURL=slider.js.map