@libs-ui/pipes-format-text-full-name-format 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.
- package/README.md +98 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Full Name Format Pipe
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pipe định dạng tên người: viết hoa chữ cái đầu mỗi từ, viết thường phần còn lại, trim khoảng trắng, xóa khoảng trắng thừa và loại bỏ emoji.
|
|
4
|
+
|
|
5
|
+
## Tính năng
|
|
6
|
+
|
|
7
|
+
- ✅ Viết hoa chữ cái đầu mỗi từ (Title Case)
|
|
8
|
+
- ✅ Viết thường các ký tự còn lại trong mỗi từ
|
|
9
|
+
- ✅ Trim khoảng trắng đầu/cuối chuỗi
|
|
10
|
+
- ✅ Xóa khoảng trắng thừa giữa các từ
|
|
11
|
+
- ✅ Loại bỏ emoji
|
|
12
|
+
- ✅ Hỗ trợ tiếng Việt có dấu unicode
|
|
13
|
+
|
|
14
|
+
## Cài đặt
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @libs-ui/pipes-format-text-full-name-format
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Import
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { LibsUiPipesFormatTextFullNameFormatPipe } from '@libs-ui/pipes-format-text-full-name-format';
|
|
24
|
+
|
|
25
|
+
@Component({
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [LibsUiPipesFormatTextFullNameFormatPipe],
|
|
28
|
+
})
|
|
29
|
+
export class ExampleComponent {}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Cú pháp
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
{{ value | LibsUiPipesFormatTextFullNameFormatPipe }}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Ví dụ
|
|
39
|
+
|
|
40
|
+
### Trong Template
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<!-- Cơ bản -->
|
|
44
|
+
{{ 'john doe' | LibsUiPipesFormatTextFullNameFormatPipe }}
|
|
45
|
+
<!-- Output: John Doe -->
|
|
46
|
+
|
|
47
|
+
<!-- ALL CAPS → Title Case -->
|
|
48
|
+
{{ 'NGUYEN VAN A' | LibsUiPipesFormatTextFullNameFormatPipe }}
|
|
49
|
+
<!-- Output: Nguyen Van A -->
|
|
50
|
+
|
|
51
|
+
<!-- Trim & xóa khoảng trắng thừa -->
|
|
52
|
+
{{ ' TRAN THI B ' | LibsUiPipesFormatTextFullNameFormatPipe }}
|
|
53
|
+
<!-- Output: Tran Thi B -->
|
|
54
|
+
|
|
55
|
+
<!-- Loại bỏ emoji -->
|
|
56
|
+
{{ 'le thu C 😀🎉' | LibsUiPipesFormatTextFullNameFormatPipe }}
|
|
57
|
+
<!-- Output: Le Thu C -->
|
|
58
|
+
|
|
59
|
+
<!-- Tiếng Việt -->
|
|
60
|
+
{{ 'phạm thị MỸ LINH' | LibsUiPipesFormatTextFullNameFormatPipe }}
|
|
61
|
+
<!-- Output: Phạm Thị Mỹ Linh -->
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Dùng trong TypeScript
|
|
65
|
+
|
|
66
|
+
Pipe là thin wrapper của hàm `fullNameFormat` trong `@libs-ui/utils`. Khi cần gọi trong TypeScript, import và dùng thẳng hàm đó — **không cần inject pipe**:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { fullNameFormat } from '@libs-ui/utils';
|
|
70
|
+
|
|
71
|
+
// Dùng thẳng hàm utils — không cần inject pipe
|
|
72
|
+
const displayName = fullNameFormat('NGUYEN VAN A');
|
|
73
|
+
// Output: 'Nguyen Van A'
|
|
74
|
+
|
|
75
|
+
// Trong component class:
|
|
76
|
+
class ExampleComponent {
|
|
77
|
+
displayName = fullNameFormat(this.user.rawName);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API
|
|
82
|
+
|
|
83
|
+
| Tham số | Kiểu | Bắt buộc | Mô tả |
|
|
84
|
+
| ------- | -------- | -------- | ----------------------- |
|
|
85
|
+
| `value` | `string` | ✅ | Tên người cần định dạng |
|
|
86
|
+
|
|
87
|
+
> **Lưu ý:** Pipe không có tham số tùy chỉnh. Options được hardcode: `lowercaseOtherCharacter=true`, `trim=true`, `removeMultipleSpace=true`, `removeEmoji=true`.
|
|
88
|
+
|
|
89
|
+
## Khi nào sử dụng
|
|
90
|
+
|
|
91
|
+
- **Form nhập tên:** Chuẩn hóa tên người dùng nhập vào về dạng "Nguyễn Văn A"
|
|
92
|
+
- **Import dữ liệu:** Tên từ Excel/CSV/hệ thống ngoài thường ở dạng ALL CAPS hoặc lowercase
|
|
93
|
+
- **Hiển thị profile:** Đảm bảo format tên nhất quán trong danh sách, avatar, profile
|
|
94
|
+
|
|
95
|
+
## Lưu ý quan trọng
|
|
96
|
+
|
|
97
|
+
- Pipe **không** hỗ trợ tùy chỉnh options — đây là pipe chuyên dụng cho định dạng tên người
|
|
98
|
+
- Nếu cần tùy chỉnh options (ví dụ: giữ nguyên emoji), hãy dùng trực tiếp `capitalize()` từ `@libs-ui/utils`
|
|
99
|
+
- Khi input là `null`, `undefined` hoặc chuỗi rỗng, pipe trả về nguyên giá trị đó (không throw error)
|