import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, forwardRef, Output, EventEmitter } from '@angular/core'; import { CommonModule } from '@angular/common'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import * as i0 from "@angular/core"; import * as i1 from "@angular/common"; export const KNOB_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => Knob), multi: true }; export class Knob { constructor(cd, el) { this.cd = cd; this.el = el; this.valueColor = "var(--primary-color, Black)"; this.rangeColor = "var(--surface-d, LightGray)"; this.textColor = "var(--text-color-secondary, Black)"; this.valueTemplate = "{value}"; this.size = 100; this.step = 1; this.min = 0; this.max = 100; this.strokeWidth = 14; this.showValue = true; this.readonly = false; this.onChange = new EventEmitter(); this.radius = 40; this.midX = 50; this.midY = 50; this.minRadians = 4 * Math.PI / 3; this.maxRadians = -Math.PI / 3; this.value = null; this.onModelChange = () => { }; this.onModelTouched = () => { }; } mapRange(x, inMin, inMax, outMin, outMax) { return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; } onClick(event) { if (!this.disabled && !this.readonly) { this.updateValue(event.offsetX, event.offsetY); } } updateValue(offsetX, offsetY) { let dx = offsetX - this.size / 2; let dy = this.size / 2 - offsetY; let angle = Math.atan2(dy, dx); let start = -Math.PI / 2 - Math.PI / 6; this.updateModel(angle, start); } updateModel(angle, start) { let mappedValue; if (angle > this.maxRadians) mappedValue = this.mapRange(angle, this.minRadians, this.maxRadians, this.min, this.max); else if (angle < start) mappedValue = this.mapRange(angle + 2 * Math.PI, this.minRadians, this.maxRadians, this.min, this.max); else return; let newValue = Math.round((mappedValue - this.min) / this.step) * this.step + this.min; this.value = newValue; this.onModelChange(this.value); this.onChange.emit(this.value); } onMouseDown(event) { if (!this.disabled && !this.readonly) { this.windowMouseMoveListener = this.onMouseMove.bind(this); this.windowMouseUpListener = this.onMouseUp.bind(this); window.addEventListener('mousemove', this.windowMouseMoveListener); window.addEventListener('mouseup', this.windowMouseUpListener); event.preventDefault(); } } onMouseUp(event) { if (!this.disabled && !this.readonly) { window.removeEventListener('mousemove', this.windowMouseMoveListener); window.removeEventListener('mouseup', this.windowMouseUpListener); this.windowMouseUpListener = null; this.windowMouseMoveListener = null; event.preventDefault(); } } onTouchStart(event) { if (!this.disabled && !this.readonly) { this.windowTouchMoveListener = this.onTouchMove.bind(this); this.windowTouchEndListener = this.onTouchEnd.bind(this); window.addEventListener('touchmove', this.windowTouchMoveListener); window.addEventListener('touchend', this.windowTouchEndListener); event.preventDefault(); } } onTouchEnd(event) { if (!this.disabled && !this.readonly) { window.removeEventListener('touchmove', this.windowTouchMoveListener); window.removeEventListener('touchend', this.windowTouchEndListener); this.windowTouchMoveListener = null; this.windowTouchEndListener = null; event.preventDefault(); } } onMouseMove(event) { if (!this.disabled && !this.readonly) { this.updateValue(event.offsetX, event.offsetY); event.preventDefault(); } } onTouchMove(event) { if (!this.disabled && !this.readonly && event.touches.length == 1) { const rect = this.el.nativeElement.children[0].getBoundingClientRect(); const touch = event.targetTouches.item(0); const offsetX = touch.clientX - rect.left; const offsetY = touch.clientY - rect.top; this.updateValue(offsetX, offsetY); } } writeValue(value) { this.value = value; this.cd.markForCheck(); } registerOnChange(fn) { this.onModelChange = fn; } registerOnTouched(fn) { this.onModelTouched = fn; } setDisabledState(val) { this.disabled = val; this.cd.markForCheck(); } containerClass() { return { 'p-knob p-component': true, 'p-disabled': this.disabled }; } rangePath() { return `M ${this.minX()} ${this.minY()} A ${this.radius} ${this.radius} 0 1 1 ${this.maxX()} ${this.maxY()}`; } valuePath() { return `M ${this.zeroX()} ${this.zeroY()} A ${this.radius} ${this.radius} 0 ${this.largeArc()} ${this.sweep()} ${this.valueX()} ${this.valueY()}`; } zeroRadians() { if (this.min > 0 && this.max > 0) return this.mapRange(this.min, this.min, this.max, this.minRadians, this.maxRadians); else return this.mapRange(0, this.min, this.max, this.minRadians, this.maxRadians); } valueRadians() { return this.mapRange(this._value, this.min, this.max, this.minRadians, this.maxRadians); } minX() { return this.midX + Math.cos(this.minRadians) * this.radius; } minY() { return this.midY - Math.sin(this.minRadians) * this.radius; } maxX() { return this.midX + Math.cos(this.maxRadians) * this.radius; } maxY() { return this.midY - Math.sin(this.maxRadians) * this.radius; } zeroX() { return this.midX + Math.cos(this.zeroRadians()) * this.radius; } zeroY() { return this.midY - Math.sin(this.zeroRadians()) * this.radius; } valueX() { return this.midX + Math.cos(this.valueRadians()) * this.radius; } valueY() { return this.midY - Math.sin(this.valueRadians()) * this.radius; } largeArc() { return Math.abs(this.zeroRadians() - this.valueRadians()) < Math.PI ? 0 : 1; } sweep() { return this.valueRadians() > this.zeroRadians() ? 0 : 1; } valueToDisplay() { return this.valueTemplate.replace("{value}", this._value.toString()); } get _value() { return this.value != null ? this.value : this.min; } } Knob.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Knob, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); Knob.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Knob, selector: "p-knob", inputs: { styleClass: "styleClass", style: "style", severity: "severity", valueColor: "valueColor", rangeColor: "rangeColor", textColor: "textColor", valueTemplate: "valueTemplate", name: "name", size: "size", step: "step", min: "min", max: "max", strokeWidth: "strokeWidth", disabled: "disabled", showValue: "showValue", readonly: "readonly" }, outputs: { onChange: "onChange" }, host: { classAttribute: "p-element" }, providers: [KNOB_VALUE_ACCESSOR], ngImport: i0, template: `
{{valueToDisplay()}}
`, isInline: true, styles: ["@keyframes dash-frame{to{stroke-dashoffset:0}}.p-knob-range{fill:none;transition:stroke .1s ease-in}.p-knob-value{animation-name:dash-frame;animation-fill-mode:forwards;fill:none}.p-knob-text{font-size:1.3rem;text-align:center}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Knob, decorators: [{ type: Component, args: [{ selector: 'p-knob', template: `
{{valueToDisplay()}}
`, providers: [KNOB_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'class': 'p-element' }, styles: ["@keyframes dash-frame{to{stroke-dashoffset:0}}.p-knob-range{fill:none;transition:stroke .1s ease-in}.p-knob-value{animation-name:dash-frame;animation-fill-mode:forwards;fill:none}.p-knob-text{font-size:1.3rem;text-align:center}\n"] }] }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { styleClass: [{ type: Input }], style: [{ type: Input }], severity: [{ type: Input }], valueColor: [{ type: Input }], rangeColor: [{ type: Input }], textColor: [{ type: Input }], valueTemplate: [{ type: Input }], name: [{ type: Input }], size: [{ type: Input }], step: [{ type: Input }], min: [{ type: Input }], max: [{ type: Input }], strokeWidth: [{ type: Input }], disabled: [{ type: Input }], showValue: [{ type: Input }], readonly: [{ type: Input }], onChange: [{ type: Output }] } }); export class KnobModule { } KnobModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: KnobModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); KnobModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: KnobModule, declarations: [Knob], imports: [CommonModule], exports: [Knob] }); KnobModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: KnobModule, imports: [[CommonModule]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: KnobModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], exports: [Knob], declarations: [Knob] }] }] }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia25vYi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvY29tcG9uZW50cy9rbm9iL2tub2IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsdUJBQXVCLEVBQUUsaUJBQWlCLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBaUMsTUFBTSxFQUFFLFlBQVksRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUN2SyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDL0MsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7OztBQUVuRCxNQUFNLENBQUMsTUFBTSxtQkFBbUIsR0FBUTtJQUNwQyxPQUFPLEVBQUUsaUJBQWlCO0lBQzFCLFdBQVcsRUFBRSxVQUFVLENBQUMsR0FBRyxFQUFFLENBQUMsSUFBSSxDQUFDO0lBQ25DLEtBQUssRUFBRSxJQUFJO0NBQ2QsQ0FBQztBQXNCRixNQUFNLE9BQU8sSUFBSTtJQTREYixZQUFvQixFQUFxQixFQUFVLEVBQWM7UUFBN0MsT0FBRSxHQUFGLEVBQUUsQ0FBbUI7UUFBVSxPQUFFLEdBQUYsRUFBRSxDQUFZO1FBcER4RCxlQUFVLEdBQVcsNkJBQTZCLENBQUM7UUFFbkQsZUFBVSxHQUFXLDZCQUE2QixDQUFDO1FBRW5ELGNBQVMsR0FBVyxvQ0FBb0MsQ0FBQztRQUV6RCxrQkFBYSxHQUFXLFNBQVMsQ0FBQztRQUlsQyxTQUFJLEdBQVcsR0FBRyxDQUFDO1FBRW5CLFNBQUksR0FBVyxDQUFDLENBQUM7UUFFakIsU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luZCh0aGlzKVxuICAgICAgICAgICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoJ21vdXNlbW92ZScsIHRoaXMud2luZG93TW91c2VNb3ZlTGlzdGVuZXIpO1xuICAgICAgICAgICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoJ21vdXNldXAnLCB0aGlzLndpbmRvd01vdXNlVXBMaXN0ZW5lcik7XG4gICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgb25Nb3VzZVVwKGV2ZW50KSB7XG4gICAgICAgIGlmICghdGhpcy5kaXNhYmxlZCAmJiAhdGhpcy5yZWFkb25seSkge1xuICAgICAgICAgICAgd2luZG93LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ21vdXNlbW92ZScsIHRoaXMud2luZG93TW91c2VNb3ZlTGlzdGVuZXIpO1xuICAgICAgICAgICAgd2luZG93LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ21vdXNldXAnLCB0aGlzLndpbmRvd01vdXNlVXBMaXN0ZW5lcik7XG4gICAgICAgICAgICB0aGlzLndpbmRvd01vdXNlVXBMaXN0ZW5lciA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLndpbmRvd01vdXNlTW92ZUxpc3RlbmVyID0gbnVsbDtcbiAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBvblRvdWNoU3RhcnQoZXZlbnQpIHtcbiAgICAgICAgaWYgKCF0aGlzLmRpc2FibGVkICYmICF0aGlzLnJlYWRvbmx5KSB7XG4gICAgICAgICAgICB0aGlzLndpbmRvd1RvdWNoTW92ZUxpc3RlbmVyID0gdGhpcy5vblRvdWNoTW92ZS5iaW5kKHRoaXMpO1xuICAgICAgICAgICAgdGhpcy53aW5kb3dUb3VjaEVuZExpc3RlbmVyID0gdGhpcy5vblRvdWNoRW5kLmJpbmQodGhpcyk7XG4gICAgICAgICA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