@kopexa/sight 17.12.1 → 17.13.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/chunk-5LLYOCGQ.mjs +153 -0
- package/dist/chunk-6IAHC3UK.mjs +1 -0
- package/dist/chunk-6XUZNN3X.mjs +1 -0
- package/dist/chunk-7KISSD3Q.mjs +1 -0
- package/dist/chunk-BJ7QPNKW.mjs +242 -0
- package/dist/chunk-CZNF6WPR.mjs +33 -0
- package/dist/chunk-DU3OVIBY.mjs +16 -0
- package/dist/chunk-DWZQIPCX.mjs +301 -0
- package/dist/chunk-EAJ3DTJ3.mjs +59 -0
- package/dist/chunk-FBTSAODG.mjs +25 -0
- package/dist/chunk-G57FFIKP.mjs +48 -0
- package/dist/chunk-GR3VEF4M.mjs +1 -0
- package/dist/chunk-HISY6ZIK.mjs +1 -0
- package/dist/chunk-HUHVPC6T.mjs +17 -0
- package/dist/chunk-HVOS7SXF.mjs +15 -0
- package/dist/chunk-PKG2E3MX.mjs +1 -0
- package/dist/chunk-POVIOFVF.mjs +18 -0
- package/dist/chunk-RK7G2GYB.mjs +45 -0
- package/dist/chunk-SHETEVHO.mjs +178 -0
- package/dist/chunk-UWC3Z7SY.mjs +1 -0
- package/dist/chunk-UWQG4HGJ.mjs +13 -0
- package/dist/chunk-XL2RCXMY.mjs +26 -0
- package/dist/chunk-XPDEN2RV.mjs +1 -0
- package/dist/components/blankstate/blankstate.d.mts +14 -0
- package/dist/components/blankstate/blankstate.d.ts +14 -0
- package/dist/components/blankstate/blankstate.js +69 -0
- package/dist/components/blankstate/blankstate.mjs +7 -0
- package/dist/components/blankstate/index.d.mts +4 -0
- package/dist/components/blankstate/index.d.ts +4 -0
- package/dist/components/blankstate/index.js +71 -0
- package/dist/components/blankstate/index.mjs +8 -0
- package/dist/components/code/code.d.mts +9 -0
- package/dist/components/code/code.d.ts +9 -0
- package/dist/components/code/code.js +49 -0
- package/dist/components/code/code.mjs +7 -0
- package/dist/components/code/index.d.mts +4 -0
- package/dist/components/code/index.d.ts +4 -0
- package/dist/components/code/index.js +51 -0
- package/dist/components/code/index.mjs +8 -0
- package/dist/components/dialog/dialog.d.mts +44 -0
- package/dist/components/dialog/dialog.d.ts +44 -0
- package/dist/components/dialog/dialog.js +213 -0
- package/dist/components/dialog/dialog.mjs +31 -0
- package/dist/components/dialog/index.d.mts +22 -0
- package/dist/components/dialog/index.d.ts +22 -0
- package/dist/components/dialog/index.js +232 -0
- package/dist/components/dialog/index.mjs +35 -0
- package/dist/components/dialog/namespace.d.mts +5 -0
- package/dist/components/dialog/namespace.d.ts +5 -0
- package/dist/components/dialog/namespace.js +213 -0
- package/dist/components/dialog/namespace.mjs +29 -0
- package/dist/components/dialog/transition.d.mts +5 -0
- package/dist/components/dialog/transition.d.ts +5 -0
- package/dist/components/dialog/transition.js +132 -0
- package/dist/components/dialog/transition.mjs +106 -0
- package/dist/components/file-upload/avatar-upload.d.mts +54 -0
- package/dist/components/file-upload/avatar-upload.d.ts +54 -0
- package/dist/components/file-upload/avatar-upload.js +841 -0
- package/dist/components/file-upload/avatar-upload.mjs +15 -0
- package/dist/components/file-upload/index.d.mts +5 -0
- package/dist/components/file-upload/index.d.ts +5 -0
- package/dist/components/file-upload/index.js +843 -0
- package/dist/components/file-upload/index.mjs +16 -0
- package/dist/components/file-upload/messages.d.mts +39 -0
- package/dist/components/file-upload/messages.d.ts +39 -0
- package/dist/components/file-upload/messages.js +68 -0
- package/dist/components/file-upload/messages.mjs +7 -0
- package/dist/components/file-upload/utils/data-url-to-file.d.mts +3 -0
- package/dist/components/file-upload/utils/data-url-to-file.d.ts +3 -0
- package/dist/components/file-upload/utils/data-url-to-file.js +38 -0
- package/dist/components/file-upload/utils/data-url-to-file.mjs +7 -0
- package/dist/components/file-upload/utils/format-accept-types.d.mts +8 -0
- package/dist/components/file-upload/utils/format-accept-types.d.ts +8 -0
- package/dist/components/file-upload/utils/format-accept-types.js +82 -0
- package/dist/components/file-upload/utils/format-accept-types.mjs +7 -0
- package/dist/components/file-upload/utils/is-image-like.d.mts +3 -0
- package/dist/components/file-upload/utils/is-image-like.d.ts +3 -0
- package/dist/components/file-upload/utils/is-image-like.js +36 -0
- package/dist/components/file-upload/utils/is-image-like.mjs +7 -0
- package/dist/components/index.d.mts +67 -0
- package/dist/components/index.d.ts +67 -0
- package/dist/components/index.js +1137 -0
- package/dist/components/index.mjs +92 -0
- package/dist/components/skeleton/index.d.mts +5 -0
- package/dist/components/skeleton/index.d.ts +5 -0
- package/dist/components/skeleton/index.js +53 -0
- package/dist/components/skeleton/index.mjs +12 -0
- package/dist/components/skeleton/skeleton-avatar.d.mts +9 -0
- package/dist/components/skeleton/skeleton-avatar.d.ts +9 -0
- package/dist/components/skeleton/skeleton-avatar.js +51 -0
- package/dist/components/skeleton/skeleton-avatar.mjs +8 -0
- package/dist/components/skeleton/skeleton.d.mts +7 -0
- package/dist/components/skeleton/skeleton.d.ts +7 -0
- package/dist/components/skeleton/skeleton.js +39 -0
- package/dist/components/skeleton/skeleton.mjs +7 -0
- package/dist/components/stat/index.d.mts +4 -0
- package/dist/components/stat/index.d.ts +4 -0
- package/dist/components/stat/index.js +186 -0
- package/dist/components/stat/index.mjs +24 -0
- package/dist/components/stat/stat.d.mts +36 -0
- package/dist/components/stat/stat.d.ts +36 -0
- package/dist/components/stat/stat.js +185 -0
- package/dist/components/stat/stat.mjs +24 -0
- package/dist/components/textarea/index.d.mts +4 -0
- package/dist/components/textarea/index.d.ts +4 -0
- package/dist/components/textarea/index.js +42 -0
- package/dist/components/textarea/index.mjs +8 -0
- package/dist/components/textarea/textarea.d.mts +8 -0
- package/dist/components/textarea/textarea.d.ts +8 -0
- package/dist/components/textarea/textarea.js +40 -0
- package/dist/components/textarea/textarea.mjs +7 -0
- package/dist/hooks/index.d.mts +2 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +341 -0
- package/dist/hooks/index.mjs +9 -0
- package/dist/hooks/use-file-upload/index.d.mts +47 -0
- package/dist/hooks/use-file-upload/index.d.ts +47 -0
- package/dist/hooks/use-file-upload/index.js +340 -0
- package/dist/hooks/use-file-upload/index.mjs +9 -0
- package/dist/hooks/use-file-upload/messages.d.mts +19 -0
- package/dist/hooks/use-file-upload/messages.d.ts +19 -0
- package/dist/hooks/use-file-upload/messages.js +48 -0
- package/dist/hooks/use-file-upload/messages.mjs +7 -0
- package/dist/index.d.mts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +1108 -32
- package/dist/index.mjs +82 -18
- package/dist/index.ts.backup.d.mts +14 -8
- package/dist/index.ts.backup.d.ts +14 -8
- package/dist/index.ts.backup.js +1108 -32
- package/dist/index.ts.backup.mjs +82 -18
- package/package.json +60 -64
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
messages
|
|
4
|
+
} from "./chunk-FBTSAODG.mjs";
|
|
5
|
+
|
|
6
|
+
// src/hooks/use-file-upload/index.ts
|
|
7
|
+
import { useSafeIntl } from "@kopexa/i18n";
|
|
8
|
+
import { formatBytes } from "@kopexa/shared-utils";
|
|
9
|
+
import {
|
|
10
|
+
useCallback,
|
|
11
|
+
useRef,
|
|
12
|
+
useState
|
|
13
|
+
} from "react";
|
|
14
|
+
var useFileUpload = (options = {}) => {
|
|
15
|
+
const {
|
|
16
|
+
maxFiles = Number.POSITIVE_INFINITY,
|
|
17
|
+
maxSize = Number.POSITIVE_INFINITY,
|
|
18
|
+
accept = "*",
|
|
19
|
+
multiple = false,
|
|
20
|
+
initialFiles = [],
|
|
21
|
+
onFilesChange,
|
|
22
|
+
onFilesAdded,
|
|
23
|
+
onError
|
|
24
|
+
} = options;
|
|
25
|
+
const t = useSafeIntl();
|
|
26
|
+
const [state, setState] = useState({
|
|
27
|
+
files: initialFiles.map((file) => ({
|
|
28
|
+
file,
|
|
29
|
+
id: file.id,
|
|
30
|
+
preview: file.url
|
|
31
|
+
})),
|
|
32
|
+
isDragging: false,
|
|
33
|
+
errors: []
|
|
34
|
+
});
|
|
35
|
+
const inputRef = useRef(null);
|
|
36
|
+
const validateFile = useCallback(
|
|
37
|
+
(file) => {
|
|
38
|
+
if (file instanceof File) {
|
|
39
|
+
if (file.size > maxSize) {
|
|
40
|
+
return t.formatMessage(messages.file_exceeds_max, {
|
|
41
|
+
name: file.name,
|
|
42
|
+
max: formatBytes(maxSize)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (file.size > maxSize) {
|
|
47
|
+
return t.formatMessage(messages.file_exceeds_max, {
|
|
48
|
+
name: file.name,
|
|
49
|
+
max: formatBytes(maxSize)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (accept !== "*") {
|
|
54
|
+
const acceptedTypes = accept.split(",").map((type) => type.trim());
|
|
55
|
+
const fileType = file instanceof File ? file.type || "" : file.type;
|
|
56
|
+
const fileExtension = `.${file instanceof File ? file.name.split(".").pop() : file.name.split(".").pop()}`;
|
|
57
|
+
const isAccepted = acceptedTypes.some((type) => {
|
|
58
|
+
if (type.startsWith(".")) {
|
|
59
|
+
return fileExtension.toLowerCase() === type.toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
if (type.endsWith("/*")) {
|
|
62
|
+
const baseType = type.split("/")[0];
|
|
63
|
+
return fileType.startsWith(`${baseType}/`);
|
|
64
|
+
}
|
|
65
|
+
return fileType === type;
|
|
66
|
+
});
|
|
67
|
+
if (!isAccepted) {
|
|
68
|
+
return t.formatMessage(messages.file_not_accepted, {
|
|
69
|
+
name: file instanceof File ? file.name : file.name
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
},
|
|
75
|
+
[accept, maxSize, t.formatMessage]
|
|
76
|
+
);
|
|
77
|
+
const createPreview = useCallback(
|
|
78
|
+
(file) => {
|
|
79
|
+
if (file instanceof File) {
|
|
80
|
+
return URL.createObjectURL(file);
|
|
81
|
+
}
|
|
82
|
+
return file.url;
|
|
83
|
+
},
|
|
84
|
+
[]
|
|
85
|
+
);
|
|
86
|
+
const generateUniqueId = useCallback((file) => {
|
|
87
|
+
if (file instanceof File) {
|
|
88
|
+
return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
89
|
+
}
|
|
90
|
+
return file.id;
|
|
91
|
+
}, []);
|
|
92
|
+
const clearFiles = useCallback(() => {
|
|
93
|
+
setState((prev) => {
|
|
94
|
+
for (const file of prev.files) {
|
|
95
|
+
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) {
|
|
96
|
+
URL.revokeObjectURL(file.preview);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (inputRef.current) {
|
|
100
|
+
inputRef.current.value = "";
|
|
101
|
+
}
|
|
102
|
+
const newState = {
|
|
103
|
+
...prev,
|
|
104
|
+
files: [],
|
|
105
|
+
errors: []
|
|
106
|
+
};
|
|
107
|
+
onFilesChange == null ? void 0 : onFilesChange(newState.files);
|
|
108
|
+
return newState;
|
|
109
|
+
});
|
|
110
|
+
}, [onFilesChange]);
|
|
111
|
+
const addFiles = useCallback(
|
|
112
|
+
(newFiles) => {
|
|
113
|
+
if (!newFiles || newFiles.length === 0) return;
|
|
114
|
+
const newFilesArray = Array.from(newFiles);
|
|
115
|
+
const errors = [];
|
|
116
|
+
setState((prev) => ({ ...prev, errors: [] }));
|
|
117
|
+
if (!multiple) {
|
|
118
|
+
clearFiles();
|
|
119
|
+
}
|
|
120
|
+
if (multiple && maxFiles !== Number.POSITIVE_INFINITY && state.files.length + newFilesArray.length > maxFiles) {
|
|
121
|
+
errors.push(
|
|
122
|
+
t.formatMessage(messages.too_many_files, {
|
|
123
|
+
max: maxFiles
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
onError == null ? void 0 : onError(errors);
|
|
127
|
+
setState((prev) => ({ ...prev, errors }));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const validFiles = [];
|
|
131
|
+
for (const file of newFilesArray) {
|
|
132
|
+
if (multiple) {
|
|
133
|
+
const isDuplicate = state.files.some(
|
|
134
|
+
(existingFile) => existingFile.file.name === file.name && existingFile.file.size === file.size
|
|
135
|
+
);
|
|
136
|
+
if (isDuplicate) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (file.size > maxSize) {
|
|
141
|
+
errors.push(
|
|
142
|
+
multiple ? `Some files exceed the maximum size of ${formatBytes(maxSize)}.` : `File exceeds the maximum size of ${formatBytes(maxSize)}.`
|
|
143
|
+
);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const error = validateFile(file);
|
|
147
|
+
if (error) {
|
|
148
|
+
errors.push(error);
|
|
149
|
+
} else {
|
|
150
|
+
validFiles.push({
|
|
151
|
+
file,
|
|
152
|
+
id: generateUniqueId(file),
|
|
153
|
+
preview: createPreview(file)
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (validFiles.length > 0) {
|
|
158
|
+
onFilesAdded == null ? void 0 : onFilesAdded(validFiles);
|
|
159
|
+
setState((prev) => {
|
|
160
|
+
const newFiles2 = !multiple ? validFiles : [...prev.files, ...validFiles];
|
|
161
|
+
onFilesChange == null ? void 0 : onFilesChange(newFiles2);
|
|
162
|
+
return {
|
|
163
|
+
...prev,
|
|
164
|
+
files: newFiles2,
|
|
165
|
+
errors
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
} else if (errors.length > 0) {
|
|
169
|
+
onError == null ? void 0 : onError(errors);
|
|
170
|
+
setState((prev) => ({
|
|
171
|
+
...prev,
|
|
172
|
+
errors
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
if (inputRef.current) {
|
|
176
|
+
inputRef.current.value = "";
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
[
|
|
180
|
+
onError,
|
|
181
|
+
state.files,
|
|
182
|
+
maxFiles,
|
|
183
|
+
multiple,
|
|
184
|
+
maxSize,
|
|
185
|
+
validateFile,
|
|
186
|
+
createPreview,
|
|
187
|
+
generateUniqueId,
|
|
188
|
+
clearFiles,
|
|
189
|
+
onFilesChange,
|
|
190
|
+
onFilesAdded,
|
|
191
|
+
t.formatMessage
|
|
192
|
+
]
|
|
193
|
+
);
|
|
194
|
+
const removeFile = useCallback(
|
|
195
|
+
(id) => {
|
|
196
|
+
setState((prev) => {
|
|
197
|
+
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
198
|
+
if ((fileToRemove == null ? void 0 : fileToRemove.preview) && fileToRemove.file instanceof File && fileToRemove.file.type.startsWith("image/")) {
|
|
199
|
+
URL.revokeObjectURL(fileToRemove.preview);
|
|
200
|
+
}
|
|
201
|
+
const newFiles = prev.files.filter((file) => file.id !== id);
|
|
202
|
+
onFilesChange == null ? void 0 : onFilesChange(newFiles);
|
|
203
|
+
return {
|
|
204
|
+
...prev,
|
|
205
|
+
files: newFiles,
|
|
206
|
+
errors: []
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
[onFilesChange]
|
|
211
|
+
);
|
|
212
|
+
const clearErrors = useCallback(() => {
|
|
213
|
+
setState((prev) => ({
|
|
214
|
+
...prev,
|
|
215
|
+
errors: []
|
|
216
|
+
}));
|
|
217
|
+
}, []);
|
|
218
|
+
const handleDragEnter = useCallback((e) => {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
e.stopPropagation();
|
|
221
|
+
setState((prev) => ({ ...prev, isDragging: true }));
|
|
222
|
+
}, []);
|
|
223
|
+
const handleDragLeave = useCallback((e) => {
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
e.stopPropagation();
|
|
226
|
+
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
230
|
+
}, []);
|
|
231
|
+
const handleDragOver = useCallback((e) => {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
e.stopPropagation();
|
|
234
|
+
}, []);
|
|
235
|
+
const handleDrop = useCallback(
|
|
236
|
+
(e) => {
|
|
237
|
+
var _a;
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
e.stopPropagation();
|
|
240
|
+
setState((prev) => ({ ...prev, isDragging: false }));
|
|
241
|
+
if ((_a = inputRef.current) == null ? void 0 : _a.disabled) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
245
|
+
if (!multiple) {
|
|
246
|
+
const file = e.dataTransfer.files[0];
|
|
247
|
+
addFiles([file]);
|
|
248
|
+
} else {
|
|
249
|
+
addFiles(e.dataTransfer.files);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
[addFiles, multiple]
|
|
254
|
+
);
|
|
255
|
+
const handleFileChange = useCallback(
|
|
256
|
+
(e) => {
|
|
257
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
258
|
+
addFiles(e.target.files);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
[addFiles]
|
|
262
|
+
);
|
|
263
|
+
const openFileDialog = useCallback(() => {
|
|
264
|
+
if (inputRef.current) {
|
|
265
|
+
inputRef.current.click();
|
|
266
|
+
}
|
|
267
|
+
}, []);
|
|
268
|
+
const getInputProps = useCallback(
|
|
269
|
+
(props = {}) => {
|
|
270
|
+
return {
|
|
271
|
+
...props,
|
|
272
|
+
type: "file",
|
|
273
|
+
onChange: handleFileChange,
|
|
274
|
+
accept: props.accept || accept,
|
|
275
|
+
multiple: props.multiple !== void 0 ? props.multiple : multiple,
|
|
276
|
+
ref: inputRef
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
[accept, multiple, handleFileChange]
|
|
280
|
+
);
|
|
281
|
+
return [
|
|
282
|
+
state,
|
|
283
|
+
{
|
|
284
|
+
addFiles,
|
|
285
|
+
removeFile,
|
|
286
|
+
clearFiles,
|
|
287
|
+
clearErrors,
|
|
288
|
+
handleDragEnter,
|
|
289
|
+
handleDragLeave,
|
|
290
|
+
handleDragOver,
|
|
291
|
+
handleDrop,
|
|
292
|
+
handleFileChange,
|
|
293
|
+
openFileDialog,
|
|
294
|
+
getInputProps
|
|
295
|
+
}
|
|
296
|
+
];
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
export {
|
|
300
|
+
useFileUpload
|
|
301
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/file-upload/utils/format-accept-types.ts
|
|
4
|
+
var WILDCARD_GROUPS = {
|
|
5
|
+
"image/*": "common image formats",
|
|
6
|
+
"audio/*": "common audio formats",
|
|
7
|
+
"video/*": "common video formats",
|
|
8
|
+
"application/*": "common document formats"
|
|
9
|
+
};
|
|
10
|
+
var MIME_TO_LABEL = {
|
|
11
|
+
"image/png": "PNG",
|
|
12
|
+
"image/jpeg": "JPG",
|
|
13
|
+
"image/jpg": "JPG",
|
|
14
|
+
"application/pdf": "PDF",
|
|
15
|
+
"text/csv": "CSV",
|
|
16
|
+
"text/plain": "TXT"
|
|
17
|
+
};
|
|
18
|
+
var EXT_TO_LABEL = {
|
|
19
|
+
".png": "PNG",
|
|
20
|
+
".jpg": "JPG",
|
|
21
|
+
".jpeg": "JPG",
|
|
22
|
+
".pdf": "PDF",
|
|
23
|
+
".csv": "CSV",
|
|
24
|
+
".txt": "TXT"
|
|
25
|
+
};
|
|
26
|
+
function normalizeToken(token) {
|
|
27
|
+
return token.trim().toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
function formatAcceptedTypes(accept) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
if (!accept || typeof accept !== "string") return "";
|
|
32
|
+
const tokens = accept.split(",").map(normalizeToken).filter(Boolean);
|
|
33
|
+
const labels = [];
|
|
34
|
+
for (const token of tokens) {
|
|
35
|
+
if (WILDCARD_GROUPS[token]) {
|
|
36
|
+
labels.push(WILDCARD_GROUPS[token]);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (token.startsWith(".")) {
|
|
40
|
+
labels.push(
|
|
41
|
+
(_a = EXT_TO_LABEL[token]) != null ? _a : token.replace(/^\./, "").toUpperCase()
|
|
42
|
+
);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (token.includes("/")) {
|
|
46
|
+
labels.push((_b = MIME_TO_LABEL[token]) != null ? _b : token.split("/")[1].toUpperCase());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const seen = /* @__PURE__ */ new Set();
|
|
50
|
+
return labels.filter((x) => {
|
|
51
|
+
if (seen.has(x)) return false;
|
|
52
|
+
seen.add(x);
|
|
53
|
+
return true;
|
|
54
|
+
}).join(", ");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
formatAcceptedTypes
|
|
59
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/hooks/use-file-upload/messages.ts
|
|
4
|
+
import { defineMessages } from "@kopexa/i18n";
|
|
5
|
+
var messages = defineMessages({
|
|
6
|
+
file_exceeds_max: {
|
|
7
|
+
id: "use_file_upload.file_exceeds_max",
|
|
8
|
+
defaultMessage: `File "{name}" exceeds the maximum size of {max}.`,
|
|
9
|
+
description: "Shown when a single file is larger than allowed"
|
|
10
|
+
},
|
|
11
|
+
file_not_accepted: {
|
|
12
|
+
id: "use_file_upload.file_not_accepted",
|
|
13
|
+
defaultMessage: `File "{name}" is not an accepted file type.`,
|
|
14
|
+
description: "Shown when file type/extension doesn't match accept"
|
|
15
|
+
},
|
|
16
|
+
too_many_files: {
|
|
17
|
+
id: "file_upload.too_many_files",
|
|
18
|
+
defaultMessage: "You can only upload a maximum of {max} files.",
|
|
19
|
+
description: "Shown when maxFiles would be exceeded"
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
messages
|
|
25
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/blankstate/blankstate.tsx
|
|
4
|
+
import { cn } from "@kopexa/shared-utils";
|
|
5
|
+
import {
|
|
6
|
+
blankstate
|
|
7
|
+
} from "@kopexa/theme";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var Blankstate = (props) => {
|
|
10
|
+
const {
|
|
11
|
+
className,
|
|
12
|
+
children,
|
|
13
|
+
classNames,
|
|
14
|
+
icon,
|
|
15
|
+
title,
|
|
16
|
+
description,
|
|
17
|
+
size,
|
|
18
|
+
bordered,
|
|
19
|
+
narrow,
|
|
20
|
+
...rest
|
|
21
|
+
} = props;
|
|
22
|
+
const styles = blankstate({ size, bordered, narrow });
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
"div",
|
|
25
|
+
{
|
|
26
|
+
className: styles.root({ className: cn(classNames == null ? void 0 : classNames.root, className) }),
|
|
27
|
+
...rest,
|
|
28
|
+
children: /* @__PURE__ */ jsxs("div", { className: styles.container({ className: classNames == null ? void 0 : classNames.container }), children: [
|
|
29
|
+
icon && /* @__PURE__ */ jsx("div", { className: styles.icon({ className: classNames == null ? void 0 : classNames.icon }), children: icon }),
|
|
30
|
+
title && /* @__PURE__ */ jsx("h2", { className: styles.title({ className: classNames == null ? void 0 : classNames.title }), children: title }),
|
|
31
|
+
description && /* @__PURE__ */ jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: styles.description({
|
|
35
|
+
className: classNames == null ? void 0 : classNames.description
|
|
36
|
+
}),
|
|
37
|
+
children: description
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
children && /* @__PURE__ */ jsx("div", { className: styles.actions({ className: classNames == null ? void 0 : classNames.actions }), children })
|
|
41
|
+
] })
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
Blankstate
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/textarea/textarea.tsx
|
|
4
|
+
import { textarea } from "@kopexa/theme";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var Textarea = (props) => {
|
|
7
|
+
const { className, size, ...rest } = props;
|
|
8
|
+
const styles = textarea({
|
|
9
|
+
className,
|
|
10
|
+
size
|
|
11
|
+
});
|
|
12
|
+
return /* @__PURE__ */ jsx("textarea", { "data-slot": "textarea", className: styles, ...rest });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
Textarea
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/file-upload/utils/data-url-to-file.ts
|
|
4
|
+
async function dataUrlToFile(dataUrl, fileName, typeHint) {
|
|
5
|
+
const res = await fetch(dataUrl);
|
|
6
|
+
const blob = await res.blob();
|
|
7
|
+
const type = typeHint || blob.type || "image/png";
|
|
8
|
+
const ext = type.includes("jpeg") ? "jpg" : type.split("/")[1] || "png";
|
|
9
|
+
const safeName = fileName.replace(/\.[^.]+$/, "");
|
|
10
|
+
return new File([blob], `${safeName}-cropped.${ext}`, { type });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
dataUrlToFile
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Skeleton
|
|
4
|
+
} from "./chunk-DU3OVIBY.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/skeleton/skeleton-avatar.tsx
|
|
7
|
+
import { cn } from "@kopexa/shared-utils";
|
|
8
|
+
import { skeletonAvatar } from "@kopexa/theme";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var SkeletonAvatar = (props) => {
|
|
11
|
+
const { size, className, ...restProps } = props;
|
|
12
|
+
const baseStyle = skeletonAvatar({ size });
|
|
13
|
+
return /* @__PURE__ */ jsx(Skeleton, { ...restProps, className: cn(baseStyle, className) });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
SkeletonAvatar
|
|
18
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/file-upload/messages.ts
|
|
4
|
+
import { defineMessages } from "@kopexa/i18n";
|
|
5
|
+
var messages = defineMessages({
|
|
6
|
+
change_avatar: {
|
|
7
|
+
id: "file_upload.change_avatar",
|
|
8
|
+
defaultMessage: "Change Avatar",
|
|
9
|
+
description: "Label for changing the avatar image"
|
|
10
|
+
},
|
|
11
|
+
upload_avatar: {
|
|
12
|
+
id: "file_upload.upload_avatar",
|
|
13
|
+
defaultMessage: "Upload Avatar",
|
|
14
|
+
description: "Label for uploading a new avatar image"
|
|
15
|
+
},
|
|
16
|
+
remove_avatar: {
|
|
17
|
+
id: "file_upload.remove_avatar",
|
|
18
|
+
defaultMessage: "Remove Avatar",
|
|
19
|
+
description: "Label for removing the current avatar image"
|
|
20
|
+
},
|
|
21
|
+
avatar_uploaded: {
|
|
22
|
+
id: "file_upload.avatar_uploaded",
|
|
23
|
+
defaultMessage: "Avatar uploaded",
|
|
24
|
+
description: "Message displayed when the avatar is uploaded successfully"
|
|
25
|
+
},
|
|
26
|
+
accepted_file_types: {
|
|
27
|
+
id: "file_upload.accepted_file_types",
|
|
28
|
+
defaultMessage: "{types}{size, select, none {} other { up to {size}}}",
|
|
29
|
+
description: "Message indicating the accepted file types for upload"
|
|
30
|
+
},
|
|
31
|
+
cancel: {
|
|
32
|
+
id: "file_upload.cancel",
|
|
33
|
+
defaultMessage: "Cancel",
|
|
34
|
+
description: "Label for canceling the file upload"
|
|
35
|
+
},
|
|
36
|
+
apply_crop: {
|
|
37
|
+
id: "file_upload.apply_crop",
|
|
38
|
+
defaultMessage: "Apply",
|
|
39
|
+
description: "Label for applying the crop to the image"
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
messages
|
|
45
|
+
};
|