@libs-ui/components-minimap 0.2.355-0 → 0.2.355-10
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/package.json +3 -3
- package/README.md +0 -244
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libs-ui/components-minimap",
|
|
3
|
-
"version": "0.2.355-
|
|
3
|
+
"version": "0.2.355-10",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/core": ">=18.0.0",
|
|
6
|
-
"@libs-ui/interfaces-types": "0.2.355-
|
|
7
|
-
"@libs-ui/utils": "0.2.355-
|
|
6
|
+
"@libs-ui/interfaces-types": "0.2.355-10",
|
|
7
|
+
"@libs-ui/utils": "0.2.355-10",
|
|
8
8
|
"rxjs": "~7.8.0"
|
|
9
9
|
},
|
|
10
10
|
"sideEffects": false,
|
package/README.md
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# @libs-ui/components-minimap
|
|
2
|
-
|
|
3
|
-
Directive tạo minimap (bản đồ thu nhỏ) để điều hướng nhanh trong nội dung có thể cuộn lớn. Giúp người dùng dễ dàng xem tổng quan và di chuyển đến vị trí mong muốn trong một vùng nội dung lớn.
|
|
4
|
-
|
|
5
|
-
## ✨ Tính năng
|
|
6
|
-
|
|
7
|
-
• **Minimap tự động**: Tạo bản đồ thu nhỏ của element có thể cuộn
|
|
8
|
-
• **Navigation tương tác**: Click và kéo thả để di chuyển viewport
|
|
9
|
-
• **Tùy chỉnh style**: Cấu hình màu sắc, kích thước, vị trí minimap
|
|
10
|
-
• **Responsive**: Tự động cập nhật khi nội dung thay đổi
|
|
11
|
-
• **Performance tối ưu**: Sử dụng signal và RxJS cho hiệu suất cao
|
|
12
|
-
• **Hỗ trợ scale**: Làm việc với element có transform scale
|
|
13
|
-
• **Control functions**: API để show/hide/toggle minimap từ code
|
|
14
|
-
|
|
15
|
-
## 📦 Cài đặt
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install @libs-ui/components-minimap
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
<button onclick="navigator.clipboard.writeText('npm install @libs-ui/components-minimap')" class="copy-btn">📋 Sao chép</button>
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
yarn add @libs-ui/components-minimap
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
<button onclick="navigator.clipboard.writeText('yarn add @libs-ui/components-minimap')" class="copy-btn">📋 Sao chép</button>
|
|
28
|
-
|
|
29
|
-
## 🚀 Sử dụng
|
|
30
|
-
|
|
31
|
-
### Ví dụ cơ bản (Inline Template)
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { Component } from '@angular/core';
|
|
35
|
-
import { LibsUiComponentsMinimapDirective } from '@libs-ui/components-minimap';
|
|
36
|
-
|
|
37
|
-
@Component({
|
|
38
|
-
selector: 'app-example',
|
|
39
|
-
standalone: true,
|
|
40
|
-
imports: [LibsUiComponentsMinimapDirective],
|
|
41
|
-
template: `
|
|
42
|
-
<div
|
|
43
|
-
LibsUiComponentsMinimapDirective
|
|
44
|
-
class="scrollable-content"
|
|
45
|
-
style="width: 500px; height: 300px; overflow: auto;">
|
|
46
|
-
<!-- Nội dung lớn cần minimap -->
|
|
47
|
-
<div style="width: 1500px; height: 1000px; background: linear-gradient(45deg, #ff6b6b, #4ecdc4);">
|
|
48
|
-
<h2>Nội dung rất lớn</h2>
|
|
49
|
-
<p>Cuộn để xem minimap hoạt động...</p>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
`,
|
|
53
|
-
})
|
|
54
|
-
export class ExampleComponent {}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Ví dụ với file HTML riêng
|
|
58
|
-
|
|
59
|
-
**Component:**
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
import { Component } from '@angular/core';
|
|
63
|
-
import { LibsUiComponentsMinimapDirective, IMiniMapFunctionControl, IMiniMapStyleConfig } from '@libs-ui/components-minimap';
|
|
64
|
-
|
|
65
|
-
@Component({
|
|
66
|
-
selector: 'app-minimap-demo',
|
|
67
|
-
standalone: true,
|
|
68
|
-
imports: [LibsUiComponentsMinimapDirective],
|
|
69
|
-
templateUrl: './minimap-demo.component.html',
|
|
70
|
-
styleUrls: ['./minimap-demo.component.scss'],
|
|
71
|
-
})
|
|
72
|
-
export class MinimapDemoComponent {
|
|
73
|
-
// Cấu hình style cho minimap container
|
|
74
|
-
minimapStyle: IMiniMapStyleConfig = {
|
|
75
|
-
width: 250,
|
|
76
|
-
height: 150,
|
|
77
|
-
top: 20,
|
|
78
|
-
right: 20,
|
|
79
|
-
background: '#f8f9fa',
|
|
80
|
-
border: '2px solid #007bff',
|
|
81
|
-
borderRadius: 8,
|
|
82
|
-
zIndex: 1500,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// Cấu hình style cho viewport rectangle
|
|
86
|
-
viewportStyle: IMiniMapStyleConfig = {
|
|
87
|
-
border: '2px solid #ff6b6b',
|
|
88
|
-
background: 'rgba(255, 107, 107, 0.1)',
|
|
89
|
-
borderRadius: 4,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
minimapControls: IMiniMapFunctionControl | null = null;
|
|
93
|
-
|
|
94
|
-
// Nhận function controls từ directive
|
|
95
|
-
onMinimapReady(controls: IMiniMapFunctionControl) {
|
|
96
|
-
this.minimapControls = controls;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Các method điều khiển minimap
|
|
100
|
-
showMinimap() {
|
|
101
|
-
this.minimapControls?.show();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
hideMinimap() {
|
|
105
|
-
this.minimapControls?.hidden();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
toggleMinimap() {
|
|
109
|
-
this.minimapControls?.toggle();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Template (minimap-demo.component.html):**
|
|
115
|
-
|
|
116
|
-
```html
|
|
117
|
-
<div class="demo-container">
|
|
118
|
-
<!-- Control buttons -->
|
|
119
|
-
<div class="controls mb-3">
|
|
120
|
-
<button
|
|
121
|
-
(click)="showMinimap()"
|
|
122
|
-
class="btn btn-success me-2">
|
|
123
|
-
Hiện Minimap
|
|
124
|
-
</button>
|
|
125
|
-
<button
|
|
126
|
-
(click)="hideMinimap()"
|
|
127
|
-
class="btn btn-warning me-2">
|
|
128
|
-
Ẩn Minimap
|
|
129
|
-
</button>
|
|
130
|
-
<button
|
|
131
|
-
(click)="toggleMinimap()"
|
|
132
|
-
class="btn btn-info">
|
|
133
|
-
Toggle Minimap
|
|
134
|
-
</button>
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
<!-- Scrollable content với minimap -->
|
|
138
|
-
<div
|
|
139
|
-
LibsUiComponentsMinimapDirective
|
|
140
|
-
[styleImageElement]="minimapStyle"
|
|
141
|
-
[styleRectangleElement]="viewportStyle"
|
|
142
|
-
[timerStartDrawMinimap]="500"
|
|
143
|
-
(outFunctionControls)="onMinimapReady($event)"
|
|
144
|
-
class="scrollable-area"
|
|
145
|
-
style="width: 600px; height: 400px; overflow: auto; border: 1px solid #ddd;">
|
|
146
|
-
<!-- Large content -->
|
|
147
|
-
<div
|
|
148
|
-
class="large-content"
|
|
149
|
-
style="width: 1200px; height: 800px; padding: 20px;">
|
|
150
|
-
<h1>Nội dung lớn với Minimap</h1>
|
|
151
|
-
|
|
152
|
-
<div
|
|
153
|
-
class="mo-minimap-flag-element-scale"
|
|
154
|
-
style="transform: scale(1.2);">
|
|
155
|
-
<!-- Element có scale để test tính năng scale detection -->
|
|
156
|
-
<div class="grid-content">
|
|
157
|
-
<!-- Tạo grid content để dễ nhận biết vị trí -->
|
|
158
|
-
<div
|
|
159
|
-
*ngFor="let row of [1,2,3,4,5,6,7,8,9,10]"
|
|
160
|
-
class="row"
|
|
161
|
-
style="display: flex; margin: 10px 0;">
|
|
162
|
-
<div
|
|
163
|
-
*ngFor="let col of [1,2,3,4,5,6,7,8,9,10]"
|
|
164
|
-
class="cell"
|
|
165
|
-
style="width: 80px; height: 60px; border: 1px solid #ccc;
|
|
166
|
-
margin: 2px; display: flex; align-items: center;
|
|
167
|
-
justify-content: center; background: #f0f0f0;">
|
|
168
|
-
{{row}}-{{col}}
|
|
169
|
-
</div>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
</div>
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## 🛠️ Công nghệ sử dụng
|
|
179
|
-
|
|
180
|
-
- **Angular 18+**: Framework chính
|
|
181
|
-
- **RxJS**: Quản lý events và reactive programming
|
|
182
|
-
- **TypeScript**: Ngôn ngữ phát triển
|
|
183
|
-
- **Signals**: Quản lý state hiện đại của Angular
|
|
184
|
-
|
|
185
|
-
## 📖 API Reference
|
|
186
|
-
|
|
187
|
-
### Inputs
|
|
188
|
-
|
|
189
|
-
| Tên | Kiểu | Mặc định | Mô tả |
|
|
190
|
-
| --------------------------- | --------------------- | --------------------------------- | ------------------------------------------------------------- |
|
|
191
|
-
| `classNameFlagElementScale` | `string` | `'mo-minimap-flag-element-scale'` | Class name của element có scale transform để directive detect |
|
|
192
|
-
| `timerStartDrawMinimap` | `number` | `250` | Thời gian delay (ms) trước khi bắt đầu vẽ minimap |
|
|
193
|
-
| `elementScroll` | `HTMLElement` | `undefined` | Element cuộn tùy chỉnh (mặc định dùng host element) |
|
|
194
|
-
| `styleRectangleElement` | `IMiniMapStyleConfig` | `undefined` | Cấu hình style cho viewport rectangle |
|
|
195
|
-
| `styleImageElement` | `IMiniMapStyleConfig` | `undefined` | Cấu hình style cho minimap container |
|
|
196
|
-
|
|
197
|
-
### Outputs
|
|
198
|
-
|
|
199
|
-
| Tên | Kiểu | Mô tả |
|
|
200
|
-
| --------------------- | ------------------------- | ------------------------------------------------ |
|
|
201
|
-
| `outFunctionControls` | `IMiniMapFunctionControl` | Emit object chứa các function để control minimap |
|
|
202
|
-
|
|
203
|
-
### Interfaces
|
|
204
|
-
|
|
205
|
-
#### `IMiniMapStyleConfig`
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
interface IMiniMapStyleConfig {
|
|
209
|
-
x?: number; // Vị trí x (không sử dụng)
|
|
210
|
-
y?: number; // Vị trí y (không sử dụng)
|
|
211
|
-
width?: number; // Chiều rộng minimap (px)
|
|
212
|
-
height?: number; // Chiều cao minimap (px)
|
|
213
|
-
zIndex?: number; // Z-index layer
|
|
214
|
-
border?: string; // CSS border
|
|
215
|
-
borderRadius?: number; // CSS border-radius (px)
|
|
216
|
-
background?: string; // CSS background
|
|
217
|
-
top?: number; // Vị trí top (px)
|
|
218
|
-
left?: number; // Vị trí left (px)
|
|
219
|
-
bottom?: number; // Vị trí bottom (px) - ưu tiên hơn top
|
|
220
|
-
right?: number; // Vị trí right (px) - ưu tiên hơn left
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Cấu hình style cho minimap container hoặc viewport rectangle. Tất cả thuộc tính đều optional.
|
|
225
|
-
|
|
226
|
-
#### `IMiniMapFunctionControl`
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
interface IMiniMapFunctionControl {
|
|
230
|
-
show: () => void; // Hiển thị minimap
|
|
231
|
-
hidden: () => void; // Ẩn minimap
|
|
232
|
-
toggle: () => void; // Toggle hiển thị/ẩn minimap
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Object chứa các function để điều khiển minimap từ code. Nhận được qua output `outFunctionControls`.
|
|
237
|
-
|
|
238
|
-
## 💡 Lưu ý
|
|
239
|
-
|
|
240
|
-
- Directive tự động tạo minimap container và thêm vào `document.body`
|
|
241
|
-
- Sử dụng class `mo-minimap-flag-element-scale` để đánh dấu element có scale transform
|
|
242
|
-
- Minimap tự động cập nhật khi nội dung hoặc kích thước thay đổi
|
|
243
|
-
- Viewport rectangle có thể click và kéo thả để điều hướng
|
|
244
|
-
- Memory được quản lý tự động, tự cleanup khi component destroy
|