@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.
package/README.md CHANGED
@@ -2,107 +2,181 @@
2
2
 
3
3
  A component for creating a custom knob with different shapes like arc, vertical slider & horizontal slider where user can adjust the value by sliding a handle on arc or by sliding a handle on vertical or horizonatl slider.
4
4
 
5
- # Features
6
-
7
- - User is allowed to add the knob of their choise from any of these: Arc, Vertical or Horizontal slider.
8
- - User is allowed to adjust the width (stroke) of the arc or slider line.
9
- - User is allowed to set size, color and width of the knob.
10
- - User is allowed to set the font-size, weight and color of value text.
11
- - User is allowed to set min and max value of range.
12
- - User is allowed to custom text before and after the value.
13
- - User is allowed to toggle the visibility of custom buttons to increment and decrement the value.
14
- - User is allowed to toggle the readonly and disabled mode.
15
- - User is allowed to toggle the visibility of tooltip.
16
- - User is allowed to adjust the value by using arrow keys of keyboard.
17
- - User is allowed to do some actions on these events onBlur, onFocus, onChange, onDragStart & onDragEnd.
18
-
19
-
20
5
  # Installation guide
21
6
 
22
- # Install complete library
23
-
24
- `npm install @uxpractice/ruc-lib`
7
+ To use the Knob component, you can install the entire RUC library or just this specific component.
25
8
 
26
- # Install individual component
9
+ ### Install the Entire Library
10
+ ```bash
11
+ npm install @uxpractice/ruc-lib
12
+ ```
27
13
 
28
- If users only need the knob component, they can install it separately
29
- `npm install @ruc-lib/knob`
14
+ ### Install Individual Component
30
15
 
31
- # Usage
16
+ If you only need the Knob component
17
+ ```bash
18
+ npm install @ruc-lib/knob
19
+ ```
32
20
 
33
- here path of the scss file is subject to change as per choice of the installation
34
21
 
35
- for library
36
- `@import "../node_modules/@ruc-lib/knob/lib/knob.scss";`
22
+ # Version Compatibility
23
+
24
+ Please ensure you install the correct version of `@ruc-lib/knob` based on your Angular version.
25
+
26
+ | Angular Version | Compatible `@ruc-lib/knob` Version |
27
+ |--------------------|------------------------------------------------------|
28
+ | 15.x.x | `npm install @ruc-lib/knob@^3.0.0` |
29
+ | 16.x.x | `npm install @ruc-lib/knob@^3.0.0` |
30
+
31
+
32
+ ## Usage
33
+ ### 1. Import the Component
34
+ In your Angular component file (e.g., `app.component.ts`), import the `RuclibKnobComponent`:
35
+
36
+ ```typescript
37
+ import { Component } from '@angular/core';
38
+
39
+ // For Complete Library
40
+ import { RuclibKnobComponent } from '@uxpractice/ruc-lib/knob';
41
+
42
+ // For Individual Package
43
+ import { RuclibKnobComponent } from '@ruc-lib/knob';
44
+
45
+ @Component({
46
+ selector: 'app-root',
47
+ imports: [RuclibKnobComponent],
48
+ templateUrl: './app.component.html',
49
+ })
50
+ export class AppComponent {
51
+ // Component code here
52
+ }
53
+ ```
37
54
 
38
- for seperate package
39
- `@import "../node_modules/@uxpractice/ruc-lib/knob/lib/knob.scss";`
55
+ ### 2. Use the Component
56
+ In your component's template, use the `<uxp-ruclib-knob>` selector and pass the configuration object to the `rucInputData` input.
40
57
 
41
- # import required modules
58
+ ```html
59
+ <uxp-ruclib-knob
60
+ [rucInputData]="knobConfig"
61
+ [customTheme]="customTheme"
62
+ (rucEvent)="passEvent($event)">
63
+ </uxp-ruclib-knob>
64
+ ```
42
65
 
43
- for library
44
- `import { RuclibKnobModule } from '@uxpractice/ruc-lib/knob';`
66
+ ## API Reference
67
+
68
+ ### Component Inputs
69
+ | Input | Type | Description |
70
+ |----------------|--------------------|---------------------------------------------------|
71
+ | `rucInputData` | `knobConfig` | The main configuration object for the knob. |
72
+ | `customTheme` | `string` | An optional CSS class for custom theming. |
73
+
74
+ ### Component Outputs
75
+ | Output | Type | Description |
76
+ |-----------|-----------|---------------------------------------------------|
77
+ | `rucEvent`| `any` | Emits events related to knob actions. |
78
+
79
+
80
+ ### knobConfig
81
+
82
+ This is the main configuration object for the Knob component.
83
+ | Property | Type | Description |
84
+ |-----------------------|-------------------------|----------------------------------------------------------------------------------------|
85
+ | `min` | `number` | Sets the minimum value of the knob. |
86
+ | `max` | `number` | Sets the maximum value of the knob. |
87
+ | `step` | `number` | Sets the increment/decrement step for the knob's value. |
88
+ | `size` | `number` | Sets the overall size (width and height) of the knob in pixels. |
89
+ | `valueColor` | `string` | Sets the color of the displayed value text. |
90
+ | `strokeBackground` | `string` | Sets the background color of the knob's track (the non-progress part). |
91
+ | `progressBackground` | `string \| string[]` | Sets the color of the progress indicator. Can be a single color or an array of colors. |
92
+ | `strokeWidth` | `number` | Sets the width of the knob's track and progress indicator. |
93
+ | `valueSize` | `number` | Sets the font size of the displayed value text. |
94
+ | `valueWeight` | `string` | Sets the font weight of the displayed value text (e.g., 'normal', 'bold'). |
95
+ | `showHandle` | `boolean` | Toggles the visibility of the knob's handle. |
96
+ | `handleBackground` | `string` | Sets the background color of the knob's handle. |
97
+ | `handleBorderColor` | `string` | Sets the border color of the knob's handle. |
98
+ | `handleBorderWidth` | `number` | Sets the border width of the knob's handle. |
99
+ | `roundedCorner` | `boolean` | Applies rounded corners to the knob's track and progress. |
100
+ | `valuePrefix` | `string` | Text to display before the value. |
101
+ | `valueSuffix` | `string` | Text to display after the value. |
102
+ | `readOnly` | `boolean` | If true, the knob's value cannot be changed by user interaction. |
103
+ | `disabled` | `boolean` | If true, the knob is completely inactive and unchangeable. |
104
+ | `enableTooltip` | `boolean` | Toggles the visibility of a tooltip displaying the current value on hover/drag. |
105
+ | `animateOnHover` | `boolean` | Enables a subtle animation effect when the user hovers over the knob. |
106
+ | `isRangeMode` | `boolean` | If true, the knob operates in a range selection mode with two handles. |
107
+ | `rangeStartValue` | `number` | Sets the starting value for the range when `isRangeMode` is true. |
108
+ | `rangeEndValue` | `number` | Sets the ending value for the range when `isRangeMode` is true. |
109
+ | `showButtons` | `boolean` | Toggles the visibility of increment and decrement buttons. |
110
+
111
+ ## Example Configuration
112
+
113
+ Here's an example of how to configure the Knob component in your component's TypeScript file.
114
+
115
+ ```typescript
116
+ import { Component } from '@angular/core';
117
+
118
+ // For Complete Library
119
+ import { KnobConfig } from '@uxpractice/ruc-lib/knob';
120
+
121
+ // For Individual package
122
+ import { KnobConfig } from '@ruclib/knob';
123
+
124
+ @Component({
125
+ selector: 'app-root',
126
+ templateUrl: './app.component.html',
127
+ })
128
+ export class AppComponent {
129
+ knobConfig: KnobConfig = {
130
+ min: 0,
131
+ max: 100,
132
+ step: 1,
133
+ size: 200,
134
+ strokeWidth: 20,
135
+ valueWeight: 'bold',
136
+ showHandle: true,
137
+ handleBackground: '#fff',
138
+ handleBorderColor: '#007bff',
139
+ handleBorderWidth: 2,
140
+ roundedCorner: true,
141
+ valuePrefix: '$',
142
+ valueSuffix: '',
143
+ readOnly: false,
144
+ disabled: false,
145
+ enableTooltip: true,
146
+ animateOnHover: true,
147
+ isRangeMode: false,
148
+ rangeStartValue: 0,
149
+ rangeEndValue:100,
150
+ showButtons: true,
151
+ };
45
152
 
46
- for seperate package
47
- `import { RuclibKnobModule } from '@ruc-lib/knob';`
153
+ passEvent(event: any) {
154
+ console.log('Knob Event:', event);
155
+ }
156
+ }
157
+ ```
48
158
 
49
- # use component selector
159
+ > ⚠️ **IMPORTANT: Custom Theme Usage in Angular Material**
50
160
 
51
- ```
52
- <uxp-ruclib-knob [rucInputData]="knobConfig" [customTheme]="customTheme"
53
- (rucEvent)="passEvent($event)"></uxp-ruclib-knob>
54
- ```
161
+ When implementing **custom themes**, such as:
55
162
 
163
+ ```scss
164
+ .custom-theme-1 {
165
+ @include angular-material-theme($custom-theme);
166
+ }
56
167
 
57
- # Input and Output
58
-
59
- # Inputs
60
- rucInputData -> It is the configuration input to configure the knob
61
-
62
- customTheme -> It is the name of the theme.
63
-
64
- # Output
65
-
66
- rucEvent -> is the event which will be fired when any change is made in knob component
67
-
68
- # rucInputData (sample object)
69
-
70
- # Detail definition of the each property can be found in type definition file.
71
-
72
- ```
73
- knobConfig = {
74
- min:<number> 0,
75
- max:<number> 100,
76
- step:<number> 1,
77
- size:<number> 150,
78
- valueColor:<string> '',
79
- strokeBackground:<string> 'lightblue',
80
- progressBackground: <string | string[]> 'blue', // 'green' | ['green'] | ['red', 'blue', 'green', 'black', 'orange'],
81
- strokeWidth:<number> 15,
82
- valueSize:<number> 20,
83
- valueWeight:<string> 'normal',
84
- showHandle:<boolean> true,
85
- handleBackground:<string> 'lightblue',
86
- handleBorderColor:<string> 'blue',
87
- handleBorderWidth:<number> 4,
88
- roundedCorner:<boolean> true,
89
- valuePrefix:<string> '',
90
- valueSuffix:<string> '',
91
- readOnly:<boolean> false,
92
- disabled:<boolean> false,
93
- enableTooltip:<boolean> false,
94
- animateOnHover:<boolean> false,
95
- isRangeMode:<boolean> false,
96
- rangeStartValue:<number> 25,
97
- rangeEndValue:<number> 75,
98
- showButtons:<boolean> false,
99
- knobType:<'horizontal' | 'vertical' | 'arc'> 'arc' // 'horizontal' | 'vertical' | 'arc'
100
- };
168
+ // You must also include the typography mixin to ensure text styles are applied correctly as shown below:
169
+ .custom-theme-1 {
170
+ @include angular-material-theme($custom-theme);
171
+ @include mat.typography-level($theme-custom-typography-name, body-1);
172
+ }
101
173
  ```
102
174
 
103
175
 
104
- # Contribution
176
+ ## Contribution
177
+
105
178
  Contributions are welcome! Feel free to open issues or pull requests for any enhancements or fixes.
106
179
 
107
- # Acknowledgements
108
- Thank you for choosing the Knob Component Library. If you have any feedback or suggestions, please let us know!
180
+ ## Acknowledgements
181
+
182
+ Thank you for choosing the Knob component. If you have any feedback or suggestions, please let us know!