cashdoc-cms-design-system 1.0.6 → 1.0.8
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/dist/components/ImageUpload/ImageUpload.d.ts +95 -1
- package/dist/index.es.js +1369 -1342
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +17 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Accept } from 'react-dropzone';
|
|
2
2
|
|
|
3
|
+
export interface ImageMetadata {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
aspectRatio: number;
|
|
7
|
+
size: number;
|
|
8
|
+
}
|
|
3
9
|
export interface ImageUploadProps {
|
|
4
10
|
value?: File[];
|
|
5
11
|
onChange?: (files: File[]) => void;
|
|
@@ -9,7 +15,11 @@ export interface ImageUploadProps {
|
|
|
9
15
|
disabled?: boolean;
|
|
10
16
|
className?: string;
|
|
11
17
|
showPreview?: boolean;
|
|
18
|
+
error?: boolean;
|
|
12
19
|
onError?: (error: string) => void;
|
|
20
|
+
validateImage?: (file: File, metadata: ImageMetadata) => string | null | Promise<string | null>;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
placeholderActive?: string;
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
15
25
|
* 드래그 앤 드롭 및 클릭을 통해 이미지를 업로드할 수 있는 컴포넌트입니다.
|
|
@@ -53,8 +63,92 @@ export interface ImageUploadProps {
|
|
|
53
63
|
* />
|
|
54
64
|
* ```
|
|
55
65
|
* {@end-tool}
|
|
66
|
+
*
|
|
67
|
+
* {@tool snippet}
|
|
68
|
+
* 최소 이미지 크기 검증:
|
|
69
|
+
*
|
|
70
|
+
* ```tsx
|
|
71
|
+
* <ImageUpload
|
|
72
|
+
* validateImage={(file, metadata) => {
|
|
73
|
+
* if (metadata.width < 800 || metadata.height < 600) {
|
|
74
|
+
* return "이미지는 최소 800x600 이상이어야 합니다.";
|
|
75
|
+
* }
|
|
76
|
+
* return null;
|
|
77
|
+
* }}
|
|
78
|
+
* onError={(error) => alert(error)}
|
|
79
|
+
* />
|
|
80
|
+
* ```
|
|
81
|
+
* {@end-tool}
|
|
82
|
+
*
|
|
83
|
+
* {@tool snippet}
|
|
84
|
+
* 정확한 이미지 크기 검증:
|
|
85
|
+
*
|
|
86
|
+
* ```tsx
|
|
87
|
+
* <ImageUpload
|
|
88
|
+
* validateImage={(file, metadata) => {
|
|
89
|
+
* if (metadata.width !== 1920 || metadata.height !== 1080) {
|
|
90
|
+
* return `이미지는 정확히 1920x1080이어야 합니다. (현재: ${metadata.width}x${metadata.height})`;
|
|
91
|
+
* }
|
|
92
|
+
* return null;
|
|
93
|
+
* }}
|
|
94
|
+
* onError={(error) => alert(error)}
|
|
95
|
+
* />
|
|
96
|
+
* ```
|
|
97
|
+
* {@end-tool}
|
|
98
|
+
*
|
|
99
|
+
* {@tool snippet}
|
|
100
|
+
* 이미지 비율 검증:
|
|
101
|
+
*
|
|
102
|
+
* ```tsx
|
|
103
|
+
* <ImageUpload
|
|
104
|
+
* validateImage={(file, metadata) => {
|
|
105
|
+
* const targetRatio = 16 / 9;
|
|
106
|
+
* const tolerance = 0.1;
|
|
107
|
+
* if (Math.abs(metadata.aspectRatio - targetRatio) > tolerance) {
|
|
108
|
+
* return "이미지 비율은 16:9여야 합니다.";
|
|
109
|
+
* }
|
|
110
|
+
* return null;
|
|
111
|
+
* }}
|
|
112
|
+
* onError={(error) => alert(error)}
|
|
113
|
+
* />
|
|
114
|
+
* ```
|
|
115
|
+
* {@end-tool}
|
|
116
|
+
*
|
|
117
|
+
* {@tool snippet}
|
|
118
|
+
* 복합 검증:
|
|
119
|
+
*
|
|
120
|
+
* ```tsx
|
|
121
|
+
* <ImageUpload
|
|
122
|
+
* validateImage={(file, metadata) => {
|
|
123
|
+
* if (metadata.width > 4000) {
|
|
124
|
+
* return "이미지 너비는 4000px를 초과할 수 없습니다.";
|
|
125
|
+
* }
|
|
126
|
+
* if (metadata.aspectRatio < 1) {
|
|
127
|
+
* return "세로 이미지는 업로드할 수 없습니다.";
|
|
128
|
+
* }
|
|
129
|
+
* if (metadata.size > 2 * 1024 * 1024) {
|
|
130
|
+
* return "파일 크기는 2MB를 초과할 수 없습니다.";
|
|
131
|
+
* }
|
|
132
|
+
* return null;
|
|
133
|
+
* }}
|
|
134
|
+
* onError={(error) => alert(error)}
|
|
135
|
+
* />
|
|
136
|
+
* ```
|
|
137
|
+
* {@end-tool}
|
|
138
|
+
*
|
|
139
|
+
* {@tool snippet}
|
|
140
|
+
* 커스텀 안내 문구:
|
|
141
|
+
*
|
|
142
|
+
* ```tsx
|
|
143
|
+
* <ImageUpload
|
|
144
|
+
* placeholder="상품 이미지를 업로드하세요"
|
|
145
|
+
* placeholderActive="이미지를 드롭하세요"
|
|
146
|
+
* onChange={(files) => console.log(files)}
|
|
147
|
+
* />
|
|
148
|
+
* ```
|
|
149
|
+
* {@end-tool}
|
|
56
150
|
*/
|
|
57
151
|
export declare const ImageUpload: {
|
|
58
|
-
({ value, onChange, maxFiles, maxSize, accept, disabled, className, showPreview, onError, }: ImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
152
|
+
({ value, onChange, maxFiles, maxSize, accept, disabled, className, showPreview, error, onError, validateImage, placeholder, placeholderActive, }: ImageUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
59
153
|
displayName: string;
|
|
60
154
|
};
|