@libs-ui/components-preview-file 0.2.355-9 → 0.2.356-0

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 +151 -2
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,3 +1,152 @@
1
- # preview-file
1
+ # @libs-ui/components-preview-file
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ > Component xem trước tệp tin hỗ trợ nhiều định dạng từ hình ảnh đến tài liệu văn phòng, PDF thông qua các bộ Viewer phổ biến.
4
+
5
+ ## Giới thiệu
6
+
7
+ `LibsUiComponentsPreviewFileComponent` là một component cung cấp giao diện modal để xem nhanh nội dung của tệp tin. Nó hỗ trợ điều hướng giữa một danh sách tệp, các nút hành động tùy chỉnh (như download, share) và tự động nhận diện định dạng để sử dụng viewer phù hợp (Google Viewer cho PDF/Images, Microsoft Viewer cho Office documents).
8
+
9
+ ### Tính năng
10
+
11
+ - ✅ **Hỗ trợ đa định dạng**: Image (JPEG, PNG, SVG), PDF, Office (DOCX, XLSX, PPTX).
12
+ - ✅ **Viewer tích hợp**: Sử dụng Google và Microsoft Online Viewers cho các tài liệu phức tạp.
13
+ - ✅ **Điều hướng**: Hỗ trợ xem danh sách nhiều tệp với nút Prev/Next.
14
+ - ✅ **Tùy biến hành động**: Cho phép thêm các nút điều khiển tùy chỉnh trên header.
15
+ - ✅ **Lazy Loading**: Chỉ load viewer khi tệp được chọn.
16
+ - ✅ **OnPush Change Detection**
17
+ - ✅ **Angular Signals**
18
+
19
+ ## Khi nào sử dụng
20
+
21
+ - Khi cần xem nhanh nội dung của một hoặc nhiều tệp đính kèm.
22
+ - Hỗ trợ duyệt album ảnh hoặc danh sách tài liệu PDF, Office.
23
+ - Tránh việc phải tải tệp về máy chỉ để xem nội dung cơ bản.
24
+
25
+ ## Cài đặt
26
+
27
+ ```bash
28
+ # npm
29
+ npm install @libs-ui/components-preview-file
30
+
31
+ # yarn
32
+ yarn add @libs-ui/components-preview-file
33
+ ```
34
+
35
+ ## Import
36
+
37
+ ```typescript
38
+ import { LibsUiComponentsPreviewFileComponent } from '@libs-ui/components-preview-file';
39
+
40
+ @Component({
41
+ standalone: true,
42
+ imports: [LibsUiComponentsPreviewFileComponent],
43
+ // ...
44
+ })
45
+ export class YourComponent {}
46
+ ```
47
+
48
+ ## Ví dụ
49
+
50
+ ### Cơ bản
51
+
52
+ ```html
53
+ <libs_ui-components-preview_file
54
+ [data]="fileList"
55
+ [(index)]="currentIndex"
56
+ (outClose)="onClose()" />
57
+ ```
58
+
59
+ ### Với nút bấm tùy chỉnh
60
+
61
+ ```html
62
+ <libs_ui-components-preview_file
63
+ [data]="fileList"
64
+ [(index)]="currentIndex"
65
+ [buttons]="customButtons"
66
+ (outClose)="onClose()" />
67
+ ```
68
+
69
+ ## API
70
+
71
+ ### libs_ui-components-preview_file
72
+
73
+ #### Inputs
74
+
75
+ | Property | Type | Default | Description |
76
+ | ----------- | ----------- | ------------ | ------------------------------------------------------------- |
77
+ | `[data]` | `IFile[]` | **Bắt buộc** | Danh sách các đối tượng tệp tin cần xem trước. |
78
+ | `[(index)]` | `number` | **Bắt buộc** | Vị trí tệp hiện tại trong danh sách (hỗ trợ Two-way binding). |
79
+ | `[buttons]` | `IButton[]` | `[]` | Danh sách các nút hành động bổ sung hiển thị trên header. |
80
+ | `[zIndex]` | `number` | `undefined` | Thiết lập z-index cho modal preview. |
81
+
82
+ #### Outputs
83
+
84
+ | Property | Type | Description |
85
+ | ------------ | ------ | --------------------------------------------------------------- |
86
+ | `(outClose)` | `void` | Phát ra khi người dùng nhấn nút đóng hoặc click ra ngoài modal. |
87
+
88
+ ## Types & Interfaces
89
+
90
+ ```typescript
91
+ export interface IFile {
92
+ id?: string;
93
+ name?: string;
94
+ file?: File;
95
+ size?: string;
96
+ url?: string;
97
+ origin_url?: string;
98
+ mimetype?: string;
99
+ type?: 'document' | 'image' | 'video' | 'audio';
100
+ extension?: string;
101
+ }
102
+
103
+ export interface IButton {
104
+ key: string;
105
+ label?: string;
106
+ type?: string;
107
+ classIconLeft?: string;
108
+ iconOnlyType?: boolean;
109
+ action?: (index: number) => Promise<void>;
110
+ }
111
+ ```
112
+
113
+ ## Styling
114
+
115
+ ### CSS Classes
116
+
117
+ | Class | Description |
118
+ | ------------------------- | -------------------------------------------------- |
119
+ | `.preview-file-container` | Container chính của modal preview. |
120
+ | `.preview-header` | Thanh tiêu đề chứa tên file và các nút điều hướng. |
121
+ | `.preview-body` | Vùng hiển thị nội dung file (iframe/img). |
122
+
123
+ ## Công nghệ
124
+
125
+ | Technology | Version | Purpose |
126
+ | ----------------------- | ------- | ----------------------- |
127
+ | Angular | 18+ | Framework |
128
+ | Google Viewer | - | PDF & Image Viewing |
129
+ | Microsoft Office Online | - | Office Document Viewing |
130
+ | Angular Signals | - | State management |
131
+
132
+ ## Demo
133
+
134
+ ```bash
135
+ npx nx serve core-ui
136
+ ```
137
+
138
+ Truy cập: `http://localhost:4200/preview-file`
139
+
140
+ ## Unit Tests
141
+
142
+ ```bash
143
+ # Chạy tests
144
+ npx nx test components-preview-file
145
+
146
+ # Coverage
147
+ npx nx test components-preview-file --coverage
148
+ ```
149
+
150
+ ## License
151
+
152
+ MIT
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@libs-ui/components-preview-file",
3
- "version": "0.2.355-9",
3
+ "version": "0.2.356-0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=18.0.0",
6
6
  "@angular/core": ">=18.0.0",
7
- "@libs-ui/components-modal": "0.2.355-9",
8
- "@libs-ui/components-skeleton": "0.2.355-9",
9
- "@libs-ui/interfaces-types": "0.2.355-9",
10
- "@libs-ui/pipes-security-trust": "0.2.355-9"
7
+ "@libs-ui/components-modal": "0.2.356-0",
8
+ "@libs-ui/components-skeleton": "0.2.356-0",
9
+ "@libs-ui/interfaces-types": "0.2.356-0",
10
+ "@libs-ui/pipes-security-trust": "0.2.356-0"
11
11
  },
12
12
  "sideEffects": false,
13
13
  "module": "fesm2022/libs-ui-components-preview-file.mjs",