@libs-ui/components-table 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.
Files changed (2) hide show
  1. package/README.md +158 -0
  2. package/package.json +25 -25
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # @libs-ui/components-table
2
+
3
+ > Component hiển thị dữ liệu dạng bảng mạnh mẽ với khả năng ghim cột, Virtual Scrolling, phân trang và hỗ trợ gọi API trực tiếp qua `httpRequestData`.
4
+
5
+ ## Giới thiệu
6
+
7
+ `LibsUiComponentsTableComponent` là một giải pháp toàn diện để hiển thị danh sách dữ liệu lớn. Nó tích hợp sẵn Virtual Scrolling để tối ưu hiệu năng, cơ chế ghim cột (Fixed Columns) linh hoạt và khả năng kết nối trực tiếp với các API service thông qua cấu hình `httpRequestData`.
8
+
9
+ ### Tính năng
10
+
11
+ - ✅ **Ghim cột (Sticky Columns)**: Hỗ trợ ghim các cột quan trọng bên trái thông qua `headerLeft`.
12
+ - ✅ **Virtual Scrolling**: Tối ưu hiệu năng cho danh sách hàng ngàn bản ghi.
13
+ - ✅ **Phân trang (Pagination)**: Hỗ trợ cả `scroll-infinity` và `click-pagination`.
14
+ - ✅ **Custom Template**: Tùy biến hiển thị từng row và cell thông qua cấu hình `colTemplateConfig`.
15
+ - ✅ **Sorting**: Tích hợp sẵn logic sắp xếp dữ liệu.
16
+ - ✅ **Checkbox Selection**: Hỗ trợ chọn một hoặc nhiều hàng cùng lúc.
17
+ - ✅ **Angular Signals**: Hoạt động mượt mà với Signal-based state management.
18
+
19
+ ## Khi nào sử dụng
20
+
21
+ - Khi cần hiển thị dữ liệu dạng bảng với số lượng bản ghi lớn.
22
+ - Khi cần các tính năng Sort/Filter/Pagination kết nối trực tiếp với Backend.
23
+ - Khi bảng có nhiều cột thông tin và cần giữ các cột quan trọng luôn hiển thị (ghim cột).
24
+
25
+ ## Cài đặt
26
+
27
+ ```bash
28
+ npm install @libs-ui/components-table
29
+ ```
30
+
31
+ ## Import
32
+
33
+ ```typescript
34
+ import { LibsUiComponentsTableComponent } from '@libs-ui/components-table';
35
+
36
+ @Component({
37
+ standalone: true,
38
+ imports: [LibsUiComponentsTableComponent],
39
+ // ...
40
+ })
41
+ export class YourComponent {}
42
+ ```
43
+
44
+ ## Ví dụ sử dụng
45
+
46
+ ### 1. Table thường với httpRequestData
47
+
48
+ Sử dụng `httpRequestData` là cách tốt nhất để component tự động quản lý việc tải dữ liệu, phân trang và sắp xếp.
49
+
50
+ ```html
51
+ <libs_ui-components-table
52
+ [headerRight]="headerConfig"
53
+ [httpRequestData]="userRequestConfig" />
54
+ ```
55
+
56
+ ```typescript
57
+ // Cấu hình gọi API từ service
58
+ readonly userRequestConfig = {
59
+ objectInstance: userService, // Inject của service chứa method lấy data
60
+ functionName: 'getUsers', // Tên phương thức gọi API
61
+ argumentsValue: [] // Tham số bổ sung nếu có
62
+ };
63
+
64
+ readonly headerConfig = [
65
+ { label: 'ID', colTemplateConfig: [{ cssWrapper: '', fieldsConfig: [{ field: 'id' }] }] },
66
+ { label: 'Name', hasSort: true, orderby: 'name', colTemplateConfig: [{ cssWrapper: 'font-bold', fieldsConfig: [{ field: 'name' }] }] }
67
+ ];
68
+ ```
69
+
70
+ ### 2. Table ghim cột (Fixed Columns)
71
+
72
+ Ghim các cột quan trọng bên trái bằng cách sử dụng `headerLeft`. Các cột trong `headerRight` sẽ có thể cuộn ngang nếu vượt quá chiều rộng container.
73
+
74
+ ```html
75
+ <libs_ui-components-table
76
+ [headerLeft]="leftPinnedColumns"
77
+ [headerRight]="scrollableColumns"
78
+ [httpRequestData]="userRequestConfig" />
79
+ ```
80
+
81
+ ## API Documentation
82
+
83
+ ### Inputs
84
+
85
+ | Property | Type | Default | Description |
86
+ | :-------------------- | :--------------------- | :---------- | :--------------------------------------------------------------------------- |
87
+ | `[httpRequestData]` | `IHttpRequestConfig` | `undefined` | **(Khuyên dùng)** Cấu hình service để component tự động gọi API lấy dữ liệu. |
88
+ | `[headerLeft]` | `ITableHeaderConfig[]` | `[]` | Danh sách cột được ghim cố định bên trái (Sticky). |
89
+ | `[headerRight]` | `ITableHeaderConfig[]` | `[]` | Danh sách các cột chính hiển thị trong vùng cuộn. |
90
+ | `[paginationSetting]` | `object` | `undefined` | Cấu hình hiển thị phân trang (showTotalPage, showInputGotoPage, ...). |
91
+ | `[fieldKey]` | `string` | `'id'` | Thuộc tính định danh duy nhất cho mỗi hàng dữ liệu. |
92
+ | `[loading]` | `boolean` | `false` | Trạng thái xoay loading (thường dùng khi không dùng httpRequestData). |
93
+ | `[newData]` | `TYPE_NEW_DATA_TABLE` | `undefined` | Dữ liệu đẩy trực tiếp vào bảng (dùng khi không dùng httpRequestData). |
94
+
95
+ #### Outputs
96
+
97
+ | Property | Type | Description |
98
+ | ------------------------ | ------------------------- | ---------------------------------------------------------- |
99
+ | `(outKeysSelected)` | `Array<any>` | Emit danh sách các `fieldKey` của các hàng đang được chọn. |
100
+ | `(outSort)` | `ISortEvent` | Emit khi người dùng thực hiện sắp xếp cột. |
101
+ | `(outLoadMore)` | `ILoadMoreEvent` | Emit khi cần tải thêm dữ liệu (scroll infinity). |
102
+ | `(outClickButtonAction)` | `ITabelButtonActionEvent` | Emit khi click vào button trong template cell. |
103
+
104
+ ## Types & Interfaces
105
+
106
+ ### ITableHeaderConfig
107
+
108
+ ```typescript
109
+ export interface ITableHeaderConfig {
110
+ label?: string | TYPE_OBJECT;
111
+ hasCheckbox?: boolean; // Có checkbox chọn row hay không
112
+ hasCheckboxAll?: boolean; // Có checkbox "Chọn tất cả" hay không
113
+ hasSort?: boolean; // Có nút sort hay không
114
+ orderby?: string; // Field dùng để sort
115
+ colTemplateConfig?: Array<ITableTemplateConfig>; // Cấu hình hiển thị cell
116
+ ngStyle?: TYPE_OBJECT;
117
+ ngClass?: TYPE_OBJECT;
118
+ }
119
+ ```
120
+
121
+ ### ITableTemplateConfig
122
+
123
+ ```typescript
124
+ export interface ITableTemplateConfig {
125
+ cssWrapper: string; // Class CSS cho wrapper của cell
126
+ fieldsConfig: Array<ITableFieldTemplateConfig>; // Danh sách các field hiển thị trong 1 cell
127
+ }
128
+ ```
129
+
130
+ ### TYPE_NEW_DATA_TABLE
131
+
132
+ ```typescript
133
+ export type TYPE_NEW_DATA_TABLE<T = TYPE_OBJECT> = {
134
+ data: WritableSignal<Array<WritableSignal<T>>>;
135
+ addToLastList?: boolean;
136
+ };
137
+ ```
138
+
139
+ ## Công nghệ
140
+
141
+ | Technology | Version | Purpose |
142
+ | ---------------- | ------- | ------------------------- |
143
+ | Angular | 18+ | Framework |
144
+ | Virtual Scroller | 15+ | Hiển thị dữ liệu lớn |
145
+ | Angular Signals | - | Quản lý trạng thái nội bộ |
146
+ | TailwindCSS | 3.x | Styling chính |
147
+
148
+ ## Demo
149
+
150
+ ```bash
151
+ npx nx serve core-ui
152
+ ```
153
+
154
+ Truy cập: `http://localhost:4500/table`
155
+
156
+ ## License
157
+
158
+ MIT
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
2
  "name": "@libs-ui/components-table",
3
- "version": "0.2.355-14",
3
+ "version": "0.2.355-15",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=18.0.0",
6
6
  "@angular/core": ">=18.0.0",
7
- "@libs-ui/components-buttons-button": "0.2.355-14",
7
+ "@libs-ui/components-buttons-button": "0.2.355-15",
8
8
  "@iharbeck/ngx-virtual-scroller": "15.2.0",
9
- "@libs-ui/interfaces-types": "0.2.355-14",
10
- "@libs-ui/components-buttons-sort": "0.2.355-14",
11
- "@libs-ui/components-popover": "0.2.355-14",
12
- "@libs-ui/components-avatar": "0.2.355-14",
13
- "@libs-ui/components-dropdown": "0.2.355-14",
14
- "@libs-ui/components-line-clamp": "0.2.355-14",
15
- "@libs-ui/components-list": "0.2.355-14",
16
- "@libs-ui/components-switch": "0.2.355-14",
17
- "@libs-ui/services-http-request": "0.2.355-14",
9
+ "@libs-ui/interfaces-types": "0.2.355-15",
10
+ "@libs-ui/components-buttons-sort": "0.2.355-15",
11
+ "@libs-ui/components-popover": "0.2.355-15",
12
+ "@libs-ui/components-avatar": "0.2.355-15",
13
+ "@libs-ui/components-dropdown": "0.2.355-15",
14
+ "@libs-ui/components-line-clamp": "0.2.355-15",
15
+ "@libs-ui/components-list": "0.2.355-15",
16
+ "@libs-ui/components-switch": "0.2.355-15",
17
+ "@libs-ui/services-http-request": "0.2.355-15",
18
18
  "rxjs": "~7.8.0",
19
- "@libs-ui/components-checkbox-group": "0.2.355-14",
20
- "@libs-ui/components-checkbox-single": "0.2.355-14",
21
- "@libs-ui/components-scroll-overlay": "0.2.355-14",
22
- "@libs-ui/components-spinner": "0.2.355-14",
23
- "@libs-ui/icons": "0.2.355-14",
24
- "@libs-ui/pipes-call-function-in-template": "0.2.355-14",
25
- "@libs-ui/pipes-check-selected-by-key": "0.2.355-14",
26
- "@libs-ui/utils": "0.2.355-14",
19
+ "@libs-ui/components-checkbox-group": "0.2.355-15",
20
+ "@libs-ui/components-checkbox-single": "0.2.355-15",
21
+ "@libs-ui/components-scroll-overlay": "0.2.355-15",
22
+ "@libs-ui/components-spinner": "0.2.355-15",
23
+ "@libs-ui/icons": "0.2.355-15",
24
+ "@libs-ui/pipes-call-function-in-template": "0.2.355-15",
25
+ "@libs-ui/pipes-check-selected-by-key": "0.2.355-15",
26
+ "@libs-ui/utils": "0.2.355-15",
27
27
  "@ngx-translate/core": "^15.0.0",
28
- "@libs-ui/components-buttons-status": "0.2.355-14",
29
- "@libs-ui/pipes-clone-object": "0.2.355-14",
30
- "@libs-ui/pipes-security-trust": "0.2.355-14",
31
- "@libs-ui/components-badge": "0.2.355-14",
32
- "@libs-ui/pipes-convert-object-to-signal": "0.2.355-14",
33
- "@libs-ui/pipes-get-value-of-object": "0.2.355-14"
28
+ "@libs-ui/components-buttons-status": "0.2.355-15",
29
+ "@libs-ui/pipes-clone-object": "0.2.355-15",
30
+ "@libs-ui/pipes-security-trust": "0.2.355-15",
31
+ "@libs-ui/components-badge": "0.2.355-15",
32
+ "@libs-ui/pipes-convert-object-to-signal": "0.2.355-15",
33
+ "@libs-ui/pipes-get-value-of-object": "0.2.355-15"
34
34
  },
35
35
  "sideEffects": false,
36
36
  "module": "fesm2022/libs-ui-components-table.mjs",