@ruc-lib/knob 3.1.0 → 3.2.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.
@@ -0,0 +1,275 @@
1
+ import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChanges } from '@angular/core';
2
+ import { KnobConfig } from '../../models/knob.interface';
3
+ import { ControlValueAccessor } from '@angular/forms';
4
+ import * as i0 from "@angular/core";
5
+ export declare class RuclibKnobComponent implements ControlValueAccessor, OnInit, AfterViewInit, OnChanges {
6
+ private cdr;
7
+ bgArcRef: ElementRef<SVGPathElement>;
8
+ progressArcRef: ElementRef<SVGPathElement>;
9
+ handleRef: ElementRef<SVGCircleElement>;
10
+ horizontalLineRef: ElementRef<SVGLineElement>;
11
+ verticalLineRef: ElementRef<SVGLineElement>;
12
+ rucEvent: EventEmitter<any>;
13
+ customTheme?: string;
14
+ rucInputData: KnobConfig;
15
+ activeHandle: 'start' | 'end' | '';
16
+ value: number;
17
+ dragging: boolean;
18
+ centerX: number;
19
+ centerY: number;
20
+ radius: number;
21
+ startAngle: number;
22
+ endAngle: number;
23
+ arcLength: number;
24
+ changeColorAfter: number;
25
+ tooltipX: number;
26
+ tooltipY: number;
27
+ showTooltip: boolean;
28
+ hovering: boolean;
29
+ config: {
30
+ min: number;
31
+ max: number;
32
+ step: number;
33
+ size: number;
34
+ valueColor: string;
35
+ strokeBackground: string;
36
+ progressBackground: string | string[];
37
+ strokeWidth: number;
38
+ valueSize: number;
39
+ valueWeight: string;
40
+ showHandle: boolean;
41
+ handleBackground: string;
42
+ handleBorderColor: string;
43
+ handleBorderWidth: number;
44
+ roundedCorner: boolean;
45
+ valuePrefix: string;
46
+ valueSuffix: string;
47
+ readOnly: boolean;
48
+ disabled: boolean;
49
+ enableTooltip: boolean;
50
+ animateOnHover: boolean;
51
+ isRangeMode: boolean;
52
+ rangeStartValue: number;
53
+ rangeEndValue: number;
54
+ showButtons: boolean;
55
+ knobType: "arc" | "horizontal" | "vertical";
56
+ };
57
+ private onTouched;
58
+ private onChange;
59
+ constructor(cdr: ChangeDetectorRef);
60
+ /**
61
+ * handling form control binding to write value
62
+ * @param val
63
+ */
64
+ writeValue(val: number): void;
65
+ /**
66
+ * registering onChange method to use as form control
67
+ * @param fn
68
+ */
69
+ registerOnChange(fn: () => void): void;
70
+ /**
71
+ * registering onTouch method to use as form control
72
+ * @param fn
73
+ */
74
+ registerOnTouched(fn: () => void): void;
75
+ /**
76
+ * registering disabled state
77
+ * @param isDisabled
78
+ */
79
+ setDisabledState(isDisabled: boolean): void;
80
+ /**
81
+ * handling input data changes
82
+ * updating default config with user provided config
83
+ * @param changes
84
+ */
85
+ ngOnChanges(changes: SimpleChanges): void;
86
+ /**
87
+ * handling change on component initilization
88
+ */
89
+ ngOnInit(): void;
90
+ /**
91
+ * handling change after view initilization
92
+ */
93
+ ngAfterViewInit(): void;
94
+ /**
95
+ * handling change when dragin on svg
96
+ * @returns
97
+ */
98
+ startDrag(): void;
99
+ /**
100
+ * rounding value to increment or decrement based on provide config value for step
101
+ * @param value
102
+ * @returns
103
+ */
104
+ roundToStep(value: number): number;
105
+ /**
106
+ * adjusting default value within min & max value when its provide out of range
107
+ */
108
+ adjustDefaultValue(): void;
109
+ /**
110
+ * handle changes on mouseUp and touchEnd event
111
+ */
112
+ stopDrag(): void;
113
+ /**
114
+ * handle changes on mouseMove and touch event
115
+ * @param event
116
+ * @returns
117
+ */
118
+ onMove(event: MouseEvent | TouchEvent): void;
119
+ /**
120
+ * handling change on main svg click
121
+ * @param event
122
+ * @returns
123
+ */
124
+ onSvgClick(event: MouseEvent | TouchEvent): void;
125
+ /**
126
+ * get ref of active svg element for different type of knobs
127
+ * @returns
128
+ */
129
+ getTargetSvg(): SVGElement | null;
130
+ /**
131
+ * updating progrees value while dragging the handle on stroke bar
132
+ * @param e
133
+ * @returns
134
+ */
135
+ setProgressFromEvent(e: MouseEvent | TouchEvent): void;
136
+ /**
137
+ * updating svg progress based on value changes
138
+ * @returns
139
+ */
140
+ updateArc(): void;
141
+ /**
142
+ * return maximum value out of min & max range
143
+ * @param val
144
+ * @param min
145
+ * @param max
146
+ * @returns
147
+ */
148
+ clamp(val: number, min: number, max: number): number;
149
+ /**
150
+ * getting calulated point from polar coordinates to cartesian coordinates
151
+ * @param cx
152
+ * @param cy
153
+ * @param r
154
+ * @param angleDeg
155
+ * @returns
156
+ */
157
+ polarToCartesian(cx: number, cy: number, r: number, angleDeg: number): {
158
+ x: number;
159
+ y: number;
160
+ };
161
+ /**
162
+ * getting radius for arc handle based on stroke width
163
+ * @returns
164
+ */
165
+ getRadius(): number;
166
+ /**
167
+ * getting svg box size based on different knob shapes
168
+ * @returns
169
+ */
170
+ getSvgViewBoxSize(): string;
171
+ /**
172
+ * geeting dynamic bg color for progress stroke based on provide config for "progressBackground"
173
+ */
174
+ get progressColor(): string;
175
+ /**
176
+ * getting coordinates for arc based on provided inputs
177
+ * @param cx
178
+ * @param cy
179
+ * @param r
180
+ * @param start
181
+ * @param end
182
+ * @returns
183
+ */
184
+ describeArc(cx: number, cy: number, r: number, start: number, end: number): string;
185
+ /**
186
+ * getting calculated angle for arc progress based on provided input
187
+ * @param x
188
+ * @param y
189
+ * @returns
190
+ */
191
+ getAngleFromPoint(x: number, y: number): number | null;
192
+ /**
193
+ * increment value on click on button
194
+ * @returns
195
+ */
196
+ increment(): void;
197
+ /**
198
+ * decrement value on click on button
199
+ * @returns
200
+ */
201
+ decrement(): void;
202
+ /**
203
+ * change value using arrow keys for accessibility
204
+ * @param event
205
+ * @returns
206
+ */
207
+ onKeyDown(event: KeyboardEvent): void;
208
+ /**
209
+ * geeting arc coordinated for range selection mode
210
+ * @returns
211
+ */
212
+ getRangeArcPath(): string;
213
+ /**
214
+ * handling mousedown when range mode is enabled
215
+ * @param event
216
+ * @param handleType
217
+ * @returns
218
+ */
219
+ onHandleMouseDown(event: MouseEvent, handleType: 'start' | 'end'): void;
220
+ /**
221
+ * getting x & y to update handle position when dragging
222
+ * @param value
223
+ * @returns
224
+ */
225
+ getHandlePosition(value: number): {
226
+ x: number;
227
+ y: number;
228
+ };
229
+ /**
230
+ * geeting handle position for horizontal line
231
+ * @param value
232
+ * @returns
233
+ */
234
+ getHorizontalHandleX(value: number): number;
235
+ /**
236
+ * geeting start position for horizontal line
237
+ * @param value
238
+ * @returns
239
+ */
240
+ getHorizontalLineStartX(): number;
241
+ /**
242
+ * geeting end position for horizontal line
243
+ * @param value
244
+ * @returns
245
+ */
246
+ getHorizontalLineEndX(): number;
247
+ /**
248
+ * geeting handle position for vertical line
249
+ * @param value
250
+ * @returns
251
+ */
252
+ getVerticalHandleY(value: number): number;
253
+ /**
254
+ * geeting start position for vertical line
255
+ * @param value
256
+ * @returns
257
+ */
258
+ getVerticalLineStartY(): number;
259
+ /**
260
+ * get output to be emitted based on range mode
261
+ * @returns
262
+ */
263
+ getEventOutput(): number | {
264
+ start: number;
265
+ end: number;
266
+ };
267
+ /**
268
+ * get correct page label from object
269
+ * @param labelName
270
+ * @returns string
271
+ */
272
+ getLabel(labelName: string): string;
273
+ static ɵfac: i0.ɵɵFactoryDeclaration<RuclibKnobComponent, never>;
274
+ static ɵcmp: i0.ɵɵComponentDeclaration<RuclibKnobComponent, "uxp-ruclib-knob", never, { "customTheme": "customTheme"; "rucInputData": "rucInputData"; }, { "rucEvent": "rucEvent"; }, never, never, false, never>;
275
+ }
@@ -0,0 +1,11 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./ruclib-knob/ruclib-knob.component";
3
+ import * as i2 from "@angular/common";
4
+ import * as i3 from "@angular/forms";
5
+ import * as i4 from "@angular/material/button";
6
+ import * as i5 from "@angular/material/icon";
7
+ export declare class RuclibKnobModule {
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<RuclibKnobModule, never>;
9
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RuclibKnobModule, [typeof i1.RuclibKnobComponent], [typeof i2.CommonModule, typeof i3.FormsModule, typeof i3.ReactiveFormsModule, typeof i4.MatButtonModule, typeof i5.MatIconModule], [typeof i1.RuclibKnobComponent]>;
10
+ static ɵinj: i0.ɵɵInjectorDeclaration<RuclibKnobModule>;
11
+ }
@@ -0,0 +1,32 @@
1
+ export declare const DefaultKnobConfig: {
2
+ min: number;
3
+ max: number;
4
+ step: number;
5
+ size: number;
6
+ valueColor: string;
7
+ strokeBackground: string;
8
+ progressBackground: string | string[];
9
+ strokeWidth: number;
10
+ valueSize: number;
11
+ valueWeight: string;
12
+ showHandle: boolean;
13
+ handleBackground: string;
14
+ handleBorderColor: string;
15
+ handleBorderWidth: number;
16
+ roundedCorner: boolean;
17
+ valuePrefix: string;
18
+ valueSuffix: string;
19
+ readOnly: boolean;
20
+ disabled: boolean;
21
+ enableTooltip: boolean;
22
+ animateOnHover: boolean;
23
+ isRangeMode: boolean;
24
+ rangeStartValue: number;
25
+ rangeEndValue: number;
26
+ showButtons: boolean;
27
+ knobType: "arc" | "horizontal" | "vertical";
28
+ };
29
+ export declare const DEFAULT_LABELS: {
30
+ incrementButton: string;
31
+ decrementButton: string;
32
+ };
@@ -0,0 +1,157 @@
1
+ export interface KnobConfig {
2
+ /**
3
+ * Defines the minimum value of the knob.
4
+ * @type {number}
5
+ * @default 0
6
+ */
7
+ min?: number;
8
+ /**
9
+ * Defines the maximum value of the knob.
10
+ * @type {number}
11
+ * @default 100
12
+ */
13
+ max?: number;
14
+ /**
15
+ * Defines the step size for incrementing/decrementing the knob value.
16
+ * @type {number}
17
+ * @default 1
18
+ */
19
+ step?: number;
20
+ /**
21
+ * Defines the size (width and height) of the knob in pixels.
22
+ * @type {number}
23
+ * @default 150
24
+ */
25
+ size?: number;
26
+ /**
27
+ * Defines the color of the displayed value.
28
+ * @type {string}
29
+ * @default ''
30
+ */
31
+ valueColor?: string;
32
+ /**
33
+ * Defines the font weight of the displayed value.
34
+ * @type {string}
35
+ * @default 'normal'
36
+ */
37
+ valueWeight?: string;
38
+ /**
39
+ * Defines the font size of the displayed value in pixels.
40
+ * @type {number}
41
+ * @default 20
42
+ */
43
+ valueSize?: number;
44
+ /**
45
+ * Defines the background color of the knob's stroke.
46
+ * @type {string}
47
+ * @default 'lightblue'
48
+ */
49
+ strokeBackground?: string;
50
+ /**
51
+ * Defines the background color of the progress stroke. Can be a single color or an array of colors for gradient.
52
+ * @type {string | string[]}
53
+ * @default 'blue'
54
+ */
55
+ progressBackground?: string | string[];
56
+ /**
57
+ * Defines the width of the knob's stroke in pixels.
58
+ * @type {number}
59
+ * @default 15
60
+ */
61
+ strokeWidth?: number;
62
+ /**
63
+ * Specifies whether the corners of the progress stroke should be rounded.
64
+ * @type {boolean}
65
+ * @default true
66
+ */
67
+ roundedCorner?: boolean;
68
+ /**
69
+ * Specifies whether a handle should be displayed on the knob.
70
+ * @type {boolean}
71
+ * @default true
72
+ */
73
+ showHandle?: boolean;
74
+ handleBackground?: string;
75
+ /**
76
+ * Defines the border color of the handle.
77
+ * @type {string}
78
+ * @default 'blue'
79
+ */
80
+ handleBorderColor?: string;
81
+ /**
82
+ * Defines the border width of the handle.
83
+ * @type {number}
84
+ * @default 4
85
+ */
86
+ handleBorderWidth?: number;
87
+ /**
88
+ * Defines the prefix for the displayed value (e.g., '$').
89
+ * @type {string}
90
+ * @default ''
91
+ */
92
+ valuePrefix?: string;
93
+ /**
94
+ * Defines the suffix for the displayed value (e.g., '%').
95
+ * @type {string}
96
+ * @default ''
97
+ */
98
+ valueSuffix?: string;
99
+ /**
100
+ * Specifies whether the knob is read-only.
101
+ * @type {boolean}
102
+ * @default false
103
+ */
104
+ readOnly?: boolean;
105
+ /**
106
+ * Specifies whether the knob is disabled.
107
+ * @type {boolean}
108
+ * @default false
109
+ */
110
+ disabled?: boolean;
111
+ /**
112
+ * Specifies whether a tooltip should be enabled for the knob.
113
+ * @type {boolean}
114
+ * @default false
115
+ */
116
+ enableTooltip?: boolean;
117
+ /**
118
+ * Specifies whether the knob animates on hover.
119
+ * @type {boolean}
120
+ * @default false
121
+ */
122
+ animateOnHover?: boolean;
123
+ /**
124
+ * Specifies whether the knob operates in range mode, allowing selection of a value range.
125
+ * @type {boolean}
126
+ * @default false
127
+ */
128
+ isRangeMode?: boolean;
129
+ /**
130
+ * Defines the starting value for the range when `isRangeMode` is true.
131
+ * @type {number}
132
+ * @default 25
133
+ */
134
+ rangeStartValue?: number;
135
+ /**
136
+ * Defines the ending value for the range when `isRangeMode` is true.
137
+ * @type {number}
138
+ * @default 75
139
+ */
140
+ rangeEndValue?: number;
141
+ /**
142
+ * Specifies whether increment/decrement buttons should be shown.
143
+ * @type {boolean}
144
+ * @default false
145
+ */
146
+ showButtons?: boolean;
147
+ /**
148
+ * Defines the type of knob.
149
+ * @type {'arc' | 'horizontal' | 'vertical'}
150
+ * @default 'arc'
151
+ */
152
+ knobType?: 'arc' | 'horizontal' | 'vertical';
153
+ }
154
+ export interface KnobRangeValue {
155
+ start: number;
156
+ end: number;
157
+ }
package/package.json CHANGED
@@ -1,22 +1,29 @@
1
1
  {
2
2
  "name": "@ruc-lib/knob",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
+ "license": "MIT",
4
5
  "peerDependencies": {
5
- "@angular/common": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
6
- "@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
7
- "@angular/material": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
8
- "@angular/platform-browser": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
9
- "@angular/animations": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
10
- "@angular/forms": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
11
- "ngx-pagination": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0",
12
- "rxjs": ">=7.5.0 <8.0.0",
13
- "zone.js": "^0.13.0 || ^0.14.0"
6
+ "@angular/material": "^15.2.0",
7
+ "@angular/animations": ">=15.0.0 <18.0.0",
8
+ "@angular/core": ">=15.0.0 <18.0.0",
9
+ "@angular/common": ">=15.0.0 <18.0.0",
10
+ "@angular/forms": ">=15.0.0 <18.0.0",
11
+ "ngx-pagination": "^6.0.3",
12
+ "rxjs": ">=6.5.0 <8.0.0",
13
+ "zone.js": ">=0.11.4 <0.14.0"
14
14
  },
15
15
  "dependencies": {
16
16
  "tslib": "^2.3.0"
17
17
  },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
18
21
  "sideEffects": false,
19
- "module": "fesm2022/ruc-lib-knob.mjs",
22
+ "module": "fesm2015/ruc-lib-knob.mjs",
23
+ "es2020": "fesm2020/ruc-lib-knob.mjs",
24
+ "esm2020": "esm2020/ruc-lib-knob.mjs",
25
+ "fesm2020": "fesm2020/ruc-lib-knob.mjs",
26
+ "fesm2015": "fesm2015/ruc-lib-knob.mjs",
20
27
  "typings": "index.d.ts",
21
28
  "exports": {
22
29
  "./package.json": {
@@ -24,7 +31,11 @@
24
31
  },
25
32
  ".": {
26
33
  "types": "./index.d.ts",
27
- "default": "./fesm2022/ruc-lib-knob.mjs"
34
+ "esm2020": "./esm2020/ruc-lib-knob.mjs",
35
+ "es2020": "./fesm2020/ruc-lib-knob.mjs",
36
+ "es2015": "./fesm2015/ruc-lib-knob.mjs",
37
+ "node": "./fesm2015/ruc-lib-knob.mjs",
38
+ "default": "./fesm2020/ruc-lib-knob.mjs"
28
39
  }
29
40
  }
30
41
  }