@libs-ui/components-process-bar-steps 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.
- package/README.md +95 -135
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,161 +46,129 @@ export class YourComponent {}
|
|
|
46
46
|
|
|
47
47
|
## Ví dụ sử dụng
|
|
48
48
|
|
|
49
|
-
###
|
|
49
|
+
### 1. Simple Config
|
|
50
|
+
|
|
51
|
+
Cấu hình đơn giản theo số lượng bước.
|
|
50
52
|
|
|
51
53
|
```html
|
|
52
|
-
<!-- your-component.component.html -->
|
|
53
54
|
<libs_ui-components-process_bar-steps [config]="configSimple()" />
|
|
54
55
|
```
|
|
55
56
|
|
|
56
57
|
```typescript
|
|
57
|
-
|
|
58
|
-
import {
|
|
59
|
-
|
|
58
|
+
import { signal } from '@angular/core';
|
|
59
|
+
import { IProcessBarStepConfigInterface, IProcessBarStepSimpleConfigInterface } from '@libs-ui/components-process-bar-steps';
|
|
60
|
+
|
|
61
|
+
// Define Simple Config Signal
|
|
62
|
+
readonly simpleConfigSignal = signal<IProcessBarStepSimpleConfigInterface>({
|
|
63
|
+
totalStep: 4,
|
|
64
|
+
currentStep: 2,
|
|
65
|
+
completedStep: 1, // Steps <= 1 are completed
|
|
66
|
+
currentStepColor: '#3B82F6',
|
|
67
|
+
stepCompletedColor: '#10B981'
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Main Config
|
|
71
|
+
readonly configSimple = signal<IProcessBarStepConfigInterface>({
|
|
72
|
+
simpleConfig: this.simpleConfigSignal,
|
|
73
|
+
widthStep: '60px',
|
|
74
|
+
heightStep: '8px',
|
|
75
|
+
radiusStep: 4,
|
|
76
|
+
backgroundColorStep: '#E5E7EB'
|
|
77
|
+
});
|
|
78
|
+
```
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
standalone: true,
|
|
63
|
-
imports: [LibsUiComponentsProcessBarStepsComponent],
|
|
64
|
-
templateUrl: './your-component.component.html',
|
|
65
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
66
|
-
})
|
|
67
|
-
export class YourComponent {
|
|
68
|
-
private readonly simpleConfigSignal = signal<IProcessBarStepSimpleConfigInterface>({
|
|
69
|
-
totalStep: 4,
|
|
70
|
-
currentStep: 2,
|
|
71
|
-
completedStep: 1,
|
|
72
|
-
currentStepColor: '#3B82F6',
|
|
73
|
-
stepCompletedColor: '#10B981',
|
|
74
|
-
});
|
|
80
|
+
---
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
simpleConfig: this.simpleConfigSignal,
|
|
78
|
-
widthStep: '60px',
|
|
79
|
-
heightStep: '8px',
|
|
80
|
-
radiusStep: 4,
|
|
81
|
-
backgroundColorStep: '#E5E7EB',
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
```
|
|
82
|
+
### 2. Advanced Config
|
|
85
83
|
|
|
86
|
-
|
|
84
|
+
Cấu hình chi tiết từng bước với Label & Custom Color.
|
|
87
85
|
|
|
88
86
|
```html
|
|
89
|
-
<!-- your-component.component.html -->
|
|
90
87
|
<libs_ui-components-process_bar-steps [config]="configAdvanced()" />
|
|
91
88
|
```
|
|
92
89
|
|
|
93
90
|
```typescript
|
|
94
|
-
|
|
95
|
-
import {
|
|
96
|
-
import { LibsUiComponentsProcessBarStepsComponent, IProcessBarStepConfigInterface, IProcessBarStepAdvancedConfigInterface } from '@libs-ui/components-process-bar-steps';
|
|
97
|
-
|
|
98
|
-
@Component({
|
|
99
|
-
standalone: true,
|
|
100
|
-
imports: [LibsUiComponentsProcessBarStepsComponent],
|
|
101
|
-
templateUrl: './your-component.component.html',
|
|
102
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
103
|
-
})
|
|
104
|
-
export class YourComponent {
|
|
105
|
-
private readonly step1 = signal<IProcessBarStepAdvancedConfigInterface>({
|
|
106
|
-
label: 'Đặt hàng',
|
|
107
|
-
processCompleted: true,
|
|
108
|
-
processCompletedColor: '#10B981',
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
private readonly step2 = signal<IProcessBarStepAdvancedConfigInterface>({
|
|
112
|
-
label: 'Đang xử lý',
|
|
113
|
-
isCurrentProcess: true,
|
|
114
|
-
currentProcessColor: '#3B82F6',
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
private readonly step3 = signal<IProcessBarStepAdvancedConfigInterface>({
|
|
118
|
-
label: 'Đã giao',
|
|
119
|
-
processCompleted: false,
|
|
120
|
-
});
|
|
91
|
+
import { signal } from '@angular/core';
|
|
92
|
+
import { IProcessBarStepConfigInterface } from '@libs-ui/components-process-bar-steps';
|
|
121
93
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
94
|
+
// Define Advanced Steps as Signals
|
|
95
|
+
const step1 = signal({ label: 'Order Placed', processCompleted: true, processCompletedColor: '#10B981' });
|
|
96
|
+
const step2 = signal({ label: 'Processing', isCurrentProcess: true, currentProcessColor: '#3B82F6' });
|
|
97
|
+
const step3 = signal({ label: 'Shipped', processCompleted: false });
|
|
98
|
+
const step4 = signal({ label: 'Delivered', processCompleted: false });
|
|
99
|
+
|
|
100
|
+
readonly configAdvanced = signal<IProcessBarStepConfigInterface>({
|
|
101
|
+
advancedConfig: signal([step1, step2, step3, step4]),
|
|
102
|
+
positionLabel: 'bottom',
|
|
103
|
+
justifyLabel: 'center',
|
|
104
|
+
widthStep: '120px',
|
|
105
|
+
heightStep: '12px'
|
|
106
|
+
});
|
|
107
|
+
```
|
|
126
108
|
|
|
127
|
-
|
|
128
|
-
advancedConfig: signal([this.step1, this.step2, this.step3, this.step4]),
|
|
129
|
-
positionLabel: 'bottom',
|
|
130
|
-
justifyLabel: 'center',
|
|
131
|
-
widthStep: '120px',
|
|
132
|
-
heightStep: '12px',
|
|
133
|
-
radiusStep: 6,
|
|
134
|
-
});
|
|
109
|
+
---
|
|
135
110
|
|
|
136
|
-
|
|
137
|
-
protected handlerMarkShipped(): void {
|
|
138
|
-
this.step3.update((s) => ({ ...s, processCompleted: true, processCompletedColor: '#10B981' }));
|
|
139
|
-
this.step4.update((s) => ({ ...s, isCurrentProcess: true, currentProcessColor: '#3B82F6' }));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
```
|
|
111
|
+
### 3. Interactive
|
|
143
112
|
|
|
144
|
-
|
|
113
|
+
Thay đổi cấu hình realtime.
|
|
145
114
|
|
|
146
115
|
```html
|
|
147
|
-
|
|
116
|
+
<div class="controls">
|
|
117
|
+
<input type="range" [(ngModel)]="interactiveTotalSteps" min="2" max="10">
|
|
118
|
+
<input type="range" [(ngModel)]="interactiveCurrentStep" min="1" [max]="interactiveTotalSteps()">
|
|
119
|
+
<select [(ngModel)]="interactivePositionLabel">
|
|
120
|
+
<option value="top">Top</option>
|
|
121
|
+
<option value="bottom">Bottom</option>
|
|
122
|
+
<option value="inner">Inner</option>
|
|
123
|
+
</select>
|
|
124
|
+
</div>
|
|
148
125
|
<libs_ui-components-process_bar-steps [config]="configInteractive()" />
|
|
149
126
|
```
|
|
150
127
|
|
|
151
128
|
```typescript
|
|
152
|
-
|
|
153
|
-
import {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
simpleConfig: this.simpleConfigSignal,
|
|
179
|
-
positionLabel: 'top',
|
|
180
|
-
justifyLabel: 'center',
|
|
181
|
-
widthStep: '80px',
|
|
182
|
-
heightStep: '10px',
|
|
183
|
-
radiusStep: 5,
|
|
184
|
-
}));
|
|
185
|
-
|
|
186
|
-
constructor() {
|
|
187
|
-
// Đồng bộ computed → writableSignal để truyền vào config
|
|
188
|
-
effect(() => {
|
|
189
|
-
untracked(() => this.simpleConfigSignal.set(this.simpleConfigValues()));
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
protected handlerNextStep(): void {
|
|
194
|
-
this.currentStep.update((v) => Math.min(v + 1, this.totalSteps()));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
protected handlerPrevStep(): void {
|
|
198
|
-
this.currentStep.update((v) => Math.max(v - 1, 1));
|
|
199
|
-
}
|
|
129
|
+
import { signal, computed, effect, untracked } from '@angular/core';
|
|
130
|
+
import { IProcessBarStepConfigInterface, IProcessBarStepSimpleConfigInterface } from '@libs-ui/components-process-bar-steps';
|
|
131
|
+
|
|
132
|
+
// [(ngModel)] điều khiển bằng slider/select
|
|
133
|
+
readonly interactiveTotalSteps = signal(5);
|
|
134
|
+
readonly interactiveCurrentStep = signal(3);
|
|
135
|
+
readonly interactivePositionLabel = signal<'top' | 'bottom' | 'inner'>('top');
|
|
136
|
+
readonly interactiveJustifyLabel = signal<'start' | 'center' | 'end'>('center');
|
|
137
|
+
|
|
138
|
+
// simpleConfig tính toán từ các signal tương tác
|
|
139
|
+
readonly interactiveSimpleConfig = computed<IProcessBarStepSimpleConfigInterface>(() => ({
|
|
140
|
+
totalStep: this.interactiveTotalSteps(),
|
|
141
|
+
currentStep: this.interactiveCurrentStep(),
|
|
142
|
+
completedStep: this.interactiveCurrentStep() - 1,
|
|
143
|
+
currentStepColor: '#8B5CF6',
|
|
144
|
+
stepCompletedColor: '#F59E0B',
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
// Signal ghi (WritableSignal) đồng bộ từ computed qua effect() — API yêu cầu simpleConfig là WritableSignal
|
|
148
|
+
readonly interactiveSimpleConfigSignal = signal<IProcessBarStepSimpleConfigInterface>(this.interactiveSimpleConfig());
|
|
149
|
+
|
|
150
|
+
constructor() {
|
|
151
|
+
effect(() => {
|
|
152
|
+
const config = this.interactiveSimpleConfig();
|
|
153
|
+
untracked(() => this.interactiveSimpleConfigSignal.set(config));
|
|
154
|
+
});
|
|
200
155
|
}
|
|
156
|
+
|
|
157
|
+
// [config]="configInteractive()"
|
|
158
|
+
readonly configInteractive = computed<IProcessBarStepConfigInterface>(() => ({
|
|
159
|
+
simpleConfig: this.interactiveSimpleConfigSignal, // Updated via effect
|
|
160
|
+
positionLabel: this.interactivePositionLabel(),
|
|
161
|
+
justifyLabel: this.interactiveJustifyLabel(),
|
|
162
|
+
widthStep: '80px',
|
|
163
|
+
heightStep: '10px'
|
|
164
|
+
}));
|
|
201
165
|
```
|
|
202
166
|
|
|
203
|
-
|
|
167
|
+
> ⚠️ **FormsModule bắt buộc**: Ví dụ Interactive dùng `[(ngModel)]`, cần import `FormsModule` vào `imports[]` của component sử dụng.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### 4. Cấu hình Global Default Token (toàn app)
|
|
204
172
|
|
|
205
173
|
```typescript
|
|
206
174
|
// app.config.ts hoặc providers của module root
|
|
@@ -297,11 +265,3 @@ Với mỗi bước, màu nền được xác định theo thứ tự ưu tiên
|
|
|
297
265
|
⚠️ **Advanced Mode — Color Priority**: Màu `processCompletedColor` ghi đè `currentProcessColor`. Nếu một bước vừa có `processCompleted: true` vừa có `isCurrentProcess: true`, màu hoàn thành sẽ được hiển thị.
|
|
298
266
|
|
|
299
267
|
⚠️ **Global Default Token**: Dùng `PROCESS_BAR_STEPS_CONFIG_DEFAULT_TOKEN_INJECT` (từ `@libs-ui/utils`) để thiết lập giá trị mặc định cho `widthStep`, `heightStep`, `backgroundColorStep`, `radiusStep` ở cấp app — tránh lặp lại config trong từng component.
|
|
300
|
-
|
|
301
|
-
## Demo
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
npx nx serve core-ui
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Truy cập: http://localhost:4500/components/process-bar/steps
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libs-ui/components-process-bar-steps",
|
|
3
|
-
"version": "0.2.357-
|
|
3
|
+
"version": "0.2.357-9",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/core": ">=18.0.0",
|
|
6
|
-
"@libs-ui/utils": "0.2.357-
|
|
6
|
+
"@libs-ui/utils": "0.2.357-9"
|
|
7
7
|
},
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"module": "fesm2022/libs-ui-components-process-bar-steps.mjs",
|