@libs-ui/components-buttons-tab 0.2.357-8 → 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 +20 -30
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
`example.component.ts`
|
|
60
60
|
|
|
61
61
|
```typescript
|
|
62
|
-
import { Component,
|
|
62
|
+
import { ChangeDetectionStrategy, Component, model } from '@angular/core';
|
|
63
63
|
import { LibsUiComponentsButtonsTabComponent, IButtonTab } from '@libs-ui/components-buttons-tab';
|
|
64
64
|
|
|
65
65
|
@Component({
|
|
@@ -78,9 +78,9 @@ export class ExampleComponent {
|
|
|
78
78
|
{ key: 'settings', label: 'Settings', type: 'orange' },
|
|
79
79
|
];
|
|
80
80
|
|
|
81
|
-
protected handlerKeySelected(
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
protected handlerKeySelected(key: string): void {
|
|
82
|
+
// key: string — key của tab vừa chọn (đã được cập nhật vào selectedKey qua two-way binding)
|
|
83
|
+
this.selectedKey.set(key);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
```
|
|
@@ -119,8 +119,8 @@ export class ExampleBadgeComponent {
|
|
|
119
119
|
{ key: 'requests', label: 'Requests', type: 'cyan', count: 105, modeCount: 'x+', maxCount: 99 },
|
|
120
120
|
];
|
|
121
121
|
|
|
122
|
-
protected handlerKeySelected(
|
|
123
|
-
|
|
122
|
+
protected handlerKeySelected(key: string): void {
|
|
123
|
+
this.selectedKey.set(key);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
```
|
|
@@ -173,8 +173,8 @@ export class ExampleDisabledComponent {
|
|
|
173
173
|
{ key: 'c', label: 'Tab C', type: 'green' },
|
|
174
174
|
];
|
|
175
175
|
|
|
176
|
-
protected handlerKeySelected(
|
|
177
|
-
|
|
176
|
+
protected handlerKeySelected(key: string): void {
|
|
177
|
+
this.selectedKey.set(key);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
```
|
|
@@ -224,8 +224,8 @@ export class ExampleOtherComponent {
|
|
|
224
224
|
{ key: 'custom-3', label: 'Custom 3', type: 'other', count: 120, modeCount: 'x+' },
|
|
225
225
|
];
|
|
226
226
|
|
|
227
|
-
protected handlerKeySelected(
|
|
228
|
-
|
|
227
|
+
protected handlerKeySelected(key: string): void {
|
|
228
|
+
this.selectedKey.set(key);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
```
|
|
@@ -243,19 +243,9 @@ export class ExampleOtherComponent {
|
|
|
243
243
|
|
|
244
244
|
| Output | Type | Mô tả | Handler TS | Binding HTML |
|
|
245
245
|
|---|---|---|---|---|
|
|
246
|
-
| `(outKeySelected)` | `string` | Emit key của tab vừa được chọn. Không emit khi tab bị disable. | `handlerKeySelected(
|
|
247
|
-
|
|
248
|
-
> **Lưu ý:** `outKeySelected` emit giá trị `string` (key của tab), không phải `Event`. Tham số trong handler là `key: string`, không phải `event: Event`. Xem ví dụ thực tế trong mục Ví dụ sử dụng ở trên — handler nhận `(event: Event)` từ DOM click nhưng `outKeySelected` truyền `key: string`.
|
|
246
|
+
| `(outKeySelected)` | `string` | Emit key của tab vừa được chọn. Không emit khi tab bị disable. | `handlerKeySelected(key: string): void { this.selectedKey.set(key); }` | `(outKeySelected)="handlerKeySelected($event)"` |
|
|
249
247
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
// HTML: (outKeySelected)="handlerTabChange($event)"
|
|
254
|
-
protected handlerTabChange(key: string): void {
|
|
255
|
-
// key là string (key của tab vừa chọn)
|
|
256
|
-
this.activeKey.set(key);
|
|
257
|
-
}
|
|
258
|
-
```
|
|
248
|
+
> **Lưu ý:** `outKeySelected` emit giá trị `string` (key của tab đã chọn), không phải DOM `Event`. Tham số trong handler PHẢI khai báo là `key: string` — không gọi được `stopPropagation()` trên giá trị này.
|
|
259
249
|
|
|
260
250
|
## Types & Interfaces
|
|
261
251
|
|
|
@@ -342,6 +332,14 @@ export type TYPE_BUTTON_TAB =
|
|
|
342
332
|
|
|
343
333
|
Có 8 màu định sẵn. Dùng `'other'` kết hợp với `[otherConfig]` để tuỳ biến màu hoàn toàn. Truyền string tuỳ ý được phép nhưng sẽ không có style mặc định nếu CSS tương ứng chưa tồn tại.
|
|
344
334
|
|
|
335
|
+
### TYPE_BADGE_MODE
|
|
336
|
+
|
|
337
|
+
`IButtonTab.modeCount` dùng type này, import từ `@libs-ui/components-badge`:
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
import { TYPE_BADGE_MODE } from '@libs-ui/components-badge';
|
|
341
|
+
```
|
|
342
|
+
|
|
345
343
|
## Lưu ý quan trọng
|
|
346
344
|
|
|
347
345
|
⚠️ **`otherConfig` chỉ áp dụng cho tab có `type = 'other'`**: Nếu bạn dùng `[otherConfig]` nhưng không có tab nào có `type = 'other'`, cấu hình này sẽ không có tác dụng. Các tab với type khác (`blue`, `green`...) không bị ảnh hưởng bởi `otherConfig`.
|
|
@@ -353,11 +351,3 @@ Có 8 màu định sẵn. Dùng `'other'` kết hợp với `[otherConfig]` đ
|
|
|
353
351
|
⚠️ **Tab bị disable không emit event**: Khi `disable = true` (toàn bộ) hoặc `item.disable = true` (từng tab), click sẽ không có tác dụng và `outKeySelected` sẽ không được emit.
|
|
354
352
|
|
|
355
353
|
⚠️ **Label được escape HTML tự động**: Giá trị `label` trong `IButtonTab` sẽ bị escape HTML trước khi hiển thị để tránh XSS. Không truyền HTML raw vào `label`.
|
|
356
|
-
|
|
357
|
-
## Demo
|
|
358
|
-
|
|
359
|
-
```bash
|
|
360
|
-
npx nx serve core-ui
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
Truy cập: `http://localhost:4500/buttons/tab`
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libs-ui/components-buttons-tab",
|
|
3
|
-
"version": "0.2.357-
|
|
3
|
+
"version": "0.2.357-9",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/core": ">=18.0.0",
|
|
6
|
-
"@libs-ui/components-badge": "0.2.357-
|
|
7
|
-
"@libs-ui/components-popover": "0.2.357-
|
|
8
|
-
"@libs-ui/utils": "0.2.357-
|
|
6
|
+
"@libs-ui/components-badge": "0.2.357-9",
|
|
7
|
+
"@libs-ui/components-popover": "0.2.357-9",
|
|
8
|
+
"@libs-ui/utils": "0.2.357-9",
|
|
9
9
|
"@ngx-translate/core": "^15.0.0"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": false,
|