@libs-ui/components-process-bar-standard 0.2.357-7 → 0.2.357-9

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.
Files changed (2) hide show
  1. package/README.md +78 -129
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -45,152 +45,109 @@ export class MyComponent {}
45
45
 
46
46
  ## Ví dụ sử dụng
47
47
 
48
- ### Ví dụ 1 Stack cơ bản (3 bước)
48
+ ### 1. Basic Stack
49
+
50
+ Chế độ Stack cơ bản với nhiều bước.
51
+
52
+ ```html
53
+ <libs_ui-components-process_bar-standard [config]="configBasic()" />
54
+ ```
49
55
 
50
56
  ```typescript
51
57
  import { signal } from '@angular/core';
52
- import {
53
- LibsUiComponentsProcessBarStandardComponent,
54
- IProcessBarStandardInterface,
55
- IProcessBarStandardStepInterface,
56
- } from '@libs-ui/components-process-bar-standard';
58
+ import { IProcessBarStandardInterface, IProcessBarStandardStepInterface } from '@libs-ui/components-process-bar-standard';
59
+
60
+ // Define Steps as Signals
61
+ const step1 = signal<IProcessBarStandardStepInterface>({ value: 30, color: '#EF4444', label: 'Processing' });
62
+ const step2 = signal<IProcessBarStandardStepInterface>({ value: 50, color: '#3B82F6', label: 'Done' });
63
+
64
+ // Config with nested signals
65
+ readonly configBasic = signal<IProcessBarStandardInterface>({
66
+ width: '100%',
67
+ height: '24px',
68
+ radius: 12,
69
+ totalValue: 100,
70
+ mode: 'stack',
71
+ steps: signal([step1, step2])
72
+ });
73
+ ```
57
74
 
58
- @Component({
59
- standalone: true,
60
- imports: [LibsUiComponentsProcessBarStandardComponent],
61
- template: `
62
- <libs_ui-components-process_bar-standard [config]="configStack()" />
63
- `,
64
- })
65
- export class MyComponent {
66
- private readonly stepProcessing = signal<IProcessBarStandardStepInterface>({
67
- value: 30,
68
- color: '#EF4444',
69
- label: 'Processing',
70
- });
71
- private readonly stepDone = signal<IProcessBarStandardStepInterface>({
72
- value: 50,
73
- color: '#3B82F6',
74
- label: 'Done',
75
- });
76
- private readonly stepPending = signal<IProcessBarStandardStepInterface>({
77
- value: 20,
78
- color: '#10B981',
79
- });
75
+ ---
80
76
 
81
- readonly configStack = signal<IProcessBarStandardInterface>({
82
- width: '100%',
83
- height: '24px',
84
- radius: 12,
85
- totalValue: 100,
86
- mode: 'stack',
87
- steps: signal([this.stepProcessing, this.stepDone, this.stepPending]),
88
- });
89
- }
90
- ```
77
+ ### 2. Separate Mode
78
+
79
+ Chế độ Separate với các thanh riêng biệt.
91
80
 
92
81
  ```html
93
- <libs_ui-components-process_bar-standard [config]="configStack()" />
82
+ <libs_ui-components-process_bar-standard [config]="configSeparate()" />
94
83
  ```
95
84
 
96
- ### Ví dụ 2 — Separate mode với hiển thị phần trăm
97
-
98
85
  ```typescript
99
86
  import { signal } from '@angular/core';
100
- import {
101
- LibsUiComponentsProcessBarStandardComponent,
102
- IProcessBarStandardInterface,
103
- IProcessBarStandardStepInterface,
104
- } from '@libs-ui/components-process-bar-standard';
87
+ import { IProcessBarStandardInterface } from '@libs-ui/components-process-bar-standard';
88
+
89
+ readonly configSeparate = signal<IProcessBarStandardInterface>({
90
+ width: '100%',
91
+ height: '16px',
92
+ backgroundColor: 'transparent',
93
+ radius: 8,
94
+ totalValue: 100,
95
+ mode: 'separate',
96
+ steps: signal([
97
+ signal({ value: 75, color: '#8B5CF6', label: 'Progress', showPercent: true }),
98
+ signal({ value: 45, color: '#F59E0B', label: 'Pending', showPercent: true }),
99
+ ])
100
+ });
101
+ ```
105
102
 
106
- @Component({
107
- standalone: true,
108
- imports: [LibsUiComponentsProcessBarStandardComponent],
109
- template: `
110
- <libs_ui-components-process_bar-standard [config]="configSeparate()" />
111
- `,
112
- })
113
- export class MyComponent {
114
- private readonly stepProgress = signal<IProcessBarStandardStepInterface>({
115
- value: 75,
116
- color: '#8B5CF6',
117
- label: 'Tiến độ',
118
- showPercent: true,
119
- });
120
- private readonly stepPending = signal<IProcessBarStandardStepInterface>({
121
- value: 45,
122
- color: '#F59E0B',
123
- label: 'Đang chờ',
124
- showPercent: true,
125
- });
103
+ ---
126
104
 
127
- readonly configSeparate = signal<IProcessBarStandardInterface>({
128
- width: '100%',
129
- height: '16px',
130
- backgroundColor: 'transparent',
131
- radius: 8,
132
- totalValue: 100,
133
- mode: 'separate',
134
- steps: signal([this.stepProgress, this.stepPending]),
135
- });
136
- }
137
- ```
105
+ ### 3. Interactive
106
+
107
+ Thay đổi giá trị động realtime.
138
108
 
139
109
  ```html
140
- <libs_ui-components-process_bar-standard [config]="configSeparate()" />
110
+ <div class="mb-4">
111
+ <input type="range" [(ngModel)]="interactiveValue" min="0" max="100">
112
+ </div>
113
+ <libs_ui-components-process_bar-standard [config]="configInteractive()" />
141
114
  ```
142
115
 
143
- ### Ví dụ 3 — Cập nhật realtime bằng Nested Signals
144
-
145
116
  ```typescript
146
- import { signal, computed } from '@angular/core';
147
- import {
148
- LibsUiComponentsProcessBarStandardComponent,
149
- IProcessBarStandardInterface,
150
- IProcessBarStandardStepInterface,
151
- } from '@libs-ui/components-process-bar-standard';
117
+ import { signal, computed, effect, untracked } from '@angular/core';
118
+ import { IProcessBarStandardInterface, IProcessBarStandardStepInterface } from '@libs-ui/components-process-bar-standard';
152
119
 
153
- @Component({
154
- standalone: true,
155
- imports: [LibsUiComponentsProcessBarStandardComponent],
156
- template: `
157
- <button (click)="handlerIncrement($event)">Tăng tiến độ</button>
158
- <libs_ui-components-process_bar-standard [config]="configRealtime()" />
159
- `,
160
- })
161
- export class MyComponent {
162
- private readonly currentValue = signal(40);
120
+ // [(ngModel)]="interactiveValue" — giá trị điều khiển bằng thanh trượt
121
+ readonly interactiveValue = signal(40);
122
+ readonly interactiveHeight = signal('20px');
123
+ readonly interactiveRadius = signal(10);
163
124
 
164
- private readonly stepMain = signal<IProcessBarStandardStepInterface>({
165
- value: 40,
166
- color: '#EC4899',
167
- label: 'Đang xử lý',
168
- });
125
+ // Step sở — value được đồng bộ tự động từ interactiveValue qua effect()
126
+ readonly interactiveStep = signal<IProcessBarStandardStepInterface>({ value: 40, color: '#EC4899', label: 'Dynamic Base' });
169
127
 
170
- readonly configRealtime = computed<IProcessBarStandardInterface>(() => ({
171
- width: '100%',
172
- height: '20px',
173
- radius: 10,
174
- totalValue: 100,
175
- mode: 'stack',
176
- steps: signal([this.stepMain]),
177
- }));
178
-
179
- protected handlerIncrement(event: Event): void {
180
- event.stopPropagation();
181
- const next = Math.min(this.currentValue() + 10, 100);
182
- this.currentValue.set(next);
183
- this.stepMain.update((step) => ({ ...step, value: next }));
184
- }
128
+ constructor() {
129
+ effect(() => {
130
+ const value = this.interactiveValue();
131
+ untracked(() => this.interactiveStep.update((s) => ({ ...s, value })));
132
+ });
185
133
  }
186
- ```
187
134
 
188
- ```html
189
- <button (click)="handlerIncrement($event)">Tăng tiến độ</button>
190
- <libs_ui-components-process_bar-standard [config]="configRealtime()" />
135
+ // [config]="configInteractive()" — computed config dựa trên các signal tương tác
136
+ readonly configInteractive = computed<IProcessBarStandardInterface>(() => ({
137
+ width: '100%',
138
+ height: this.interactiveHeight(),
139
+ radius: this.interactiveRadius(),
140
+ totalValue: 100,
141
+ mode: 'stack',
142
+ steps: signal([this.interactiveStep])
143
+ }));
191
144
  ```
192
145
 
193
- ### Ví dụ 4 Global default config qua Injection Token
146
+ > ⚠️ **FormsModule bắt buộc**: Ví dụ Interactive dùng `[(ngModel)]`, cần import `FormsModule` vào `imports[]` của component sử dụng.
147
+
148
+ ---
149
+
150
+ ### 4. Global default config qua Injection Token
194
151
 
195
152
  ```typescript
196
153
  import { ApplicationConfig } from '@angular/core';
@@ -318,11 +275,3 @@ export interface IProcessBarStandardStepInterface {
318
275
  ⚠️ **`showPercent` chỉ hoạt động ở chế độ `separate`**: Trong chế độ `stack`, thuộc tính `showPercent` (cả ở config lẫn từng step) không có hiệu lực vì cấu trúc layout không hỗ trợ.
319
276
 
320
277
  ⚠️ **Global default token**: Nếu inject `PROCESS_BAR_STANDARD_CONFIG_DEFAULT_TOKEN_INJECT`, các giá trị trong token sẽ là fallback khi thuộc tính tương ứng trong `[config]` không được truyền. Thứ tự ưu tiên: `config.xxx` > `tokenDefault.xxx` > hardcoded default.
321
-
322
- ## Demo
323
-
324
- ```bash
325
- npx nx serve core-ui
326
- ```
327
-
328
- Truy cập: http://localhost:4500/components/process-bar/standard
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@libs-ui/components-process-bar-standard",
3
- "version": "0.2.357-7",
3
+ "version": "0.2.357-9",
4
4
  "peerDependencies": {
5
5
  "@angular/core": ">=18.0.0",
6
- "@libs-ui/utils": "0.2.357-7"
6
+ "@libs-ui/utils": "0.2.357-9"
7
7
  },
8
8
  "sideEffects": false,
9
9
  "module": "fesm2022/libs-ui-components-process-bar-standard.mjs",