@ruc-lib/knob 2.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,618 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { EventEmitter, forwardRef, Component, ViewChild, Output, Input, HostListener, NgModule } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
5
- import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
6
- import * as i2 from '@angular/material/button';
7
- import { MatButtonModule } from '@angular/material/button';
8
- import * as i3 from '@angular/material/icon';
9
- import { MatIconModule } from '@angular/material/icon';
10
-
11
- const DefaultKnobConfig = {
12
- min: 0,
13
- max: 100,
14
- step: 1,
15
- size: 150,
16
- valueColor: '',
17
- strokeBackground: 'lightblue',
18
- progressBackground: 'blue',
19
- strokeWidth: 15,
20
- valueSize: 20,
21
- valueWeight: 'normal',
22
- showHandle: true,
23
- handleBackground: 'lightblue',
24
- handleBorderColor: 'blue',
25
- handleBorderWidth: 4,
26
- roundedCorner: true,
27
- valuePrefix: '',
28
- valueSuffix: '',
29
- readOnly: false,
30
- disabled: false,
31
- enableTooltip: false,
32
- animateOnHover: false,
33
- isRangeMode: false,
34
- rangeStartValue: 25,
35
- rangeEndValue: 75,
36
- showButtons: false,
37
- knobType: 'arc' // 'horizontal' | 'vertical' | 'arc'
38
- };
39
- const DEFAULT_LABELS = {
40
- incrementButton: 'Increment Value',
41
- decrementButton: 'Decrement Value'
42
- };
43
-
44
- class RuclibKnobComponent {
45
- constructor(cdr) {
46
- this.cdr = cdr;
47
- this.rucEvent = new EventEmitter();
48
- this.customTheme = '';
49
- this.activeHandle = '';
50
- this.value = 0;
51
- this.dragging = false;
52
- this.centerX = 0;
53
- this.centerY = 0;
54
- this.radius = 0;
55
- this.startAngle = 210;
56
- this.endAngle = 510;
57
- this.arcLength = 300;
58
- this.changeColorAfter = 0;
59
- this.tooltipX = 0;
60
- this.tooltipY = 0;
61
- this.showTooltip = false;
62
- this.hovering = false;
63
- this.config = DefaultKnobConfig;
64
- this.onTouched = () => { };
65
- this.onChange = (value) => { };
66
- }
67
- /**
68
- * handling form control binding to write value
69
- * @param val
70
- */
71
- writeValue(val) {
72
- this.value = val;
73
- }
74
- /**
75
- * registering onChange method to use as form control
76
- * @param fn
77
- */
78
- registerOnChange(fn) {
79
- this.onChange = fn;
80
- }
81
- /**
82
- * registering onTouch method to use as form control
83
- * @param fn
84
- */
85
- registerOnTouched(fn) {
86
- this.onTouched = fn;
87
- }
88
- /**
89
- * registering disabled state
90
- * @param isDisabled
91
- */
92
- setDisabledState(isDisabled) {
93
- this.config.disabled = isDisabled;
94
- }
95
- /**
96
- * handling input data changes
97
- * updating default config with user provided config
98
- * @param changes
99
- */
100
- ngOnChanges(changes) {
101
- if (changes && changes['rucInputData'] && changes['rucInputData'].currentValue) {
102
- this.config = { ...this.config, ...changes['rucInputData'].currentValue };
103
- }
104
- }
105
- /**
106
- * handling change on component initilization
107
- */
108
- ngOnInit() {
109
- this.adjustDefaultValue();
110
- if (this.config.knobType != 'arc') {
111
- this.config.isRangeMode = false;
112
- this.config.enableTooltip = false;
113
- }
114
- if (Array.isArray(this.config.progressBackground)) {
115
- this.changeColorAfter = Math.round(100 / this.config.progressBackground.length);
116
- }
117
- }
118
- /**
119
- * handling change after view initilization
120
- */
121
- ngAfterViewInit() {
122
- this.centerX = this.config.size / 2;
123
- this.centerY = this.config.size / 2;
124
- this.radius = this.config.size / 2 - 20;
125
- this.bgArcRef?.nativeElement.setAttribute('d', this.describeArc(this.centerX, this.centerY, this.radius, this.startAngle, this.endAngle));
126
- this.updateArc();
127
- this.cdr.detectChanges();
128
- }
129
- /**
130
- * handling change when dragin on svg
131
- * @returns
132
- */
133
- startDrag() {
134
- if (this.config.disabled || this.config.readOnly)
135
- return;
136
- this.dragging = true;
137
- this.showTooltip = true;
138
- this.rucEvent.emit({ eventName: 'dragStart', eventOutput: { value: this.getEventOutput() } });
139
- }
140
- /**
141
- * rounding value to increment or decrement based on provide config value for step
142
- * @param value
143
- * @returns
144
- */
145
- roundToStep(value) {
146
- const stepped = Math.round((value - this.config.min) / this.config.step) * this.config.step + this.config.min;
147
- return this.clamp(stepped, this.config.min, this.config.max);
148
- }
149
- /**
150
- * adjusting default value within min & max value when its provide out of range
151
- */
152
- adjustDefaultValue() {
153
- if (this.value < this.config.min) {
154
- this.value = this.config.min;
155
- }
156
- if (this.value > this.config.max) {
157
- this.value = this.config.max;
158
- }
159
- if (this.config.isRangeMode) {
160
- if (this.config.rangeStartValue < this.config.min || this.config.rangeStartValue > this.config.max) {
161
- this.config.rangeStartValue = this.config.min;
162
- }
163
- if (this.config.rangeEndValue > this.config.max || this.config.rangeEndValue < this.config.min) {
164
- this.config.rangeEndValue = this.config.max;
165
- }
166
- }
167
- this.updateArc();
168
- }
169
- /**
170
- * handle changes on mouseUp and touchEnd event
171
- */
172
- stopDrag() {
173
- this.dragging = false;
174
- this.showTooltip = false;
175
- this.rucEvent.emit({ eventName: 'dragEnd', eventOutput: { value: this.getEventOutput() } });
176
- }
177
- /**
178
- * handle changes on mouseMove and touch event
179
- * @param event
180
- * @returns
181
- */
182
- onMove(event) {
183
- if (this.config.disabled || this.config.readOnly || !this.dragging)
184
- return;
185
- event.preventDefault();
186
- this.setProgressFromEvent(event);
187
- }
188
- /**
189
- * handling change on main svg click
190
- * @param event
191
- * @returns
192
- */
193
- onSvgClick(event) {
194
- if (this.config.disabled || this.config.readOnly || this.config.isRangeMode)
195
- return;
196
- this.setProgressFromEvent(event);
197
- }
198
- /**
199
- * get ref of active svg element for different type of knobs
200
- * @returns
201
- */
202
- getTargetSvg() {
203
- if (this.config.knobType === 'horizontal') {
204
- return this.horizontalLineRef.nativeElement.closest('svg');
205
- }
206
- else if (this.config.knobType === 'vertical') {
207
- return this.verticalLineRef.nativeElement.closest('svg');
208
- }
209
- return this.bgArcRef.nativeElement.closest('svg');
210
- }
211
- /**
212
- * updating progrees value while dragging the handle on stroke bar
213
- * @param e
214
- * @returns
215
- */
216
- setProgressFromEvent(e) {
217
- const svg = this.getTargetSvg();
218
- if (!svg) {
219
- return;
220
- }
221
- const rect = svg.getBoundingClientRect();
222
- const clientX = (e instanceof TouchEvent) ? e.touches[0].clientX : e.clientX;
223
- const clientY = (e instanceof TouchEvent) ? e.touches[0].clientY : e.clientY;
224
- const x = clientX - rect.left;
225
- const y = clientY - rect.top;
226
- let rawPercent;
227
- if (this.config.knobType === 'horizontal') {
228
- const usableWidth = this.config.size - 2 * this.config.strokeWidth;
229
- rawPercent = ((x - this.config.strokeWidth) / usableWidth) * 100;
230
- }
231
- else if (this.config.knobType === 'vertical') {
232
- const usableHeight = this.config.size - 2 * this.config.strokeWidth;
233
- rawPercent = (1 - (y - this.config.strokeWidth) / usableHeight) * 100;
234
- }
235
- else {
236
- const angle = this.getAngleFromPoint(x, y);
237
- if (angle === null)
238
- return;
239
- rawPercent = ((angle - this.startAngle) / this.arcLength) * 100;
240
- }
241
- const clampedPercent = this.clamp(rawPercent, 0, 100);
242
- let absolutePercent = this.config.min + (clampedPercent / 100) * (this.config.max - this.config.min);
243
- absolutePercent = this.roundToStep(absolutePercent);
244
- if (this.config.isRangeMode) {
245
- if (this.activeHandle === 'start') {
246
- if (absolutePercent > this.config.rangeEndValue) {
247
- absolutePercent = this.config.rangeEndValue;
248
- }
249
- this.config.rangeStartValue = absolutePercent;
250
- }
251
- else {
252
- if (absolutePercent < this.config.rangeStartValue) {
253
- absolutePercent = this.config.rangeStartValue;
254
- }
255
- this.config.rangeEndValue = absolutePercent;
256
- }
257
- this.rucEvent.emit({ eventName: 'valueChange', eventOutput: { start: this.config.rangeStartValue, end: this.config.rangeEndValue } });
258
- }
259
- else {
260
- this.value = absolutePercent;
261
- this.rucEvent.emit({ eventName: 'valueChange', eventOutput: this.value });
262
- }
263
- this.updateArc();
264
- this.onChange(this.value);
265
- this.onTouched();
266
- }
267
- /**
268
- * updating svg progress based on value changes
269
- * @returns
270
- */
271
- updateArc() {
272
- if (this.config.knobType !== 'arc') {
273
- return;
274
- }
275
- const scaled = (this.value - this.config.min) / (this.config.max - this.config.min);
276
- const angle = this.startAngle + scaled * this.arcLength;
277
- const path = this.describeArc(this.centerX, this.centerY, this.radius, this.startAngle, angle);
278
- this.progressArcRef?.nativeElement.setAttribute('d', path);
279
- const pos = this.polarToCartesian(this.centerX, this.centerY, this.radius, angle);
280
- this.handleRef?.nativeElement.setAttribute('cx', pos.x.toString());
281
- this.handleRef?.nativeElement.setAttribute('cy', pos.y.toString());
282
- // for tooltip
283
- const angleRad = (angle - 90) * Math.PI / 180;
284
- const tooltipRadius = this.radius + this.config.strokeWidth / 2 + 10;
285
- this.tooltipX = this.centerX + tooltipRadius * Math.cos(angleRad);
286
- this.tooltipY = this.centerY + tooltipRadius * Math.sin(angleRad);
287
- }
288
- /**
289
- * return maximum value out of min & max range
290
- * @param val
291
- * @param min
292
- * @param max
293
- * @returns
294
- */
295
- clamp(val, min, max) {
296
- return Math.max(min, Math.min(max, val));
297
- }
298
- /**
299
- * getting calulated point from polar coordinates to cartesian coordinates
300
- * @param cx
301
- * @param cy
302
- * @param r
303
- * @param angleDeg
304
- * @returns
305
- */
306
- polarToCartesian(cx, cy, r, angleDeg) {
307
- const angleRad = (angleDeg - 90) * Math.PI / 180;
308
- return {
309
- x: cx + r * Math.cos(angleRad),
310
- y: cy + r * Math.sin(angleRad)
311
- };
312
- }
313
- /**
314
- * getting radius for arc handle based on stroke width
315
- * @returns
316
- */
317
- getRadius() {
318
- return this.config.strokeWidth ? (this.config.strokeWidth / 2) - ((this.config.handleBorderWidth ?? 0) / 2) : 4;
319
- }
320
- /**
321
- * getting svg box size based on different knob shapes
322
- * @returns
323
- */
324
- getSvgViewBoxSize() {
325
- let width = this.config.size, height = this.config.size;
326
- if (this.config.knobType === 'horizontal') {
327
- height = this.config.strokeWidth + 40;
328
- }
329
- if (this.config.knobType === 'vertical') {
330
- height = this.config.size / 4 + 5;
331
- width = this.config.strokeWidth + 40;
332
- }
333
- return '0 0 ' + width + ' ' + height;
334
- }
335
- /**
336
- * geeting dynamic bg color for progress stroke based on provide config for "progressBackground"
337
- */
338
- get progressColor() {
339
- if (typeof this.config.progressBackground === 'string') {
340
- return this.config.progressBackground;
341
- }
342
- else if (this.config.progressBackground?.length == 1) {
343
- return this.config.progressBackground[0];
344
- }
345
- else if (this.config.progressBackground.length > 1) {
346
- return this.config.progressBackground[Math.ceil(this.value / this.changeColorAfter) - 1];
347
- }
348
- else {
349
- return 'green';
350
- }
351
- }
352
- /**
353
- * getting coordinates for arc based on provided inputs
354
- * @param cx
355
- * @param cy
356
- * @param r
357
- * @param start
358
- * @param end
359
- * @returns
360
- */
361
- describeArc(cx, cy, r, start, end) {
362
- const startPos = this.polarToCartesian(cx, cy, r, end);
363
- const endPos = this.polarToCartesian(cx, cy, r, start);
364
- const largeArc = end - start <= 180 ? 0 : 1;
365
- return [
366
- "M", startPos.x, startPos.y,
367
- "A", r, r, 0, largeArc, 0, endPos.x, endPos.y
368
- ].join(" ");
369
- }
370
- /**
371
- * getting calculated angle for arc progress based on provided input
372
- * @param x
373
- * @param y
374
- * @returns
375
- */
376
- getAngleFromPoint(x, y) {
377
- const dx = x - this.centerX;
378
- if (dx === 0) {
379
- return null;
380
- }
381
- const dy = y - this.centerY;
382
- let angle = Math.atan2(dy, dx) * 180 / Math.PI + 90;
383
- if (angle < 0)
384
- angle += 360;
385
- const normalizedStart = this.startAngle % 360;
386
- let delta = angle - normalizedStart;
387
- if (delta < 0)
388
- delta += 360;
389
- if (delta > this.arcLength)
390
- return null;
391
- return this.startAngle + delta;
392
- }
393
- /**
394
- * increment value on click on button
395
- * @returns
396
- */
397
- increment() {
398
- if (this.config.disabled || this.config.readOnly)
399
- return;
400
- this.value = this.clamp((this.value + this.config.step), this.config.min, this.config.max);
401
- this.updateArc();
402
- this.onChange(this.value);
403
- this.onTouched();
404
- }
405
- /**
406
- * decrement value on click on button
407
- * @returns
408
- */
409
- decrement() {
410
- if (this.config.disabled || this.config.readOnly)
411
- return;
412
- this.value = this.clamp((this.value - this.config.step), this.config.min, this.config.max);
413
- this.updateArc();
414
- this.onChange(this.value);
415
- this.onTouched();
416
- }
417
- /**
418
- * change value using arrow keys for accessibility
419
- * @param event
420
- * @returns
421
- */
422
- onKeyDown(event) {
423
- if (this.config.readOnly || this.config.disabled)
424
- return;
425
- if (event.key === 'ArrowRight' || event.key === 'ArrowUp') {
426
- this.increment();
427
- event.preventDefault();
428
- }
429
- else if (event.key === 'ArrowLeft' || event.key === 'ArrowDown') {
430
- this.decrement();
431
- event.preventDefault();
432
- }
433
- }
434
- /**
435
- * geeting arc coordinated for range selection mode
436
- * @returns
437
- */
438
- getRangeArcPath() {
439
- const startAngle = this.startAngle + (this.config.rangeStartValue / (this.config.max - this.config.min)) * (this.endAngle - this.startAngle);
440
- const endAngle = this.startAngle + (this.config.rangeEndValue / (this.config.max - this.config.min)) * (this.endAngle - this.startAngle);
441
- return this.describeArc(this.centerX, this.centerY, this.radius, startAngle, endAngle);
442
- }
443
- /**
444
- * handling mousedown when range mode is enabled
445
- * @param event
446
- * @param handleType
447
- * @returns
448
- */
449
- onHandleMouseDown(event, handleType) {
450
- if (this.config.disabled || this.config.readOnly)
451
- return;
452
- this.activeHandle = handleType;
453
- this.startDrag();
454
- }
455
- /**
456
- * getting x & y to update handle position when dragging
457
- * @param value
458
- * @returns
459
- */
460
- getHandlePosition(value) {
461
- const scaled = (value - this.config.min) / (this.config.max - this.config.min);
462
- const angle = this.startAngle + scaled * this.arcLength;
463
- const pos = this.polarToCartesian(this.centerX, this.centerY, this.radius, angle);
464
- return pos;
465
- }
466
- /**
467
- * geeting handle position for horizontal line
468
- * @param value
469
- * @returns
470
- */
471
- getHorizontalHandleX(value) {
472
- const usableWidth = this.config.size - 2 * this.config.strokeWidth;
473
- const ratio = (value - this.config.min) / (this.config.max - this.config.min);
474
- return this.config.strokeWidth + usableWidth * ratio;
475
- }
476
- /**
477
- * geeting start position for horizontal line
478
- * @param value
479
- * @returns
480
- */
481
- getHorizontalLineStartX() {
482
- return this.getHorizontalHandleX(this.config.isRangeMode ? this.config.rangeStartValue : this.config.min);
483
- }
484
- /**
485
- * geeting end position for horizontal line
486
- * @param value
487
- * @returns
488
- */
489
- getHorizontalLineEndX() {
490
- return this.getHorizontalHandleX(this.config.isRangeMode ? this.config.rangeEndValue : this.value);
491
- }
492
- /**
493
- * geeting handle position for vertical line
494
- * @param value
495
- * @returns
496
- */
497
- getVerticalHandleY(value) {
498
- const usableHeight = this.config.size - 2 * this.config.strokeWidth;
499
- const ratio = 1 - (value - this.config.min) / (this.config.max - this.config.min);
500
- return this.config.strokeWidth + usableHeight * ratio;
501
- }
502
- /**
503
- * geeting start position for vertical line
504
- * @param value
505
- * @returns
506
- */
507
- getVerticalLineStartY() {
508
- return this.getVerticalHandleY(this.config.isRangeMode ? this.config.rangeEndValue : this.value);
509
- }
510
- /**
511
- * get output to be emitted based on range mode
512
- * @returns
513
- */
514
- getEventOutput() {
515
- if (this.config.isRangeMode) {
516
- return { start: this.config.rangeStartValue, end: this.config.rangeEndValue };
517
- }
518
- return this.value;
519
- }
520
- /**
521
- * get correct page label from object
522
- * @param labelName
523
- * @returns string
524
- */
525
- getLabel(labelName) {
526
- return DEFAULT_LABELS[labelName] || '';
527
- }
528
- }
529
- RuclibKnobComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RuclibKnobComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
530
- RuclibKnobComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: RuclibKnobComponent, selector: "uxp-ruclib-knob", inputs: { customTheme: "customTheme", rucInputData: "rucInputData" }, outputs: { rucEvent: "rucEvent" }, host: { listeners: { "window:mouseup": "stopDrag()", "window:touchend": "stopDrag()", "window:mousemove": "onMove($event)", "window:touchmove": "onMove($event)" } }, providers: [
531
- {
532
- provide: NG_VALUE_ACCESSOR,
533
- useExisting: forwardRef(() => RuclibKnobComponent),
534
- multi: true
535
- }
536
- ], viewQueries: [{ propertyName: "bgArcRef", first: true, predicate: ["bgArc"], descendants: true }, { propertyName: "progressArcRef", first: true, predicate: ["progressArc"], descendants: true }, { propertyName: "handleRef", first: true, predicate: ["handle"], descendants: true }, { propertyName: "horizontalLineRef", first: true, predicate: ["horizontalLine"], descendants: true }, { propertyName: "verticalLineRef", first: true, predicate: ["verticalLine"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"knob-container {{customTheme}}\" [style.width.px]=\"config.size\">\r\n <svg [ngClass]=\"{ 'hover-animate': config.animateOnHover }\" [attr.viewBox]=\"getSvgViewBoxSize()\"\r\n (click)=\"onSvgClick($event)\" [style.cursor]=\"(config.readOnly || config.disabled) ? 'not-allowed' : 'pointer'\"\r\n [class.disabled]=\"config.disabled\" [class.read-only]=\"config.readOnly\"\r\n (mouseenter)=\"showTooltip = true; hovering=true; rucEvent.emit({eventName: 'hover'})\"\r\n (mouseleave)=\"showTooltip = false; hovering=false\" (focus)=\"rucEvent.emit({eventName: 'focus'})\"\r\n (blur)=\"rucEvent.emit({eventName: 'blur'})\" (keydown)=\"onKeyDown($event)\" [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"config.min\" [attr.aria-valuemax]=\"config.max\" [attr.aria-valuenow]=\"value\"\r\n [attr.aria-disabled]=\"config.disabled\" [ngSwitch]=\"config.knobType\">\r\n\r\n <!-- arc knob -->\r\n <ng-container *ngSwitchCase=\"'arc'\">\r\n\r\n <!-- glow effect -->\r\n <defs>\r\n <filter id=\"glow\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\r\n <feDropShadow dx=\"0\" dy=\"0\" stdDeviation=\"4\" [attr.flood-color]=\"config.strokeBackground\"\r\n flood-opacity=\"0.75\" />\r\n </filter>\r\n </defs>\r\n\r\n <!-- arc main stroke -->\r\n <path #bgArc fill=\"none\" class=\"main-path\" [attr.stroke]=\"config.strokeBackground\"\r\n [attr.stroke-width]=\"config.strokeWidth\" [attr.stroke-linecap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- arc progress stroke - single handle -->\r\n <path *ngIf=\"!config.isRangeMode\" #progressArc fill=\"none\" class=\"progress-path\" [attr.stroke]=\"progressColor\"\r\n [attr.stroke-width]=\"config.strokeWidth\" [attr.stroke-linecap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- arc - single handle -->\r\n <circle *ngIf=\"!config.isRangeMode\" #handle class=\"handle\" [attr.r]=\"getRadius()\"\r\n [attr.fill]=\"config.showHandle ? config.handleBackground : 'transparent'\"\r\n [attr.stroke-width]=\"config.showHandle ? config.handleBorderWidth : 0\"\r\n [attr.stroke]=\"config.showHandle ? config.handleBorderColor : 'transparent'\" (mousedown)=\"startDrag()\"\r\n (touchstart)=\"startDrag()\" />\r\n\r\n <!-- arc progress stroke - dual handle for range -->\r\n <path *ngIf=\"config.isRangeMode\" [attr.d]=\"getRangeArcPath()\" [attr.stroke]=\"progressColor\"\r\n [attr.stroke-width]=\"config.strokeWidth\" fill=\"none\" stroke-linecap=\"round\" />\r\n\r\n <!-- arc dual handle - start -->\r\n <circle *ngIf=\"config.isRangeMode\" [attr.cx]=\"getHandlePosition(config.rangeStartValue).x\"\r\n [attr.cy]=\"getHandlePosition(config.rangeStartValue).y\" [attr.r]=\"getRadius()\"\r\n [attr.fill]=\"config.handleBackground\" [attr.stroke-width]=\"config.handleBorderWidth\"\r\n [attr.stroke]=\"config.handleBorderColor\" (mousedown)=\"onHandleMouseDown($event, 'start')\" />\r\n\r\n <!-- arc dual handle - end -->\r\n <circle *ngIf=\"config.isRangeMode\" [attr.cx]=\"getHandlePosition(config.rangeEndValue).x\"\r\n [attr.cy]=\"getHandlePosition(config.rangeEndValue).y\" [attr.r]=\"getRadius()\"\r\n [attr.fill]=\"config.handleBackground\" [attr.stroke-width]=\"config.handleBorderWidth\"\r\n [attr.stroke]=\"config.handleBorderColor\" (mousedown)=\"onHandleMouseDown($event, 'end')\" />\r\n </ng-container>\r\n\r\n <!-- horizontal line -->\r\n <ng-container *ngSwitchCase=\"'horizontal'\">\r\n <line #horizontalLine [attr.x1]=\"config.strokeWidth\" [attr.x2]=\"config.size\" [attr.y1]=\"config.strokeWidth + 10\"\r\n [attr.y2]=\"config.strokeWidth + 10\" [attr.stroke]=\"config.strokeBackground\"\r\n [attr.stroke-width]=\"config.strokeWidth\" [attr.line-cap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- progress for horizontal line -->\r\n <line [attr.x1]=\"getHorizontalLineStartX()\" [attr.x2]=\"getHorizontalLineEndX()\"\r\n [attr.y1]=\"config.strokeWidth + 10\" [attr.y2]=\"config.strokeWidth + 10\" [attr.stroke]=\"progressColor\"\r\n [attr.stroke-width]=\"config.strokeWidth\" />\r\n\r\n <!-- handle for horizontal line -->\r\n <rect *ngIf=\"!config.isRangeMode\" [attr.x]=\"getHorizontalHandleX(value)\"\r\n [attr.y]=\"config.strokeWidth + 10 - getRadius()-1\" [attr.width]=\"config.strokeWidth\"\r\n [attr.height]=\"config.strokeWidth\"\r\n [attr.fill]=\"config.handleBackground ? config.handleBackground : progressColor\" (mousedown)=\"startDrag()\"\r\n (touchstart)=\"startDrag()\" />\r\n </ng-container>\r\n\r\n <!-- vertical line -->\r\n <ng-container *ngSwitchCase=\"'vertical'\">\r\n <line #verticalLine [attr.y1]=\"config.strokeWidth/4\" [attr.y2]=\"config.size/4\" [attr.x1]=\"config.strokeWidth + 10\"\r\n [attr.x2]=\"config.strokeWidth + 10\" [attr.stroke]=\"config.strokeBackground\"\r\n [attr.stroke-width]=\"config.strokeWidth/4\" [attr.line-cap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- progress for vertical line -->\r\n <line [attr.y1]=\"getVerticalLineStartY()/4\" [attr.y2]=\"config.size/4\" [attr.x1]=\"config.strokeWidth + 10\"\r\n [attr.x2]=\"config.strokeWidth + 10\" [attr.stroke]=\"progressColor\" [attr.stroke-width]=\"config.strokeWidth/4\" />\r\n\r\n <!-- Handle for vertical line -->\r\n <rect *ngIf=\"!config.isRangeMode\" [attr.y]=\"getVerticalHandleY(value)/4\" [attr.x]=\"config.strokeWidth + 7.5\"\r\n [attr.width]=\"config.strokeWidth/4\" [attr.height]=\"config.strokeWidth/4\"\r\n [attr.fill]=\"config.handleBackground ? config.handleBackground : progressColor\" (mousedown)=\"startDrag()\"\r\n (touchstart)=\"startDrag()\" />\r\n </ng-container>\r\n </svg>\r\n\r\n <!-- tooltip -->\r\n <div class=\"tooltip\" *ngIf=\"config.enableTooltip && !config.isRangeMode\" [class.show]=\"showTooltip\"\r\n [style.left.px]=\"tooltipX\" [style.top.px]=\"tooltipY\">\r\n {{ value}}\r\n </div>\r\n\r\n <!-- progress value -->\r\n <div class=\"progress-value {{config.knobType}}\" [style.maxWidth.px]=\"config.size * 2 - 50\"\r\n [style.color]=\"config.valueColor\" [style.fontSize.px]=\"config.valueSize\" [style.fontWeight]=\"config.valueWeight\"\r\n [style.cursor]=\"(config.readOnly || config.disabled) ? 'not-allowed' : ''\" [class.disabled]=\"config.disabled\"\r\n [class.read-only]=\"config.readOnly\" title=\"{{config.valuePrefix +''+value+''+config.valueSuffix}}\">\r\n <ng-container *ngIf=\"!config.isRangeMode\">\r\n <span class=\"value-prefix\">{{config.valuePrefix}}</span>\r\n <span class=\"value\">{{ value }}</span>\r\n <span class=\"value-suffix\">{{config.valueSuffix}}</span>\r\n </ng-container>\r\n <ng-container *ngIf=\"config.isRangeMode\">\r\n <span class=\"value\">{{config.rangeStartValue}} : {{config.rangeEndValue}}</span>\r\n </ng-container>\r\n </div>\r\n\r\n <!-- increment-decrement button -->\r\n <div class=\"arc-buttons\" *ngIf=\"!config.isRangeMode && config.showButtons\">\r\n <button mat-mini-fab color=\"secondary\" (click)=\"decrement()\" [disabled]=\"config.disabled || config.readOnly\" (keydown)=\"onKeyDown($event)\"\r\n [attr.aria-label]=\"getLabel('decrementButton')\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n \r\n <button mat-mini-fab color=\"secondary\" (click)=\"increment()\" [disabled]=\"config.disabled || config.readOnly\" (keydown)=\"onKeyDown($event)\"\r\n [attr.aria-label]=\"getLabel('incrementButton')\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n \r\n </div>\r\n</div>", styles: [".knob-container{position:relative;padding-bottom:10px}svg{width:100%;height:100%;outline:none}.progress-value{left:50%;font-size:24px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%)}.progress-value.arc{position:absolute;top:45%}.progress-value.horizontal,.progress-value.vertical{position:relative;display:flex;justify-content:center;align-items:center;padding-top:20px}.handle{cursor:pointer}.disabled{opacity:.6;pointer-events:none}.read-only{opacity:.8}.arc-buttons{display:flex;justify-content:center;gap:1rem;margin-top:-10px}.arc-buttons button{padding:6px;width:35px;height:35px;font-size:1rem;cursor:pointer;border:none;border-radius:4px;transition:background .2s ease;box-shadow:0 0 1px 1px #ddd!important}::ng-deep .mat-mdc-mini-fab:not(.mdc-fab--extended) .mdc-fab__ripple{border-radius:0!important;-webkit-border-radius:0!important;-moz-border-radius:0!important;-ms-border-radius:0!important;-o-border-radius:0!important}.arc-buttons button:disabled{opacity:.6;cursor:not-allowed}.tooltip{position:absolute;background:#333;color:#fff;padding:4px 8px;border-radius:4px;font-size:12px;pointer-events:none;white-space:nowrap;transform:translate(-50%,-100%);opacity:0;transition:opacity .3s ease}.tooltip.show{opacity:1}.main-path{transition:all 1s ease;-webkit-transition:all 1s ease;-moz-transition:all 1s ease;-ms-transition:all 1s ease;-o-transition:all 1s ease}.hover-animate:hover .main-path{filter:url(#glow);-webkit-filter:url(#glow)}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "component", type: i2.MatMiniFabButton, selector: "button[mat-mini-fab]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
537
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RuclibKnobComponent, decorators: [{
538
- type: Component,
539
- args: [{ selector: 'uxp-ruclib-knob', providers: [
540
- {
541
- provide: NG_VALUE_ACCESSOR,
542
- useExisting: forwardRef(() => RuclibKnobComponent),
543
- multi: true
544
- }
545
- ], template: "<div class=\"knob-container {{customTheme}}\" [style.width.px]=\"config.size\">\r\n <svg [ngClass]=\"{ 'hover-animate': config.animateOnHover }\" [attr.viewBox]=\"getSvgViewBoxSize()\"\r\n (click)=\"onSvgClick($event)\" [style.cursor]=\"(config.readOnly || config.disabled) ? 'not-allowed' : 'pointer'\"\r\n [class.disabled]=\"config.disabled\" [class.read-only]=\"config.readOnly\"\r\n (mouseenter)=\"showTooltip = true; hovering=true; rucEvent.emit({eventName: 'hover'})\"\r\n (mouseleave)=\"showTooltip = false; hovering=false\" (focus)=\"rucEvent.emit({eventName: 'focus'})\"\r\n (blur)=\"rucEvent.emit({eventName: 'blur'})\" (keydown)=\"onKeyDown($event)\" [attr.role]=\"'slider'\"\r\n [attr.aria-valuemin]=\"config.min\" [attr.aria-valuemax]=\"config.max\" [attr.aria-valuenow]=\"value\"\r\n [attr.aria-disabled]=\"config.disabled\" [ngSwitch]=\"config.knobType\">\r\n\r\n <!-- arc knob -->\r\n <ng-container *ngSwitchCase=\"'arc'\">\r\n\r\n <!-- glow effect -->\r\n <defs>\r\n <filter id=\"glow\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\r\n <feDropShadow dx=\"0\" dy=\"0\" stdDeviation=\"4\" [attr.flood-color]=\"config.strokeBackground\"\r\n flood-opacity=\"0.75\" />\r\n </filter>\r\n </defs>\r\n\r\n <!-- arc main stroke -->\r\n <path #bgArc fill=\"none\" class=\"main-path\" [attr.stroke]=\"config.strokeBackground\"\r\n [attr.stroke-width]=\"config.strokeWidth\" [attr.stroke-linecap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- arc progress stroke - single handle -->\r\n <path *ngIf=\"!config.isRangeMode\" #progressArc fill=\"none\" class=\"progress-path\" [attr.stroke]=\"progressColor\"\r\n [attr.stroke-width]=\"config.strokeWidth\" [attr.stroke-linecap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- arc - single handle -->\r\n <circle *ngIf=\"!config.isRangeMode\" #handle class=\"handle\" [attr.r]=\"getRadius()\"\r\n [attr.fill]=\"config.showHandle ? config.handleBackground : 'transparent'\"\r\n [attr.stroke-width]=\"config.showHandle ? config.handleBorderWidth : 0\"\r\n [attr.stroke]=\"config.showHandle ? config.handleBorderColor : 'transparent'\" (mousedown)=\"startDrag()\"\r\n (touchstart)=\"startDrag()\" />\r\n\r\n <!-- arc progress stroke - dual handle for range -->\r\n <path *ngIf=\"config.isRangeMode\" [attr.d]=\"getRangeArcPath()\" [attr.stroke]=\"progressColor\"\r\n [attr.stroke-width]=\"config.strokeWidth\" fill=\"none\" stroke-linecap=\"round\" />\r\n\r\n <!-- arc dual handle - start -->\r\n <circle *ngIf=\"config.isRangeMode\" [attr.cx]=\"getHandlePosition(config.rangeStartValue).x\"\r\n [attr.cy]=\"getHandlePosition(config.rangeStartValue).y\" [attr.r]=\"getRadius()\"\r\n [attr.fill]=\"config.handleBackground\" [attr.stroke-width]=\"config.handleBorderWidth\"\r\n [attr.stroke]=\"config.handleBorderColor\" (mousedown)=\"onHandleMouseDown($event, 'start')\" />\r\n\r\n <!-- arc dual handle - end -->\r\n <circle *ngIf=\"config.isRangeMode\" [attr.cx]=\"getHandlePosition(config.rangeEndValue).x\"\r\n [attr.cy]=\"getHandlePosition(config.rangeEndValue).y\" [attr.r]=\"getRadius()\"\r\n [attr.fill]=\"config.handleBackground\" [attr.stroke-width]=\"config.handleBorderWidth\"\r\n [attr.stroke]=\"config.handleBorderColor\" (mousedown)=\"onHandleMouseDown($event, 'end')\" />\r\n </ng-container>\r\n\r\n <!-- horizontal line -->\r\n <ng-container *ngSwitchCase=\"'horizontal'\">\r\n <line #horizontalLine [attr.x1]=\"config.strokeWidth\" [attr.x2]=\"config.size\" [attr.y1]=\"config.strokeWidth + 10\"\r\n [attr.y2]=\"config.strokeWidth + 10\" [attr.stroke]=\"config.strokeBackground\"\r\n [attr.stroke-width]=\"config.strokeWidth\" [attr.line-cap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- progress for horizontal line -->\r\n <line [attr.x1]=\"getHorizontalLineStartX()\" [attr.x2]=\"getHorizontalLineEndX()\"\r\n [attr.y1]=\"config.strokeWidth + 10\" [attr.y2]=\"config.strokeWidth + 10\" [attr.stroke]=\"progressColor\"\r\n [attr.stroke-width]=\"config.strokeWidth\" />\r\n\r\n <!-- handle for horizontal line -->\r\n <rect *ngIf=\"!config.isRangeMode\" [attr.x]=\"getHorizontalHandleX(value)\"\r\n [attr.y]=\"config.strokeWidth + 10 - getRadius()-1\" [attr.width]=\"config.strokeWidth\"\r\n [attr.height]=\"config.strokeWidth\"\r\n [attr.fill]=\"config.handleBackground ? config.handleBackground : progressColor\" (mousedown)=\"startDrag()\"\r\n (touchstart)=\"startDrag()\" />\r\n </ng-container>\r\n\r\n <!-- vertical line -->\r\n <ng-container *ngSwitchCase=\"'vertical'\">\r\n <line #verticalLine [attr.y1]=\"config.strokeWidth/4\" [attr.y2]=\"config.size/4\" [attr.x1]=\"config.strokeWidth + 10\"\r\n [attr.x2]=\"config.strokeWidth + 10\" [attr.stroke]=\"config.strokeBackground\"\r\n [attr.stroke-width]=\"config.strokeWidth/4\" [attr.line-cap]=\"config.roundedCorner ? 'round' : ''\" />\r\n\r\n <!-- progress for vertical line -->\r\n <line [attr.y1]=\"getVerticalLineStartY()/4\" [attr.y2]=\"config.size/4\" [attr.x1]=\"config.strokeWidth + 10\"\r\n [attr.x2]=\"config.strokeWidth + 10\" [attr.stroke]=\"progressColor\" [attr.stroke-width]=\"config.strokeWidth/4\" />\r\n\r\n <!-- Handle for vertical line -->\r\n <rect *ngIf=\"!config.isRangeMode\" [attr.y]=\"getVerticalHandleY(value)/4\" [attr.x]=\"config.strokeWidth + 7.5\"\r\n [attr.width]=\"config.strokeWidth/4\" [attr.height]=\"config.strokeWidth/4\"\r\n [attr.fill]=\"config.handleBackground ? config.handleBackground : progressColor\" (mousedown)=\"startDrag()\"\r\n (touchstart)=\"startDrag()\" />\r\n </ng-container>\r\n </svg>\r\n\r\n <!-- tooltip -->\r\n <div class=\"tooltip\" *ngIf=\"config.enableTooltip && !config.isRangeMode\" [class.show]=\"showTooltip\"\r\n [style.left.px]=\"tooltipX\" [style.top.px]=\"tooltipY\">\r\n {{ value}}\r\n </div>\r\n\r\n <!-- progress value -->\r\n <div class=\"progress-value {{config.knobType}}\" [style.maxWidth.px]=\"config.size * 2 - 50\"\r\n [style.color]=\"config.valueColor\" [style.fontSize.px]=\"config.valueSize\" [style.fontWeight]=\"config.valueWeight\"\r\n [style.cursor]=\"(config.readOnly || config.disabled) ? 'not-allowed' : ''\" [class.disabled]=\"config.disabled\"\r\n [class.read-only]=\"config.readOnly\" title=\"{{config.valuePrefix +''+value+''+config.valueSuffix}}\">\r\n <ng-container *ngIf=\"!config.isRangeMode\">\r\n <span class=\"value-prefix\">{{config.valuePrefix}}</span>\r\n <span class=\"value\">{{ value }}</span>\r\n <span class=\"value-suffix\">{{config.valueSuffix}}</span>\r\n </ng-container>\r\n <ng-container *ngIf=\"config.isRangeMode\">\r\n <span class=\"value\">{{config.rangeStartValue}} : {{config.rangeEndValue}}</span>\r\n </ng-container>\r\n </div>\r\n\r\n <!-- increment-decrement button -->\r\n <div class=\"arc-buttons\" *ngIf=\"!config.isRangeMode && config.showButtons\">\r\n <button mat-mini-fab color=\"secondary\" (click)=\"decrement()\" [disabled]=\"config.disabled || config.readOnly\" (keydown)=\"onKeyDown($event)\"\r\n [attr.aria-label]=\"getLabel('decrementButton')\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n \r\n <button mat-mini-fab color=\"secondary\" (click)=\"increment()\" [disabled]=\"config.disabled || config.readOnly\" (keydown)=\"onKeyDown($event)\"\r\n [attr.aria-label]=\"getLabel('incrementButton')\">\r\n <mat-icon>add</mat-icon>\r\n </button>\r\n \r\n </div>\r\n</div>", styles: [".knob-container{position:relative;padding-bottom:10px}svg{width:100%;height:100%;outline:none}.progress-value{left:50%;font-size:24px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%)}.progress-value.arc{position:absolute;top:45%}.progress-value.horizontal,.progress-value.vertical{position:relative;display:flex;justify-content:center;align-items:center;padding-top:20px}.handle{cursor:pointer}.disabled{opacity:.6;pointer-events:none}.read-only{opacity:.8}.arc-buttons{display:flex;justify-content:center;gap:1rem;margin-top:-10px}.arc-buttons button{padding:6px;width:35px;height:35px;font-size:1rem;cursor:pointer;border:none;border-radius:4px;transition:background .2s ease;box-shadow:0 0 1px 1px #ddd!important}::ng-deep .mat-mdc-mini-fab:not(.mdc-fab--extended) .mdc-fab__ripple{border-radius:0!important;-webkit-border-radius:0!important;-moz-border-radius:0!important;-ms-border-radius:0!important;-o-border-radius:0!important}.arc-buttons button:disabled{opacity:.6;cursor:not-allowed}.tooltip{position:absolute;background:#333;color:#fff;padding:4px 8px;border-radius:4px;font-size:12px;pointer-events:none;white-space:nowrap;transform:translate(-50%,-100%);opacity:0;transition:opacity .3s ease}.tooltip.show{opacity:1}.main-path{transition:all 1s ease;-webkit-transition:all 1s ease;-moz-transition:all 1s ease;-ms-transition:all 1s ease;-o-transition:all 1s ease}.hover-animate:hover .main-path{filter:url(#glow);-webkit-filter:url(#glow)}\n"] }]
546
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { bgArcRef: [{
547
- type: ViewChild,
548
- args: ['bgArc']
549
- }], progressArcRef: [{
550
- type: ViewChild,
551
- args: ['progressArc']
552
- }], handleRef: [{
553
- type: ViewChild,
554
- args: ['handle']
555
- }], horizontalLineRef: [{
556
- type: ViewChild,
557
- args: ['horizontalLine']
558
- }], verticalLineRef: [{
559
- type: ViewChild,
560
- args: ['verticalLine']
561
- }], rucEvent: [{
562
- type: Output
563
- }], customTheme: [{
564
- type: Input
565
- }], rucInputData: [{
566
- type: Input
567
- }], stopDrag: [{
568
- type: HostListener,
569
- args: ['window:mouseup']
570
- }, {
571
- type: HostListener,
572
- args: ['window:touchend']
573
- }], onMove: [{
574
- type: HostListener,
575
- args: ['window:mousemove', ['$event']]
576
- }, {
577
- type: HostListener,
578
- args: ['window:touchmove', ['$event']]
579
- }] } });
580
-
581
- class RuclibKnobModule {
582
- }
583
- RuclibKnobModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RuclibKnobModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
584
- RuclibKnobModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: RuclibKnobModule, declarations: [RuclibKnobComponent], imports: [CommonModule,
585
- FormsModule,
586
- ReactiveFormsModule,
587
- MatButtonModule,
588
- MatIconModule], exports: [RuclibKnobComponent] });
589
- RuclibKnobModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RuclibKnobModule, imports: [CommonModule,
590
- FormsModule,
591
- ReactiveFormsModule,
592
- MatButtonModule,
593
- MatIconModule] });
594
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RuclibKnobModule, decorators: [{
595
- type: NgModule,
596
- args: [{
597
- imports: [
598
- CommonModule,
599
- FormsModule,
600
- ReactiveFormsModule,
601
- MatButtonModule,
602
- MatIconModule
603
- ],
604
- declarations: [
605
- RuclibKnobComponent
606
- ],
607
- exports: [RuclibKnobComponent],
608
- }]
609
- }] });
610
-
611
- ;
612
-
613
- /**
614
- * Generated bundle index. Do not edit.
615
- */
616
-
617
- export { RuclibKnobComponent, RuclibKnobModule };
618
- //# sourceMappingURL=ruc-lib-knob.mjs.map