5htp-core 0.4.8-1 → 0.4.8-2
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.4.8-
|
|
4
|
+
"version": "0.4.8-2",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@ export type Props = {
|
|
|
60
60
|
|
|
61
61
|
// Input
|
|
62
62
|
title: ComponentChild,
|
|
63
|
-
value?: FileToUpload,
|
|
63
|
+
value?: string | FileToUpload, // string = already registered
|
|
64
64
|
|
|
65
65
|
// Display
|
|
66
66
|
emptyText?: ComponentChild,
|
|
@@ -96,7 +96,7 @@ export default ({
|
|
|
96
96
|
|
|
97
97
|
const [previewUrl, setPreviewUrl] = React.useState<string | undefined>(previewUrlInit);
|
|
98
98
|
|
|
99
|
-
className = 'input upload ' + (className === undefined ? '' : ' ' + className)
|
|
99
|
+
className = 'input upload ' + (className === undefined ? '' : ' ' + className);
|
|
100
100
|
|
|
101
101
|
/*----------------------------------
|
|
102
102
|
- ACTIONS
|
|
@@ -115,7 +115,7 @@ export default ({
|
|
|
115
115
|
React.useEffect(() => {
|
|
116
116
|
|
|
117
117
|
// Image = decode & display preview
|
|
118
|
-
if (file !== undefined && file.type.startsWith('image/'))
|
|
118
|
+
if (file !== undefined && typeof file === 'object' && file.type.startsWith('image/'))
|
|
119
119
|
createImagePreview(file.data).then(setPreviewUrl);
|
|
120
120
|
else
|
|
121
121
|
setPreviewUrl(undefined);
|
|
@@ -135,14 +135,20 @@ export default ({
|
|
|
135
135
|
|
|
136
136
|
{previewUrl ? (
|
|
137
137
|
<img src={previewUrl} />
|
|
138
|
-
) : file ? <>
|
|
138
|
+
) : typeof file === 'string' ? <>
|
|
139
|
+
<strong>A file has been selected</strong>
|
|
140
|
+
</> : file ? <>
|
|
139
141
|
<strong>{file.name}</strong>
|
|
140
142
|
</> : null}
|
|
141
143
|
</div>
|
|
142
144
|
|
|
143
145
|
<div class="row actions sp-05">
|
|
146
|
+
|
|
147
|
+
{typeof file === 'string' && <>
|
|
148
|
+
<Bouton type="secondary" icon="eye" shape="pill" size="s" link={file} />
|
|
149
|
+
</>}
|
|
144
150
|
|
|
145
|
-
<Bouton class='
|
|
151
|
+
<Bouton class='bg error' icon="trash" shape="pill" size="s"
|
|
146
152
|
async onClick={() => onChange(undefined)} />
|
|
147
153
|
</div>
|
|
148
154
|
</>}
|
|
@@ -402,14 +402,14 @@ export default class SchemaValidators {
|
|
|
402
402
|
|
|
403
403
|
} = {}) => new Validator<FileToUpload>('file', (val, options, path) => {
|
|
404
404
|
|
|
405
|
-
if (!(val instanceof FileToUpload))
|
|
406
|
-
throw new InputError(`Must be a File (${typeof val} received)`);
|
|
407
|
-
|
|
408
405
|
// Chaine = url ancien fichier = exclusion de la valeur pour conserver l'ancien fichier
|
|
409
406
|
// NOTE: Si la valeur est présente mais undefined, alors on supprimera le fichier
|
|
410
407
|
if (typeof val === 'string')
|
|
411
408
|
return EXCLUDE_VALUE;
|
|
412
409
|
|
|
410
|
+
if (!(val instanceof FileToUpload))
|
|
411
|
+
throw new InputError(`Must be a File (${typeof val} received)`);
|
|
412
|
+
|
|
413
413
|
// MIME
|
|
414
414
|
if (type !== undefined) {
|
|
415
415
|
|