@haloduck/util 1.0.0 → 2.0.1
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 +21 -93
- package/package.json +14 -6
package/README.md
CHANGED
|
@@ -1,127 +1,55 @@
|
|
|
1
1
|
# @haloduck/util
|
|
2
2
|
|
|
3
|
-
HaloDuck Util Library
|
|
3
|
+
HaloDuck Util Library is a utility functions and services library for Angular-based applications.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @haloduck/util
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Key Features
|
|
12
12
|
|
|
13
|
-
###
|
|
14
|
-
- **download**:
|
|
13
|
+
### File Utilities
|
|
14
|
+
- **download**: File download function
|
|
15
15
|
|
|
16
|
-
###
|
|
17
|
-
- **hasRequired**:
|
|
18
|
-
- **hasError**:
|
|
19
|
-
- **getDirtyValues**:
|
|
20
|
-
- **englishAndNumberOnlyValidator**:
|
|
16
|
+
### Form Utilities
|
|
17
|
+
- **hasRequired**: Check required field validation
|
|
18
|
+
- **hasError**: Check form error status
|
|
19
|
+
- **getDirtyValues**: Extract only changed form values
|
|
20
|
+
- **englishAndNumberOnlyValidator**: Validator that allows only English and numbers
|
|
21
21
|
|
|
22
|
-
###
|
|
23
|
-
- **UtilService**:
|
|
24
|
-
- **provideHaloduckUtilIconSet**:
|
|
22
|
+
### Services
|
|
23
|
+
- **UtilService**: File icon URL provider service
|
|
24
|
+
- **provideHaloduckUtilIconSet**: File icon configuration provider
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Usage
|
|
27
27
|
|
|
28
|
-
###
|
|
28
|
+
### Basic Configuration
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import { NgModule } from '@angular/core';
|
|
32
|
-
import { UtilModule } from '@haloduck/util';
|
|
33
|
-
|
|
34
|
-
@NgModule({
|
|
35
|
-
imports: [
|
|
36
|
-
UtilModule
|
|
37
|
-
]
|
|
38
|
-
})
|
|
39
|
-
export class AppModule { }
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 파일 다운로드
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { download } from '@haloduck/util';
|
|
46
|
-
|
|
47
|
-
// 파일 다운로드
|
|
48
|
-
download('https://example.com/file.pdf');
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 폼 유틸리티 사용
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
import {
|
|
55
|
-
hasRequired,
|
|
56
|
-
hasError,
|
|
57
|
-
getDirtyValues,
|
|
58
|
-
englishAndNumberOnlyValidator
|
|
59
|
-
} from '@haloduck/util';
|
|
60
|
-
|
|
61
|
-
@Component({...})
|
|
62
|
-
export class MyComponent {
|
|
63
|
-
form = new FormGroup({
|
|
64
|
-
name: new FormControl('', [englishAndNumberOnlyValidator]),
|
|
65
|
-
email: new FormControl('', [Validators.required, Validators.email])
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
checkField() {
|
|
69
|
-
const nameControl = this.form.get('name');
|
|
70
|
-
|
|
71
|
-
// 필수 필드인지 확인
|
|
72
|
-
console.log(hasRequired(nameControl));
|
|
73
|
-
|
|
74
|
-
// 에러가 있는지 확인
|
|
75
|
-
console.log(hasError(nameControl, 'pattern'));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
submitForm() {
|
|
79
|
-
// 변경된 값만 추출
|
|
80
|
-
const dirtyValues = getDirtyValues(this.form);
|
|
81
|
-
console.log(dirtyValues);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### 파일 아이콘 서비스
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
import {
|
|
90
|
-
UtilService,
|
|
91
|
-
provideHaloduckUtilIconSet
|
|
92
|
-
} from '@haloduck/util';
|
|
93
|
-
|
|
94
|
-
// 앱 설정에서 아이콘 설정 제공
|
|
95
31
|
export const appConfig: ApplicationConfig = {
|
|
96
32
|
providers: [
|
|
33
|
+
// ...
|
|
97
34
|
provideHaloduckUtilIconSet({
|
|
98
35
|
default: '/app/images/default-file-preview.svg',
|
|
99
36
|
stl: '/app/images/default-stl-preview.svg',
|
|
100
37
|
pdf: '/app/images/default-pdf-preview.svg',
|
|
101
38
|
}),
|
|
39
|
+
// ...
|
|
102
40
|
],
|
|
103
41
|
};
|
|
104
|
-
|
|
105
|
-
// 컴포넌트에서 사용
|
|
106
|
-
@Component({...})
|
|
107
|
-
export class FileComponent {
|
|
108
|
-
constructor(private utilService: UtilService) {}
|
|
109
|
-
|
|
110
|
-
getFileIcon(filename: string) {
|
|
111
|
-
return this.utilService.getFileIconUrl(filename);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
42
|
```
|
|
115
43
|
|
|
116
|
-
##
|
|
44
|
+
## Dependencies
|
|
117
45
|
|
|
118
46
|
- Angular 19.2.0+
|
|
119
47
|
- Angular Forms 19.2.0+
|
|
120
48
|
|
|
121
|
-
##
|
|
49
|
+
## License
|
|
122
50
|
|
|
123
51
|
MIT License
|
|
124
52
|
|
|
125
|
-
##
|
|
53
|
+
## Support
|
|
126
54
|
|
|
127
|
-
|
|
55
|
+
If you have any issues or questions, please register
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haloduck/util",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "HaloDuck Util Library - Angular
|
|
5
|
-
"keywords": [
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "HaloDuck Util Library - Angular",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"haloduck",
|
|
8
|
+
"util",
|
|
9
|
+
"utility",
|
|
10
|
+
"typescript",
|
|
11
|
+
"forms",
|
|
12
|
+
"file"
|
|
13
|
+
],
|
|
6
14
|
"author": "HaloDuck",
|
|
7
15
|
"license": "MIT",
|
|
8
16
|
"repository": {
|
|
@@ -33,9 +41,9 @@
|
|
|
33
41
|
"prepublishOnly": "npm run build:prod"
|
|
34
42
|
},
|
|
35
43
|
"peerDependencies": {
|
|
36
|
-
"@angular/common": "^
|
|
37
|
-
"@angular/core": "^
|
|
38
|
-
"@angular/forms": "^
|
|
44
|
+
"@angular/common": "^20.0.0",
|
|
45
|
+
"@angular/core": "^20.0.0",
|
|
46
|
+
"@angular/forms": "^20.0.0"
|
|
39
47
|
},
|
|
40
48
|
"dependencies": {
|
|
41
49
|
"tslib": "^2.3.0"
|