@rsuci/shared-form-components 1.0.78 → 1.0.79
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/IdDocInput.d.ts.map +1 -1
- package/dist/components/IdDocInput.js +3 -2
- package/dist/components/wrappers/ImageUpload.d.ts.map +1 -1
- package/dist/components/wrappers/ImageUpload.js +25 -6
- package/dist/components/wrappers/PhotoCapture.d.ts.map +1 -1
- package/dist/components/wrappers/PhotoCapture.js +25 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdDocInput.d.ts","sourceRoot":"","sources":["../../src/components/IdDocInput.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKrE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuBD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"IdDocInput.d.ts","sourceRoot":"","sources":["../../src/components/IdDocInput.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKrE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuBD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+XzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -63,10 +63,11 @@ const IdDocInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
}, [stream]);
|
|
66
|
-
// Mettre à jour les données
|
|
66
|
+
// Mettre à jour les données (sérialiser en JSON string comme DatePicker le fait pour les dates)
|
|
67
67
|
const updateData = (updates) => {
|
|
68
68
|
const newData = { ...currentData, ...updates };
|
|
69
|
-
|
|
69
|
+
const serializedValue = VariableValueConverter.serialize(newData, variable.typeCode);
|
|
70
|
+
onChange(serializedValue);
|
|
70
71
|
};
|
|
71
72
|
// Gérer la sélection de fichier
|
|
72
73
|
const handleFileSelect = async (event) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../src/components/wrappers/ImageUpload.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../src/components/wrappers/ImageUpload.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,UAAU,CAAC,EAAE;YACX,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC;KACH,CAAC;IACF,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4G3C,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,eAAe,WAAW,CAAC"}
|
|
@@ -7,14 +7,30 @@ const ImageUpload = ({ variable, value, onChange, error, disabled }) => {
|
|
|
7
7
|
const [preview, setPreview] = useState(null);
|
|
8
8
|
const fileInputRef = React.useRef(null);
|
|
9
9
|
useEffect(() => {
|
|
10
|
-
if (value
|
|
11
|
-
|
|
10
|
+
if (value) {
|
|
11
|
+
// Gérer les deux formats : objet ou string JSON
|
|
12
|
+
let fileData = value;
|
|
13
|
+
if (typeof value === 'string') {
|
|
14
|
+
try {
|
|
15
|
+
fileData = JSON.parse(value);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
fileData = null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (fileData && typeof fileData === 'object' && fileData.imageData) {
|
|
22
|
+
setPreview(fileData.imageData);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
setPreview(null);
|
|
26
|
+
if (fileInputRef.current)
|
|
27
|
+
fileInputRef.current.value = '';
|
|
28
|
+
}
|
|
12
29
|
}
|
|
13
30
|
else {
|
|
14
31
|
setPreview(null);
|
|
15
|
-
if (fileInputRef.current)
|
|
32
|
+
if (fileInputRef.current)
|
|
16
33
|
fileInputRef.current.value = '';
|
|
17
|
-
}
|
|
18
34
|
}
|
|
19
35
|
}, [value]);
|
|
20
36
|
const handleFileSelect = async (event) => {
|
|
@@ -37,14 +53,17 @@ const ImageUpload = ({ variable, value, onChange, error, disabled }) => {
|
|
|
37
53
|
}
|
|
38
54
|
// Convertir en base64
|
|
39
55
|
const imageData = await VariableValueConverter.fileToBase64(file);
|
|
40
|
-
|
|
56
|
+
// Sérialiser en JSON string avant d'émettre (comme DatePicker le fait pour les dates)
|
|
57
|
+
const fileData = {
|
|
41
58
|
imageData,
|
|
42
59
|
name: file.name,
|
|
43
60
|
size: file.size,
|
|
44
61
|
type: file.type,
|
|
45
62
|
timestamp: new Date(),
|
|
46
63
|
source: 'upload'
|
|
47
|
-
}
|
|
64
|
+
};
|
|
65
|
+
const serializedValue = VariableValueConverter.serialize(fileData, variable.typeCode);
|
|
66
|
+
onChange(serializedValue);
|
|
48
67
|
};
|
|
49
68
|
return (_jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "text-sm text-gray-600 mb-2", children: "\uD83D\uDCC1 Upload d'image uniquement" }), _jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", onChange: handleFileSelect, disabled: disabled, className: `w-full px-3 py-2 border border-dashed rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white cursor-pointer hover:border-green-500'}` }), preview && (_jsxs("div", { className: "relative", children: [_jsx("img", { src: preview, alt: "Aper\u00E7u", className: "w-full max-w-xs mx-auto rounded-lg shadow-md" }), _jsx("button", { type: "button", onClick: () => {
|
|
50
69
|
onChange(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhotoCapture.d.ts","sourceRoot":"","sources":["../../../src/components/wrappers/PhotoCapture.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PhotoCapture.d.ts","sourceRoot":"","sources":["../../../src/components/wrappers/PhotoCapture.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,UAAU,CAAC,EAAE;YACX,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC;KACH,CAAC;IACF,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkQ7C,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,eAAe,YAAY,CAAC"}
|
|
@@ -12,14 +12,30 @@ const PhotoCapture = ({ variable, value, onChange, error, disabled }) => {
|
|
|
12
12
|
const videoRef = React.useRef(null);
|
|
13
13
|
const canvasRef = React.useRef(null);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
if (value
|
|
16
|
-
|
|
15
|
+
if (value) {
|
|
16
|
+
// Gérer les deux formats : objet ou string JSON
|
|
17
|
+
let fileData = value;
|
|
18
|
+
if (typeof value === 'string') {
|
|
19
|
+
try {
|
|
20
|
+
fileData = JSON.parse(value);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
fileData = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (fileData && typeof fileData === 'object' && fileData.imageData) {
|
|
27
|
+
setPreview(fileData.imageData);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setPreview(null);
|
|
31
|
+
if (fileInputRef.current)
|
|
32
|
+
fileInputRef.current.value = '';
|
|
33
|
+
}
|
|
17
34
|
}
|
|
18
35
|
else {
|
|
19
36
|
setPreview(null);
|
|
20
|
-
if (fileInputRef.current)
|
|
37
|
+
if (fileInputRef.current)
|
|
21
38
|
fileInputRef.current.value = '';
|
|
22
|
-
}
|
|
23
39
|
}
|
|
24
40
|
}, [value]);
|
|
25
41
|
// Nettoyer le stream quand le composant est démonté
|
|
@@ -53,14 +69,17 @@ const PhotoCapture = ({ variable, value, onChange, error, disabled }) => {
|
|
|
53
69
|
}
|
|
54
70
|
// Convertir en base64
|
|
55
71
|
const imageData = await VariableValueConverter.fileToBase64(file);
|
|
56
|
-
|
|
72
|
+
// Sérialiser en JSON string avant d'émettre (comme DatePicker le fait pour les dates)
|
|
73
|
+
const fileData = {
|
|
57
74
|
imageData,
|
|
58
75
|
name: file.name,
|
|
59
76
|
size: file.size,
|
|
60
77
|
type: file.type,
|
|
61
78
|
timestamp: new Date(),
|
|
62
79
|
source: captureMode === 'camera' ? 'camera' : 'upload'
|
|
63
|
-
}
|
|
80
|
+
};
|
|
81
|
+
const serializedValue = VariableValueConverter.serialize(fileData, variable.typeCode);
|
|
82
|
+
onChange(serializedValue);
|
|
64
83
|
};
|
|
65
84
|
const startCamera = async () => {
|
|
66
85
|
if (disabled)
|
package/package.json
CHANGED