@libs-ui/components-buttons-tab 0.2.355-14 → 0.2.355-15
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 +189 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Buttons Tab Component
|
|
2
|
+
|
|
3
|
+
> Version: `0.2.355-14`
|
|
4
|
+
>
|
|
5
|
+
> Component tab dạng button, hỗ trợ nhiều màu, badge count và tuỳ biến màu riêng với type `other`.
|
|
6
|
+
|
|
7
|
+
## Giới thiệu
|
|
8
|
+
|
|
9
|
+
`LibsUiComponentsButtonsTabComponent` là standalone Angular component dùng để hiển thị danh sách tab theo dạng button. Component hỗ trợ hiển thị badge count cho từng tab và cho phép disable toàn bộ hoặc disable từng tab.
|
|
10
|
+
|
|
11
|
+
## Tính năng
|
|
12
|
+
|
|
13
|
+
- ✅ Hiển thị tab theo danh sách `items`
|
|
14
|
+
- ✅ Hỗ trợ nhiều màu tab theo `type`
|
|
15
|
+
- ✅ Hỗ trợ badge count (`count`, `modeCount`, `maxCount`)
|
|
16
|
+
- ✅ Two-way binding key đang chọn qua `[(keySelected)]`
|
|
17
|
+
- ✅ Disable toàn bộ hoặc disable từng tab item
|
|
18
|
+
- ✅ Tuỳ biến màu với `otherConfig` khi `type = 'other'`
|
|
19
|
+
- ✅ OnPush Change Detection
|
|
20
|
+
- ✅ Angular Signals
|
|
21
|
+
|
|
22
|
+
## Cài đặt
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @libs-ui/components-buttons-tab
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Import
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { Component } from '@angular/core';
|
|
32
|
+
import { LibsUiComponentsButtonsTabComponent, IButtonTab, IOtherConfig, TYPE_BUTTON_TAB } from '@libs-ui/components-buttons-tab';
|
|
33
|
+
|
|
34
|
+
@Component({
|
|
35
|
+
standalone: true,
|
|
36
|
+
imports: [LibsUiComponentsButtonsTabComponent],
|
|
37
|
+
template: '',
|
|
38
|
+
})
|
|
39
|
+
export class ExampleComponent {}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Cách sử dụng
|
|
43
|
+
|
|
44
|
+
### 1. Ví dụ inline template
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<libs_ui-components-buttons-tab
|
|
48
|
+
[items]="items"
|
|
49
|
+
[(keySelected)]="selectedKey"
|
|
50
|
+
(outKeySelected)="onKeySelected($event)"
|
|
51
|
+
/>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { Component, signal } from '@angular/core';
|
|
56
|
+
import { LibsUiComponentsButtonsTabComponent, IButtonTab } from '@libs-ui/components-buttons-tab';
|
|
57
|
+
|
|
58
|
+
@Component({
|
|
59
|
+
standalone: true,
|
|
60
|
+
imports: [LibsUiComponentsButtonsTabComponent],
|
|
61
|
+
template: `
|
|
62
|
+
<libs_ui-components-buttons-tab
|
|
63
|
+
[items]="items"
|
|
64
|
+
[(keySelected)]="selectedKey()"
|
|
65
|
+
(outKeySelected)="onKeySelected($event)"
|
|
66
|
+
/>
|
|
67
|
+
`,
|
|
68
|
+
})
|
|
69
|
+
export class InlineExampleComponent {
|
|
70
|
+
readonly selectedKey = signal<string>('overview');
|
|
71
|
+
|
|
72
|
+
readonly items: IButtonTab[] = [
|
|
73
|
+
{ key: 'overview', label: 'Overview', type: 'blue' },
|
|
74
|
+
{ key: 'details', label: 'Details', type: 'green' },
|
|
75
|
+
{ key: 'settings', label: 'Settings', type: 'orange' },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
onKeySelected(key: string): void {
|
|
79
|
+
this.selectedKey.set(key);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Ví dụ với file HTML riêng
|
|
85
|
+
|
|
86
|
+
`example.component.html`
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<libs_ui-components-buttons-tab
|
|
90
|
+
[items]="items"
|
|
91
|
+
[otherConfig]="otherConfig"
|
|
92
|
+
[(keySelected)]="selectedKey"
|
|
93
|
+
/>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`example.component.ts`
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { Component, signal } from '@angular/core';
|
|
100
|
+
import { LibsUiComponentsButtonsTabComponent, IButtonTab, IOtherConfig } from '@libs-ui/components-buttons-tab';
|
|
101
|
+
|
|
102
|
+
@Component({
|
|
103
|
+
standalone: true,
|
|
104
|
+
imports: [LibsUiComponentsButtonsTabComponent],
|
|
105
|
+
templateUrl: './example.component.html',
|
|
106
|
+
})
|
|
107
|
+
export class HtmlFileExampleComponent {
|
|
108
|
+
readonly selectedKey = signal<string>('custom-1');
|
|
109
|
+
|
|
110
|
+
readonly otherConfig: IOtherConfig = {
|
|
111
|
+
color: '#0ea5e9',
|
|
112
|
+
background: '#e0f2fe',
|
|
113
|
+
background_badge: '#bae6fd',
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
readonly items: IButtonTab[] = [
|
|
117
|
+
{ key: 'custom-1', label: 'Custom 1', type: 'other' },
|
|
118
|
+
{ key: 'custom-2', label: 'Custom 2', type: 'other', count: 7, modeCount: 'x+' },
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Công nghệ
|
|
124
|
+
|
|
125
|
+
| Technology | Version | Purpose |
|
|
126
|
+
|------------|---------|---------|
|
|
127
|
+
| Angular | 18+ | Framework |
|
|
128
|
+
| Angular Signals | - | State management |
|
|
129
|
+
| TailwindCSS | 3.x | Styling (demo) |
|
|
130
|
+
| OnPush | - | Change Detection |
|
|
131
|
+
|
|
132
|
+
## API
|
|
133
|
+
|
|
134
|
+
### libs_ui-components-buttons-tab
|
|
135
|
+
|
|
136
|
+
#### Inputs
|
|
137
|
+
|
|
138
|
+
| Property | Type | Default | Description |
|
|
139
|
+
|----------|------|---------|-------------|
|
|
140
|
+
| `[disable]` | `boolean` | `false` | Disable toàn bộ tab |
|
|
141
|
+
| `[items]` | `Array<IButtonTab>` | `required` | Danh sách tab cần hiển thị |
|
|
142
|
+
| `[otherConfig]` | `IOtherConfig \| undefined` | `undefined` | Cấu hình màu cho type = other |
|
|
143
|
+
| `[(keySelected)]` | `string` | `''` | Key tab đang được chọn (two-way binding) |
|
|
144
|
+
|
|
145
|
+
#### Outputs
|
|
146
|
+
|
|
147
|
+
| Property | Type | Description |
|
|
148
|
+
|----------|------|-------------|
|
|
149
|
+
| `(outKeySelected)` | `EventEmitter<string>` | Emit key mỗi khi người dùng chọn tab |
|
|
150
|
+
|
|
151
|
+
## Types & Interfaces
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
export interface IButtonTab {
|
|
155
|
+
key: string;
|
|
156
|
+
label: string;
|
|
157
|
+
type: TYPE_BUTTON_TAB;
|
|
158
|
+
count?: number;
|
|
159
|
+
modeCount?: TYPE_BADGE_MODE;
|
|
160
|
+
maxCount?: number;
|
|
161
|
+
class?: string;
|
|
162
|
+
classLabel?: string;
|
|
163
|
+
disable?: boolean;
|
|
164
|
+
data?: any;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface IOtherConfig {
|
|
168
|
+
color: string;
|
|
169
|
+
background?: string;
|
|
170
|
+
background_badge?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export type TYPE_BUTTON_TAB = 'blue' | 'green' | 'red' | 'orange' | 'yellow' | 'cyan' | 'purple' | 'brown' | 'other' | string;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Mô tả Types
|
|
177
|
+
|
|
178
|
+
- **IButtonTab**: Cấu hình cho từng tab item, có thể kèm badge count và tuỳ chỉnh class/disable.
|
|
179
|
+
- **IOtherConfig**: Cấu hình màu tuỳ biến cho type `other`.
|
|
180
|
+
- **TYPE_BUTTON_TAB**: Danh sách type màu hỗ trợ (có thể mở rộng bằng string).
|
|
181
|
+
|
|
182
|
+
## Demo
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npx nx serve core-ui
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Truy cập: `http://localhost:4500/buttons/tab`
|
|
189
|
+
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libs-ui/components-buttons-tab",
|
|
3
|
-
"version": "0.2.355-
|
|
3
|
+
"version": "0.2.355-15",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/core": ">=18.0.0",
|
|
6
|
-
"@libs-ui/components-badge": "0.2.355-
|
|
7
|
-
"@libs-ui/components-popover": "0.2.355-
|
|
8
|
-
"@libs-ui/utils": "0.2.355-
|
|
6
|
+
"@libs-ui/components-badge": "0.2.355-15",
|
|
7
|
+
"@libs-ui/components-popover": "0.2.355-15",
|
|
8
|
+
"@libs-ui/utils": "0.2.355-15",
|
|
9
9
|
"@ngx-translate/core": "^15.0.0"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": false,
|