@vinaup/media-ui 1.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/dist/index.css ADDED
@@ -0,0 +1,101 @@
1
+ /* src/components/styles/media-upload.module.scss */
2
+ .sectionTitleRoot {
3
+ font-size: 0.875rem;
4
+ font-weight: 500;
5
+ }
6
+ .copyButtonRoot {
7
+ opacity: 0.9;
8
+ transition: opacity 0.2s;
9
+ cursor: pointer;
10
+ }
11
+ .imageContainer {
12
+ position: relative;
13
+ width: 100%;
14
+ padding-bottom: 100%;
15
+ }
16
+ .itemImageRoot {
17
+ position: absolute;
18
+ top: 0;
19
+ left: 0;
20
+ width: 100%;
21
+ height: 100%;
22
+ object-fit: cover;
23
+ border-radius: 4px;
24
+ }
25
+ .uploadingOverlay {
26
+ position: absolute;
27
+ top: 0;
28
+ left: 0;
29
+ right: 0;
30
+ bottom: 0;
31
+ background-color: rgba(0, 0, 0, 0.5);
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ border-radius: 4px;
36
+ }
37
+ .statusBadge {
38
+ position: absolute;
39
+ top: 8px;
40
+ right: 8px;
41
+ border-radius: 50%;
42
+ width: 24px;
43
+ height: 24px;
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ }
48
+ .statusBadgeSuccess {
49
+ background-color: green;
50
+ }
51
+ .statusBadgeError {
52
+ background-color: red;
53
+ }
54
+
55
+ /* src/components/styles/media-grid.module.scss */
56
+ .itemPaperRoot {
57
+ cursor: pointer;
58
+ transition: border-color 0.2s, background-color 0.2s;
59
+ }
60
+ .selectedPaper {
61
+ border-color: var(--mantine-color-blue-6);
62
+ border-width: 2px;
63
+ background-color: var(--mantine-color-blue-0);
64
+ }
65
+ .imageContainer {
66
+ position: relative;
67
+ width: 100%;
68
+ padding-bottom: 100%;
69
+ }
70
+ .itemImageRoot {
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ height: 100%;
76
+ object-fit: cover;
77
+ border-radius: 4px;
78
+ }
79
+ .itemTextRoot {
80
+ word-break: break-word;
81
+ }
82
+
83
+ /* src/components/styles/media-detail.module.scss */
84
+ .paperRoot {
85
+ position: relative;
86
+ }
87
+ .imageWrapper {
88
+ width: 100%;
89
+ }
90
+ .urlText {
91
+ overflow: hidden;
92
+ text-overflow: ellipsis;
93
+ white-space: nowrap;
94
+ flex: 1;
95
+ }
96
+ .deleteButtonRoot {
97
+ position: absolute;
98
+ bottom: 8px;
99
+ right: 8px;
100
+ }
101
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/media-upload.module.scss","../src/components/media-grid.module.scss","../src/components/media-detail.module.scss"],"sourcesContent":["// Text component (section title)\n.sectionTitleRoot {\n font-size: 0.875rem;\n font-weight: 500;\n}\n\n// UnstyledButton component (copy button)\n.copyButtonRoot {\n opacity: 0.9;\n transition: opacity 0.2s;\n cursor: pointer;\n}\n\n// Native divs (image container and overlays)\n.imageContainer {\n position: relative;\n width: 100%;\n padding-bottom: 100%;\n}\n\n.itemImageRoot {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 4px;\n}\n\n.uploadingOverlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n}\n\n.statusBadge {\n position: absolute;\n top: 8px;\n right: 8px;\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.statusBadgeSuccess {\n background-color: green;\n}\n\n.statusBadgeError {\n background-color: red;\n}","// Paper component (item)\n.itemPaperRoot {\n cursor: pointer;\n transition: border-color 0.2s, background-color 0.2s;\n}\n\n.selectedPaper {\n border-color: var(--mantine-color-blue-6);\n border-width: 2px;\n background-color: var(--mantine-color-blue-0);\n}\n\n// Native div (image container)\n.imageContainer {\n position: relative;\n width: 100%;\n padding-bottom: 100%;\n}\n\n// Image component\n.itemImageRoot {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 4px;\n}\n\n// Text component (filename)\n.itemTextRoot {\n word-break: break-word;\n}","// Paper component\n.paperRoot {\n position: relative;\n}\n\n.imageWrapper {\n width: 100%;\n}\n\n.urlText {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex: 1;\n}\n\n// Delete button\n.deleteButtonRoot {\n position: absolute;\n bottom: 8px;\n right: 8px;\n}"],"mappings":";AACA,CAAA;AACE,aAAA;AACA,eAAA;;AAIF,CAAA;AACE,WAAA;AACA,cAAA,QAAA;AACA,UAAA;;AAIF,CAAA;AACE,YAAA;AACA,SAAA;AACA,kBAAA;;AAGF,CAAA;AACE,YAAA;AACA,OAAA;AACA,QAAA;AACA,SAAA;AACA,UAAA;AACA,cAAA;AACA,iBAAA;;AAGF,CAAA;AACE,YAAA;AACA,OAAA;AACA,QAAA;AACA,SAAA;AACA,UAAA;AACA,oBAAA,KAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA;AACA,WAAA;AACA,eAAA;AACA,mBAAA;AACA,iBAAA;;AAGF,CAAA;AACE,YAAA;AACA,OAAA;AACA,SAAA;AACA,iBAAA;AACA,SAAA;AACA,UAAA;AACA,WAAA;AACA,eAAA;AACA,mBAAA;;AAGF,CAAA;AACE,oBAAA;;AAGF,CAAA;AACE,oBAAA;;;;AC3DF,CAAA;AACE,UAAA;AACA,cAAA,aAAA,IAAA,EAAA,iBAAA;;AAGF,CAAA;AACE,gBAAA,IAAA;AACA,gBAAA;AACA,oBAAA,IAAA;;AAIF,CAAA;AACE,YAAA;AACA,SAAA;AACA,kBAAA;;AAIF,CAAA;AACE,YAAA;AACA,OAAA;AACA,QAAA;AACA,SAAA;AACA,UAAA;AACA,cAAA;AACA,iBAAA;;AAIF,CAAA;AACE,cAAA;;;;AC/BF,CAAA;AACE,YAAA;;AAGF,CAAA;AACE,SAAA;;AAGF,CAAA;AACE,YAAA;AACA,iBAAA;AACA,eAAA;AACA,QAAA;;AAIF,CAAA;AACE,YAAA;AACA,UAAA;AACA,SAAA;;","names":[]}
@@ -0,0 +1,244 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface IMedia {
4
+ id: string;
5
+ name: string;
6
+ title: string | null;
7
+ description: string | null;
8
+ url: string;
9
+ type: string;
10
+ folder: string;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ }
14
+ interface ICreateMedia {
15
+ name: string;
16
+ title?: string | null;
17
+ description?: string | null;
18
+ url: string;
19
+ type: string;
20
+ folder: string;
21
+ }
22
+ interface IUpdateMedia {
23
+ name?: string;
24
+ title?: string | null;
25
+ description?: string | null;
26
+ }
27
+ interface UploadResult {
28
+ url: string;
29
+ name: string;
30
+ }
31
+ interface MediaUploadHandlers {
32
+ onUpload: (files: File[]) => Promise<UploadResult[]>;
33
+ onSave?: (data: ICreateMedia[]) => Promise<IMedia[]>;
34
+ onUploadSuccess?: (media: IMedia[]) => void;
35
+ onUploadError?: (error: Error) => void;
36
+ }
37
+ interface MediaGridHandlers {
38
+ onImageSelect: (imageId: string) => void;
39
+ onLoadImages: () => Promise<IMedia[]>;
40
+ }
41
+ interface MediaDetailHandlers {
42
+ onUpdate: (id: string, data: IUpdateMedia) => Promise<void>;
43
+ onDelete: (id: string) => Promise<void>;
44
+ onNavigateBack: () => void;
45
+ }
46
+ interface MediaTabsConfig {
47
+ tabs: {
48
+ value: string;
49
+ label: string;
50
+ }[];
51
+ activeTab: string;
52
+ onTabChange: (value: string) => void;
53
+ }
54
+
55
+ interface UploadFileItem {
56
+ id: string;
57
+ file: File;
58
+ preview: string;
59
+ status: 'uploading' | 'success' | 'error';
60
+ url?: string;
61
+ error?: string;
62
+ }
63
+ interface MediaUploadClassNames {
64
+ rootStack?: {
65
+ root?: string;
66
+ };
67
+ dropzone?: {
68
+ root?: string;
69
+ inner?: string;
70
+ };
71
+ dropzoneGroup?: {
72
+ root?: string;
73
+ };
74
+ dropzoneText?: {
75
+ root?: string;
76
+ };
77
+ dropzoneSubtext?: {
78
+ root?: string;
79
+ };
80
+ recentStack?: {
81
+ root?: string;
82
+ };
83
+ sectionTitle?: {
84
+ root?: string;
85
+ };
86
+ grid?: {
87
+ root?: string;
88
+ inner?: string;
89
+ col?: string;
90
+ };
91
+ itemPaper?: {
92
+ root?: string;
93
+ };
94
+ itemStack?: {
95
+ root?: string;
96
+ };
97
+ itemImage?: {
98
+ root?: string;
99
+ };
100
+ itemFilename?: {
101
+ root?: string;
102
+ };
103
+ itemFilesize?: {
104
+ root?: string;
105
+ };
106
+ itemError?: {
107
+ root?: string;
108
+ };
109
+ itemGroup?: {
110
+ root?: string;
111
+ };
112
+ copyButton?: {
113
+ root?: string;
114
+ };
115
+ copyButtonText?: {
116
+ root?: string;
117
+ };
118
+ imageContainer?: string;
119
+ uploadingOverlay?: string;
120
+ statusBadge?: string;
121
+ statusBadgeSuccess?: string;
122
+ statusBadgeError?: string;
123
+ }
124
+ interface MediaUploadProps extends MediaUploadHandlers {
125
+ maxSize?: number;
126
+ acceptedTypes?: string[];
127
+ multiple?: boolean;
128
+ folder?: string;
129
+ classNames?: MediaUploadClassNames;
130
+ }
131
+
132
+ declare function MediaUpload({ onUpload, onSave, onUploadSuccess, onUploadError, maxSize, acceptedTypes, multiple, folder, classNames, }: MediaUploadProps): react_jsx_runtime.JSX.Element;
133
+
134
+ interface MediaGridClassNames {
135
+ rootStack?: {
136
+ root?: string;
137
+ };
138
+ filterGroup?: {
139
+ root?: string;
140
+ };
141
+ sortSelect?: {
142
+ root?: string;
143
+ wrapper?: string;
144
+ input?: string;
145
+ section?: string;
146
+ dropdown?: string;
147
+ };
148
+ searchInput?: {
149
+ root?: string;
150
+ wrapper?: string;
151
+ input?: string;
152
+ section?: string;
153
+ };
154
+ grid?: {
155
+ root?: string;
156
+ inner?: string;
157
+ col?: string;
158
+ };
159
+ itemPaper?: {
160
+ root?: string;
161
+ };
162
+ itemStack?: {
163
+ root?: string;
164
+ };
165
+ itemImage?: {
166
+ root?: string;
167
+ };
168
+ itemText?: {
169
+ root?: string;
170
+ };
171
+ imageContainer?: string;
172
+ selectedPaper?: string;
173
+ }
174
+ interface MediaGridProps {
175
+ images: IMedia[];
176
+ selectedImageId?: string | null;
177
+ onImageClick: (imageId: string) => void;
178
+ sortOptions?: {
179
+ value: string;
180
+ label: string;
181
+ }[];
182
+ classNames?: MediaGridClassNames;
183
+ }
184
+
185
+ declare function MediaGrid({ images, selectedImageId, onImageClick, sortOptions, classNames, }: MediaGridProps): react_jsx_runtime.JSX.Element;
186
+
187
+ interface MediaDetailClassNames {
188
+ paper?: {
189
+ root?: string;
190
+ };
191
+ image?: {
192
+ root?: string;
193
+ };
194
+ title?: {
195
+ root?: string;
196
+ };
197
+ fieldsStack?: {
198
+ root?: string;
199
+ };
200
+ fieldLabel?: {
201
+ root?: string;
202
+ };
203
+ fieldValue?: {
204
+ root?: string;
205
+ };
206
+ textarea?: {
207
+ root?: string;
208
+ input?: string;
209
+ wrapper?: string;
210
+ };
211
+ saveButton?: {
212
+ root?: string;
213
+ };
214
+ copyButton?: {
215
+ root?: string;
216
+ };
217
+ deleteButton?: {
218
+ root?: string;
219
+ };
220
+ imageWrapper?: string;
221
+ fieldGroup?: string;
222
+ urlText?: string;
223
+ }
224
+ interface MediaDetailProps {
225
+ image: IMedia;
226
+ onUpdate: (id: string, data: IUpdateMedia) => Promise<void>;
227
+ onDelete?: (id: string) => void;
228
+ onCopyLink?: (url: string) => void;
229
+ onNotify?: (type: 'success' | 'error', message: string) => void;
230
+ classNames?: MediaDetailClassNames;
231
+ }
232
+
233
+ declare function MediaDetail({ image, onUpdate, onDelete, onCopyLink, onNotify, classNames, }: MediaDetailProps): react_jsx_runtime.JSX.Element;
234
+
235
+ declare const validateImageFile: (file: File) => boolean;
236
+ declare const formatFileSize: (bytes: number) => string;
237
+ /**
238
+ * Merge multiple className strings into one, filtering out falsy values
239
+ * @param classNames - Array of className strings (can include undefined)
240
+ * @returns Single merged className string
241
+ */
242
+ declare const cx: (...classNames: (string | undefined)[]) => string;
243
+
244
+ export { type ICreateMedia, type IMedia, type IUpdateMedia, MediaDetail, type MediaDetailClassNames, type MediaDetailHandlers, type MediaDetailProps, MediaGrid, type MediaGridClassNames, type MediaGridHandlers, type MediaGridProps, type MediaTabsConfig, MediaUpload, type MediaUploadClassNames, type MediaUploadHandlers, type MediaUploadProps, type UploadFileItem, type UploadResult, cx, formatFileSize, validateImageFile };
@@ -0,0 +1,244 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface IMedia {
4
+ id: string;
5
+ name: string;
6
+ title: string | null;
7
+ description: string | null;
8
+ url: string;
9
+ type: string;
10
+ folder: string;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ }
14
+ interface ICreateMedia {
15
+ name: string;
16
+ title?: string | null;
17
+ description?: string | null;
18
+ url: string;
19
+ type: string;
20
+ folder: string;
21
+ }
22
+ interface IUpdateMedia {
23
+ name?: string;
24
+ title?: string | null;
25
+ description?: string | null;
26
+ }
27
+ interface UploadResult {
28
+ url: string;
29
+ name: string;
30
+ }
31
+ interface MediaUploadHandlers {
32
+ onUpload: (files: File[]) => Promise<UploadResult[]>;
33
+ onSave?: (data: ICreateMedia[]) => Promise<IMedia[]>;
34
+ onUploadSuccess?: (media: IMedia[]) => void;
35
+ onUploadError?: (error: Error) => void;
36
+ }
37
+ interface MediaGridHandlers {
38
+ onImageSelect: (imageId: string) => void;
39
+ onLoadImages: () => Promise<IMedia[]>;
40
+ }
41
+ interface MediaDetailHandlers {
42
+ onUpdate: (id: string, data: IUpdateMedia) => Promise<void>;
43
+ onDelete: (id: string) => Promise<void>;
44
+ onNavigateBack: () => void;
45
+ }
46
+ interface MediaTabsConfig {
47
+ tabs: {
48
+ value: string;
49
+ label: string;
50
+ }[];
51
+ activeTab: string;
52
+ onTabChange: (value: string) => void;
53
+ }
54
+
55
+ interface UploadFileItem {
56
+ id: string;
57
+ file: File;
58
+ preview: string;
59
+ status: 'uploading' | 'success' | 'error';
60
+ url?: string;
61
+ error?: string;
62
+ }
63
+ interface MediaUploadClassNames {
64
+ rootStack?: {
65
+ root?: string;
66
+ };
67
+ dropzone?: {
68
+ root?: string;
69
+ inner?: string;
70
+ };
71
+ dropzoneGroup?: {
72
+ root?: string;
73
+ };
74
+ dropzoneText?: {
75
+ root?: string;
76
+ };
77
+ dropzoneSubtext?: {
78
+ root?: string;
79
+ };
80
+ recentStack?: {
81
+ root?: string;
82
+ };
83
+ sectionTitle?: {
84
+ root?: string;
85
+ };
86
+ grid?: {
87
+ root?: string;
88
+ inner?: string;
89
+ col?: string;
90
+ };
91
+ itemPaper?: {
92
+ root?: string;
93
+ };
94
+ itemStack?: {
95
+ root?: string;
96
+ };
97
+ itemImage?: {
98
+ root?: string;
99
+ };
100
+ itemFilename?: {
101
+ root?: string;
102
+ };
103
+ itemFilesize?: {
104
+ root?: string;
105
+ };
106
+ itemError?: {
107
+ root?: string;
108
+ };
109
+ itemGroup?: {
110
+ root?: string;
111
+ };
112
+ copyButton?: {
113
+ root?: string;
114
+ };
115
+ copyButtonText?: {
116
+ root?: string;
117
+ };
118
+ imageContainer?: string;
119
+ uploadingOverlay?: string;
120
+ statusBadge?: string;
121
+ statusBadgeSuccess?: string;
122
+ statusBadgeError?: string;
123
+ }
124
+ interface MediaUploadProps extends MediaUploadHandlers {
125
+ maxSize?: number;
126
+ acceptedTypes?: string[];
127
+ multiple?: boolean;
128
+ folder?: string;
129
+ classNames?: MediaUploadClassNames;
130
+ }
131
+
132
+ declare function MediaUpload({ onUpload, onSave, onUploadSuccess, onUploadError, maxSize, acceptedTypes, multiple, folder, classNames, }: MediaUploadProps): react_jsx_runtime.JSX.Element;
133
+
134
+ interface MediaGridClassNames {
135
+ rootStack?: {
136
+ root?: string;
137
+ };
138
+ filterGroup?: {
139
+ root?: string;
140
+ };
141
+ sortSelect?: {
142
+ root?: string;
143
+ wrapper?: string;
144
+ input?: string;
145
+ section?: string;
146
+ dropdown?: string;
147
+ };
148
+ searchInput?: {
149
+ root?: string;
150
+ wrapper?: string;
151
+ input?: string;
152
+ section?: string;
153
+ };
154
+ grid?: {
155
+ root?: string;
156
+ inner?: string;
157
+ col?: string;
158
+ };
159
+ itemPaper?: {
160
+ root?: string;
161
+ };
162
+ itemStack?: {
163
+ root?: string;
164
+ };
165
+ itemImage?: {
166
+ root?: string;
167
+ };
168
+ itemText?: {
169
+ root?: string;
170
+ };
171
+ imageContainer?: string;
172
+ selectedPaper?: string;
173
+ }
174
+ interface MediaGridProps {
175
+ images: IMedia[];
176
+ selectedImageId?: string | null;
177
+ onImageClick: (imageId: string) => void;
178
+ sortOptions?: {
179
+ value: string;
180
+ label: string;
181
+ }[];
182
+ classNames?: MediaGridClassNames;
183
+ }
184
+
185
+ declare function MediaGrid({ images, selectedImageId, onImageClick, sortOptions, classNames, }: MediaGridProps): react_jsx_runtime.JSX.Element;
186
+
187
+ interface MediaDetailClassNames {
188
+ paper?: {
189
+ root?: string;
190
+ };
191
+ image?: {
192
+ root?: string;
193
+ };
194
+ title?: {
195
+ root?: string;
196
+ };
197
+ fieldsStack?: {
198
+ root?: string;
199
+ };
200
+ fieldLabel?: {
201
+ root?: string;
202
+ };
203
+ fieldValue?: {
204
+ root?: string;
205
+ };
206
+ textarea?: {
207
+ root?: string;
208
+ input?: string;
209
+ wrapper?: string;
210
+ };
211
+ saveButton?: {
212
+ root?: string;
213
+ };
214
+ copyButton?: {
215
+ root?: string;
216
+ };
217
+ deleteButton?: {
218
+ root?: string;
219
+ };
220
+ imageWrapper?: string;
221
+ fieldGroup?: string;
222
+ urlText?: string;
223
+ }
224
+ interface MediaDetailProps {
225
+ image: IMedia;
226
+ onUpdate: (id: string, data: IUpdateMedia) => Promise<void>;
227
+ onDelete?: (id: string) => void;
228
+ onCopyLink?: (url: string) => void;
229
+ onNotify?: (type: 'success' | 'error', message: string) => void;
230
+ classNames?: MediaDetailClassNames;
231
+ }
232
+
233
+ declare function MediaDetail({ image, onUpdate, onDelete, onCopyLink, onNotify, classNames, }: MediaDetailProps): react_jsx_runtime.JSX.Element;
234
+
235
+ declare const validateImageFile: (file: File) => boolean;
236
+ declare const formatFileSize: (bytes: number) => string;
237
+ /**
238
+ * Merge multiple className strings into one, filtering out falsy values
239
+ * @param classNames - Array of className strings (can include undefined)
240
+ * @returns Single merged className string
241
+ */
242
+ declare const cx: (...classNames: (string | undefined)[]) => string;
243
+
244
+ export { type ICreateMedia, type IMedia, type IUpdateMedia, MediaDetail, type MediaDetailClassNames, type MediaDetailHandlers, type MediaDetailProps, MediaGrid, type MediaGridClassNames, type MediaGridHandlers, type MediaGridProps, type MediaTabsConfig, MediaUpload, type MediaUploadClassNames, type MediaUploadHandlers, type MediaUploadProps, type UploadFileItem, type UploadResult, cx, formatFileSize, validateImageFile };