@monkvision/inspection-capture-web 5.0.0 → 5.0.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/lib/PhotoCapture/PhotoCapture.js +17 -24
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.d.ts +10 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.js +2 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.d.ts +9 -5
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.js +2 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.d.ts +1 -1
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.js +2 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.d.ts +12 -2
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.js +17 -9
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.styles.js +23 -7
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/hooks.d.ts +818 -0
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/hooks.js +26 -0
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.d.ts +9 -1
- package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.js +1 -1
- package/lib/PhotoCapture/hooks/index.d.ts +2 -0
- package/lib/PhotoCapture/hooks/index.js +2 -0
- package/lib/PhotoCapture/hooks/useInspectionComplete.d.ts +38 -0
- package/lib/PhotoCapture/hooks/useInspectionComplete.js +41 -0
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightGuidelines.d.ts +28 -0
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightGuidelines.js +42 -0
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.d.ts +11 -3
- package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.js +29 -16
- package/lib/PhotoCapture/hooks/usePhotoCaptureTutorial.d.ts +16 -6
- package/lib/components/HUDOverlay/HUDOverlay.styles.js +1 -1
- package/lib/hooks/useStartTasksOnComplete.js +5 -2
- package/lib/translations/de.json +3 -1
- package/lib/translations/en.json +3 -1
- package/lib/translations/fr.json +3 -1
- package/lib/translations/nl.json +3 -1
- package/package.json +15 -15
|
@@ -28,7 +28,6 @@ var analytics_1 = require("@monkvision/analytics");
|
|
|
28
28
|
var camera_web_1 = require("@monkvision/camera-web");
|
|
29
29
|
var common_1 = require("@monkvision/common");
|
|
30
30
|
var common_ui_web_1 = require("@monkvision/common-ui-web");
|
|
31
|
-
var monitoring_1 = require("@monkvision/monitoring");
|
|
32
31
|
var types_1 = require("@monkvision/types");
|
|
33
32
|
var react_1 = require("react");
|
|
34
33
|
var react_i18next_1 = require("react-i18next");
|
|
@@ -43,7 +42,7 @@ var PhotoCaptureScreen;
|
|
|
43
42
|
})(PhotoCaptureScreen || (PhotoCaptureScreen = {}));
|
|
44
43
|
// No ts-doc for this component : the component exported is PhotoCaptureHOC
|
|
45
44
|
function PhotoCapture(_a) {
|
|
46
|
-
var sights = _a.sights, inspectionId = _a.inspectionId, apiConfig = _a.apiConfig, additionalTasks = _a.additionalTasks, tasksBySight = _a.tasksBySight, _b = _a.startTasksOnComplete, startTasksOnComplete = _b === void 0 ? true : _b, onClose = _a.onClose, onComplete = _a.onComplete, onPictureTaken = _a.onPictureTaken, _c = _a.maxUploadDurationWarning, maxUploadDurationWarning = _c === void 0 ? 15000 : _c, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.enableCompliance, enableCompliance = _e === void 0 ? true : _e, enableCompliancePerSight = _a.enableCompliancePerSight, complianceIssues = _a.complianceIssues, complianceIssuesPerSight = _a.complianceIssuesPerSight, customComplianceThresholds = _a.customComplianceThresholds, customComplianceThresholdsPerSight = _a.customComplianceThresholdsPerSight, _f = _a.useLiveCompliance, useLiveCompliance = _f === void 0 ? false : _f, _g = _a.allowSkipRetake, allowSkipRetake = _g === void 0 ? false : _g, _h = _a.addDamage, addDamage = _h === void 0 ? types_1.AddDamage.PART_SELECT : _h, sightGuidelines = _a.sightGuidelines, _j = _a.enableTutorial, enableTutorial = _j === void 0 ? types_1.PhotoCaptureTutorialOption.FIRST_TIME_ONLY : _j, _k = _a.allowSkipTutorial, allowSkipTutorial = _k === void 0 ? true : _k, _l = _a.enableSightTutorial, enableSightTutorial = _l === void 0 ? true : _l, _m = _a.enableSightGuidelines, enableSightGuidelines = _m === void 0 ?
|
|
45
|
+
var sights = _a.sights, inspectionId = _a.inspectionId, apiConfig = _a.apiConfig, additionalTasks = _a.additionalTasks, tasksBySight = _a.tasksBySight, _b = _a.startTasksOnComplete, startTasksOnComplete = _b === void 0 ? true : _b, onClose = _a.onClose, onComplete = _a.onComplete, onPictureTaken = _a.onPictureTaken, _c = _a.maxUploadDurationWarning, maxUploadDurationWarning = _c === void 0 ? 15000 : _c, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.enableCompliance, enableCompliance = _e === void 0 ? true : _e, enableCompliancePerSight = _a.enableCompliancePerSight, complianceIssues = _a.complianceIssues, complianceIssuesPerSight = _a.complianceIssuesPerSight, customComplianceThresholds = _a.customComplianceThresholds, customComplianceThresholdsPerSight = _a.customComplianceThresholdsPerSight, _f = _a.useLiveCompliance, useLiveCompliance = _f === void 0 ? false : _f, _g = _a.allowSkipRetake, allowSkipRetake = _g === void 0 ? false : _g, _h = _a.addDamage, addDamage = _h === void 0 ? types_1.AddDamage.PART_SELECT : _h, sightGuidelines = _a.sightGuidelines, _j = _a.enableTutorial, enableTutorial = _j === void 0 ? types_1.PhotoCaptureTutorialOption.FIRST_TIME_ONLY : _j, _k = _a.allowSkipTutorial, allowSkipTutorial = _k === void 0 ? true : _k, _l = _a.enableSightTutorial, enableSightTutorial = _l === void 0 ? true : _l, _m = _a.enableSightGuidelines, enableSightGuidelines = _m === void 0 ? types_1.PhotoCaptureSightGuidelinesOption.EPHEMERAL : _m, _o = _a.useAdaptiveImageQuality, useAdaptiveImageQuality = _o === void 0 ? true : _o, lang = _a.lang, enforceOrientation = _a.enforceOrientation, validateButtonLabel = _a.validateButtonLabel, _p = _a.vehicleType, vehicleType = _p === void 0 ? types_1.VehicleType.SEDAN : _p, initialCameraConfig = __rest(_a, ["sights", "inspectionId", "apiConfig", "additionalTasks", "tasksBySight", "startTasksOnComplete", "onClose", "onComplete", "onPictureTaken", "maxUploadDurationWarning", "showCloseButton", "enableCompliance", "enableCompliancePerSight", "complianceIssues", "complianceIssuesPerSight", "customComplianceThresholds", "customComplianceThresholdsPerSight", "useLiveCompliance", "allowSkipRetake", "addDamage", "sightGuidelines", "enableTutorial", "allowSkipTutorial", "enableSightTutorial", "enableSightGuidelines", "useAdaptiveImageQuality", "lang", "enforceOrientation", "validateButtonLabel", "vehicleType"]);
|
|
47
46
|
(0, common_1.useI18nSync)(lang);
|
|
48
47
|
var complianceOptions = (0, common_1.useObjectMemo)({
|
|
49
48
|
enableCompliance: enableCompliance,
|
|
@@ -55,7 +54,6 @@ function PhotoCapture(_a) {
|
|
|
55
54
|
customComplianceThresholdsPerSight: customComplianceThresholdsPerSight,
|
|
56
55
|
});
|
|
57
56
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
58
|
-
var monitoring = (0, monitoring_1.useMonitoring)();
|
|
59
57
|
var _q = (0, react_1.useState)(PhotoCaptureScreen.CAMERA), currentScreen = _q[0], setCurrentScreen = _q[1];
|
|
60
58
|
var analytics = (0, analytics_1.useAnalytics)();
|
|
61
59
|
var loading = (0, common_1.useLoadingState)();
|
|
@@ -94,13 +92,18 @@ function PhotoCapture(_a) {
|
|
|
94
92
|
tasksBySight: tasksBySight,
|
|
95
93
|
complianceOptions: complianceOptions,
|
|
96
94
|
setIsInitialInspectionFetched: setIsInitialInspectionFetched,
|
|
95
|
+
startTasksOnComplete: startTasksOnComplete,
|
|
96
|
+
onComplete: onComplete,
|
|
97
97
|
});
|
|
98
98
|
var _s = (0, hooks_2.usePhotoCaptureTutorial)({
|
|
99
99
|
enableTutorial: enableTutorial,
|
|
100
100
|
enableSightGuidelines: enableSightGuidelines,
|
|
101
101
|
enableSightTutorial: enableSightTutorial,
|
|
102
102
|
}), currentTutorialStep = _s.currentTutorialStep, goToNextTutorialStep = _s.goToNextTutorialStep, closeTutorial = _s.closeTutorial;
|
|
103
|
-
var _t = (0,
|
|
103
|
+
var _t = (0, hooks_2.usePhotoCaptureSightGuidelines)({
|
|
104
|
+
enableSightGuidelines: enableSightGuidelines,
|
|
105
|
+
}), showSightGuidelines = _t.showSightGuidelines, handleDisableSightGuidelines = _t.handleDisableSightGuidelines;
|
|
106
|
+
var _u = (0, hooks_1.useBadConnectionWarning)({ maxUploadDurationWarning: maxUploadDurationWarning }), isBadConnectionWarningDialogDisplayed = _u.isBadConnectionWarningDialogDisplayed, closeBadConnectionWarningDialog = _u.closeBadConnectionWarningDialog, badConnectionWarningUploadEventHandlers = _u.uploadEventHandlers;
|
|
104
107
|
var uploadQueue = (0, hooks_1.useUploadQueue)({
|
|
105
108
|
inspectionId: inspectionId,
|
|
106
109
|
apiConfig: apiConfig,
|
|
@@ -116,6 +119,13 @@ function PhotoCapture(_a) {
|
|
|
116
119
|
tasksBySight: tasksBySight,
|
|
117
120
|
onPictureTaken: onPictureTaken,
|
|
118
121
|
});
|
|
122
|
+
var handleInspectionCompleted = (0, hooks_2.useInspectionComplete)({
|
|
123
|
+
startTasks: startTasks,
|
|
124
|
+
sightState: sightState,
|
|
125
|
+
loading: loading,
|
|
126
|
+
startTasksOnComplete: startTasksOnComplete,
|
|
127
|
+
onComplete: onComplete,
|
|
128
|
+
}).handleInspectionCompleted;
|
|
119
129
|
var handleGalleryBack = function () { return setCurrentScreen(PhotoCaptureScreen.CAMERA); };
|
|
120
130
|
var handleNavigateToCapture = function (options) {
|
|
121
131
|
if (options.reason === common_ui_web_1.NavigateToCaptureReason.ADD_DAMAGE) {
|
|
@@ -133,24 +143,6 @@ function PhotoCapture(_a) {
|
|
|
133
143
|
}
|
|
134
144
|
setCurrentScreen(PhotoCaptureScreen.CAMERA);
|
|
135
145
|
};
|
|
136
|
-
var allowRedirect = (0, common_1.usePreventExit)(sightState.sightsTaken.length !== 0).allowRedirect;
|
|
137
|
-
var handleGalleryValidate = function () {
|
|
138
|
-
startTasks()
|
|
139
|
-
.then(function () {
|
|
140
|
-
analytics.trackEvent('Capture Completed');
|
|
141
|
-
analytics.setUserProperties({
|
|
142
|
-
captureCompleted: true,
|
|
143
|
-
sightSelected: 'inspection-completed',
|
|
144
|
-
});
|
|
145
|
-
allowRedirect();
|
|
146
|
-
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
147
|
-
sightState.setIsInspectionCompleted(true);
|
|
148
|
-
})
|
|
149
|
-
.catch(function (err) {
|
|
150
|
-
loading.onError(err);
|
|
151
|
-
monitoring.handleError(err);
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
146
|
var hudProps = {
|
|
155
147
|
sights: sights,
|
|
156
148
|
selectedSight: sightState.selectedSight,
|
|
@@ -173,14 +165,15 @@ function PhotoCapture(_a) {
|
|
|
173
165
|
addDamage: addDamage,
|
|
174
166
|
onValidateVehicleParts: addDamageHandle.handleValidateVehicleParts,
|
|
175
167
|
sightGuidelines: sightGuidelines,
|
|
176
|
-
|
|
168
|
+
showSightGuidelines: showSightGuidelines,
|
|
177
169
|
currentTutorialStep: currentTutorialStep,
|
|
178
170
|
onNextTutorialStep: goToNextTutorialStep,
|
|
179
171
|
onCloseTutorial: closeTutorial,
|
|
172
|
+
onDisableSightGuidelines: handleDisableSightGuidelines,
|
|
180
173
|
allowSkipTutorial: allowSkipTutorial,
|
|
181
174
|
enforceOrientation: enforceOrientation,
|
|
182
175
|
vehicleType: vehicleType,
|
|
183
176
|
};
|
|
184
|
-
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCapture_styles_1.styles['container'] }, { children: [currentScreen === PhotoCaptureScreen.CAMERA && ((0, jsx_runtime_1.jsx)(camera_web_1.Camera, __assign({ HUDComponent: PhotoCaptureHUD_1.PhotoCaptureHUD, onPictureTaken: handlePictureTaken, hudProps: hudProps }, adaptiveCameraConfig))), currentScreen === PhotoCaptureScreen.GALLERY && ((0, jsx_runtime_1.jsx)(common_ui_web_1.InspectionGallery, __assign({ inspectionId: inspectionId, apiConfig: apiConfig, captureMode: true, lang: lang, showBackButton: true, sights: sights, allowSkipRetake: allowSkipRetake, onBack: handleGalleryBack, onNavigateToCapture: handleNavigateToCapture, onValidate:
|
|
177
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCapture_styles_1.styles['container'] }, { children: [currentScreen === PhotoCaptureScreen.CAMERA && ((0, jsx_runtime_1.jsx)(camera_web_1.Camera, __assign({ HUDComponent: PhotoCaptureHUD_1.PhotoCaptureHUD, onPictureTaken: handlePictureTaken, hudProps: hudProps }, adaptiveCameraConfig))), currentScreen === PhotoCaptureScreen.GALLERY && ((0, jsx_runtime_1.jsx)(common_ui_web_1.InspectionGallery, __assign({ inspectionId: inspectionId, apiConfig: apiConfig, captureMode: true, lang: lang, showBackButton: true, sights: sights, allowSkipRetake: allowSkipRetake, onBack: handleGalleryBack, onNavigateToCapture: handleNavigateToCapture, onValidate: handleInspectionCompleted, addDamage: addDamage, validateButtonLabel: validateButtonLabel, isInspectionCompleted: sightState.isInspectionCompleted }, complianceOptions))), (0, jsx_runtime_1.jsx)(common_ui_web_1.BackdropDialog, { show: isBadConnectionWarningDialogDisplayed, showCancelButton: false, dialogIcon: 'warning-outline', dialogIconPrimaryColor: 'caution-base', message: t('photo.badConnectionWarning.message'), confirmLabel: t('photo.badConnectionWarning.confirm'), onConfirm: closeBadConnectionWarningDialog })] })));
|
|
185
178
|
}
|
|
186
179
|
exports.PhotoCapture = PhotoCapture;
|
|
@@ -7,7 +7,7 @@ import { CaptureMode } from '../../types';
|
|
|
7
7
|
/**
|
|
8
8
|
* Props of the PhotoCaptureHUD component.
|
|
9
9
|
*/
|
|
10
|
-
export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureAppConfig, '
|
|
10
|
+
export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage' | 'showCloseButton' | 'allowSkipTutorial' | 'enforceOrientation'> {
|
|
11
11
|
/**
|
|
12
12
|
* The inspection ID.
|
|
13
13
|
*/
|
|
@@ -84,6 +84,10 @@ export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureA
|
|
|
84
84
|
* Callback called when the user clicks on the "Validate" button of the Add Damage mode.
|
|
85
85
|
*/
|
|
86
86
|
onValidateVehicleParts: () => void;
|
|
87
|
+
/**
|
|
88
|
+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
|
|
89
|
+
*/
|
|
90
|
+
onDisableSightGuidelines: () => void;
|
|
87
91
|
/**
|
|
88
92
|
* Callback called when the user clicks on the close button. If this callback is not provided, the close button is not
|
|
89
93
|
* displayed.
|
|
@@ -97,10 +101,14 @@ export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureA
|
|
|
97
101
|
* The vehicle type of the inspection.
|
|
98
102
|
*/
|
|
99
103
|
vehicleType: VehicleType;
|
|
104
|
+
/**
|
|
105
|
+
* Boolean indicating whether the sight guidelines should be displayed.
|
|
106
|
+
*/
|
|
107
|
+
showSightGuidelines: boolean;
|
|
100
108
|
}
|
|
101
109
|
/**
|
|
102
110
|
* This component implements the Camera HUD (head-up display) displayed in the PhotoCapture component over the Camera
|
|
103
111
|
* preview. It implements elements such as buttons to interact with the camera, PhotoCapture indicators, error messages,
|
|
104
112
|
* loaders etc.
|
|
105
113
|
*/
|
|
106
|
-
export declare function PhotoCaptureHUD({ inspectionId, sights, selectedSight, sightsTaken, lastPictureTakenUri, mode, vehicleParts, onSelectSight, onRetakeSight, onAddDamage, onAddDamagePartsSelected, onValidateVehicleParts, onCancelAddDamage, onOpenGallery, onRetry, onClose, showCloseButton, loading, handle, cameraPreview, images, addDamage, sightGuidelines,
|
|
114
|
+
export declare function PhotoCaptureHUD({ inspectionId, sights, selectedSight, sightsTaken, lastPictureTakenUri, mode, vehicleParts, onSelectSight, onRetakeSight, onAddDamage, onAddDamagePartsSelected, onValidateVehicleParts, onCancelAddDamage, onOpenGallery, onRetry, onClose, showCloseButton, loading, handle, cameraPreview, images, addDamage, sightGuidelines, showSightGuidelines, currentTutorialStep, allowSkipTutorial, onNextTutorialStep, onCloseTutorial, enforceOrientation, vehicleType, onDisableSightGuidelines, }: PhotoCaptureHUDProps): JSX.Element;
|
|
@@ -30,7 +30,7 @@ var components_1 = require("../../components");
|
|
|
30
30
|
*/
|
|
31
31
|
function PhotoCaptureHUD(_a) {
|
|
32
32
|
var _b;
|
|
33
|
-
var inspectionId = _a.inspectionId, sights = _a.sights, selectedSight = _a.selectedSight, sightsTaken = _a.sightsTaken, lastPictureTakenUri = _a.lastPictureTakenUri, mode = _a.mode, vehicleParts = _a.vehicleParts, onSelectSight = _a.onSelectSight, onRetakeSight = _a.onRetakeSight, onAddDamage = _a.onAddDamage, onAddDamagePartsSelected = _a.onAddDamagePartsSelected, onValidateVehicleParts = _a.onValidateVehicleParts, onCancelAddDamage = _a.onCancelAddDamage, onOpenGallery = _a.onOpenGallery, onRetry = _a.onRetry, onClose = _a.onClose, showCloseButton = _a.showCloseButton, loading = _a.loading, handle = _a.handle, cameraPreview = _a.cameraPreview, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines,
|
|
33
|
+
var inspectionId = _a.inspectionId, sights = _a.sights, selectedSight = _a.selectedSight, sightsTaken = _a.sightsTaken, lastPictureTakenUri = _a.lastPictureTakenUri, mode = _a.mode, vehicleParts = _a.vehicleParts, onSelectSight = _a.onSelectSight, onRetakeSight = _a.onRetakeSight, onAddDamage = _a.onAddDamage, onAddDamagePartsSelected = _a.onAddDamagePartsSelected, onValidateVehicleParts = _a.onValidateVehicleParts, onCancelAddDamage = _a.onCancelAddDamage, onOpenGallery = _a.onOpenGallery, onRetry = _a.onRetry, onClose = _a.onClose, showCloseButton = _a.showCloseButton, loading = _a.loading, handle = _a.handle, cameraPreview = _a.cameraPreview, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines, showSightGuidelines = _a.showSightGuidelines, currentTutorialStep = _a.currentTutorialStep, allowSkipTutorial = _a.allowSkipTutorial, onNextTutorialStep = _a.onNextTutorialStep, onCloseTutorial = _a.onCloseTutorial, enforceOrientation = _a.enforceOrientation, vehicleType = _a.vehicleType, onDisableSightGuidelines = _a.onDisableSightGuidelines;
|
|
34
34
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
35
35
|
var _c = (0, react_1.useState)(false), showCloseModal = _c[0], setShowCloseModal = _c[1];
|
|
36
36
|
var style = (0, hooks_1.usePhotoCaptureHUDStyle)();
|
|
@@ -45,6 +45,6 @@ function PhotoCaptureHUD(_a) {
|
|
|
45
45
|
trackEvent('Capture Closed');
|
|
46
46
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
47
47
|
};
|
|
48
|
-
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.container }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.previewContainer, "data-testid": 'camera-preview' }, { children: [cameraPreview, (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElements_1.PhotoCaptureHUDElements, { selectedSight: selectedSight, sights: sights, sightsTaken: sightsTaken, mode: mode, vehicleParts: vehicleParts, onAddDamage: onAddDamage, onCancelAddDamage: onCancelAddDamage, onAddDamagePartsSelected: onAddDamagePartsSelected, onSelectSight: onSelectSight, onRetakeSight: onRetakeSight, onValidateVehicleParts: onValidateVehicleParts,
|
|
48
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.container }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.previewContainer, "data-testid": 'camera-preview' }, { children: [cameraPreview, (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElements_1.PhotoCaptureHUDElements, { selectedSight: selectedSight, sights: sights, sightsTaken: sightsTaken, mode: mode, vehicleParts: vehicleParts, onAddDamage: onAddDamage, onCancelAddDamage: onCancelAddDamage, onAddDamagePartsSelected: onAddDamagePartsSelected, onSelectSight: onSelectSight, onRetakeSight: onRetakeSight, onValidateVehicleParts: onValidateVehicleParts, error: (_b = loading.error) !== null && _b !== void 0 ? _b : handle.error, previewDimensions: handle.previewDimensions, images: images, addDamage: addDamage, sightGuidelines: sightGuidelines, showSightGuidelines: showSightGuidelines, tutorialStep: currentTutorialStep, vehicleType: vehicleType, onDisableSightGuidelines: onDisableSightGuidelines })] })), mode !== types_2.CaptureMode.ADD_DAMAGE_PART_SELECT && ((0, jsx_runtime_1.jsx)(components_1.HUDButtons, { onOpenGallery: onOpenGallery, onTakePicture: handle === null || handle === void 0 ? void 0 : handle.takePicture, onClose: function () { return setShowCloseModal(true); }, galleryPreview: lastPictureTakenUri !== null && lastPictureTakenUri !== void 0 ? lastPictureTakenUri : undefined, closeDisabled: !!loading.error || !!handle.error, galleryDisabled: !!loading.error || !!handle.error, takePictureDisabled: !!loading.error || !!handle.error || handle.isLoading || loading.isLoading, showCloseButton: showCloseButton, showGalleryBadge: retakeCount > 0, retakeCount: retakeCount })), (0, jsx_runtime_1.jsx)(components_1.HUDOverlay, { inspectionId: inspectionId, handle: handle, isCaptureLoading: loading.isLoading, captureError: loading.error, onRetry: onRetry }), (0, jsx_runtime_1.jsx)(common_ui_web_1.BackdropDialog, { show: showCloseModal, message: t('photo.hud.closeConfirm.message'), cancelLabel: t('photo.hud.closeConfirm.cancel'), confirmLabel: t('photo.hud.closeConfirm.confirm'), onCancel: function () { return setShowCloseModal(false); }, onConfirm: handleCloseConfirm }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDTutorial_1.PhotoCaptureHUDTutorial, { currentTutorialStep: handle.error || loading.error ? null : currentTutorialStep, onNextTutorialStep: onNextTutorialStep, onCloseTutorial: onCloseTutorial, allowSkipTutorial: allowSkipTutorial, sightId: selectedSight.id, sightGuidelines: sightGuidelines, addDamage: addDamage }), (0, jsx_runtime_1.jsx)(components_1.OrientationEnforcer, { orientation: enforceOrientation })] })));
|
|
49
49
|
}
|
|
50
50
|
exports.PhotoCaptureHUD = PhotoCaptureHUD;
|
package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CaptureMode } from '../../../types';
|
|
|
5
5
|
/**
|
|
6
6
|
* Props of the PhotoCaptureHUDElements component.
|
|
7
7
|
*/
|
|
8
|
-
export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig, '
|
|
8
|
+
export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage'> {
|
|
9
9
|
/**
|
|
10
10
|
* The currently selected sight in the PhotoCapture component : the sight that the user needs to capture.
|
|
11
11
|
*/
|
|
@@ -55,13 +55,13 @@ export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig
|
|
|
55
55
|
*/
|
|
56
56
|
onValidateVehicleParts: () => void;
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
onDisableSightGuidelines?: () => void;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* The effective pixel dimensions of the Camera video stream on the screen.
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
previewDimensions: PixelDimensions | null;
|
|
65
65
|
/**
|
|
66
66
|
* The error that occurred in the PhotoCapture component. Set this value to `null` if there is no error.
|
|
67
67
|
*/
|
|
@@ -74,6 +74,10 @@ export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig
|
|
|
74
74
|
* The vehicle type of the inspection.
|
|
75
75
|
*/
|
|
76
76
|
vehicleType: VehicleType;
|
|
77
|
+
/**
|
|
78
|
+
* Boolean indicating whether the sight guidelines should be displayed.
|
|
79
|
+
*/
|
|
80
|
+
showSightGuidelines?: boolean;
|
|
77
81
|
}
|
|
78
82
|
/**
|
|
79
83
|
* Component implementing an HUD displayed on top of the Camera preview during the PhotoCapture process.
|
|
@@ -9,11 +9,11 @@ var types_1 = require("../../../types");
|
|
|
9
9
|
* Component implementing an HUD displayed on top of the Camera preview during the PhotoCapture process.
|
|
10
10
|
*/
|
|
11
11
|
function PhotoCaptureHUDElements(params) {
|
|
12
|
-
if (params.
|
|
12
|
+
if (params.error) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
if (params.mode === types_1.CaptureMode.SIGHT) {
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.PhotoCaptureHUDElementsSight, { sights: params.sights, selectedSight: params.selectedSight, onSelectedSight: params.onSelectSight, onRetakeSight: params.onRetakeSight, sightsTaken: params.sightsTaken, onAddDamage: params.onAddDamage, previewDimensions: params.previewDimensions, images: params.images, addDamage: params.addDamage, sightGuidelines: params.sightGuidelines,
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.PhotoCaptureHUDElementsSight, { sights: params.sights, selectedSight: params.selectedSight, onSelectedSight: params.onSelectSight, onRetakeSight: params.onRetakeSight, sightsTaken: params.sightsTaken, onAddDamage: params.onAddDamage, previewDimensions: params.previewDimensions, images: params.images, addDamage: params.addDamage, sightGuidelines: params.sightGuidelines, showSightGuidelines: params.showSightGuidelines, tutorialStep: params.tutorialStep, onDisableSightGuidelines: params.onDisableSightGuidelines }));
|
|
17
17
|
}
|
|
18
18
|
if (params.mode === types_1.CaptureMode.ADD_DAMAGE_1ST_SHOT) {
|
|
19
19
|
return (0, jsx_runtime_1.jsx)(components_1.ZoomOutShot, { onCancel: params.onCancelAddDamage });
|
|
@@ -4,4 +4,4 @@ import { PhotoCaptureHUDElementsSightProps } from './hooks';
|
|
|
4
4
|
* Component implementing an HUD displayed on top of the Camera preview during the PhotoCapture process when the current
|
|
5
5
|
* mode is SIGHT.
|
|
6
6
|
*/
|
|
7
|
-
export declare function PhotoCaptureHUDElementsSight({ sights, selectedSight, onSelectedSight, onRetakeSight, onAddDamage, sightsTaken, previewDimensions, images, addDamage, sightGuidelines,
|
|
7
|
+
export declare function PhotoCaptureHUDElementsSight({ sights, selectedSight, onSelectedSight, onRetakeSight, onAddDamage, onDisableSightGuidelines, sightsTaken, previewDimensions, images, addDamage, sightGuidelines, showSightGuidelines, tutorialStep, }: PhotoCaptureHUDElementsSightProps): JSX.Element;
|
|
@@ -27,9 +27,9 @@ var types_1 = require("../../../types");
|
|
|
27
27
|
* mode is SIGHT.
|
|
28
28
|
*/
|
|
29
29
|
function PhotoCaptureHUDElementsSight(_a) {
|
|
30
|
-
var sights = _a.sights, selectedSight = _a.selectedSight, _b = _a.onSelectedSight, onSelectedSight = _b === void 0 ? function () { } : _b, _c = _a.onRetakeSight, onRetakeSight = _c === void 0 ? function () { } : _c, _d = _a.onAddDamage, onAddDamage = _d === void 0 ? function () { } : _d, sightsTaken = _a.sightsTaken, previewDimensions = _a.previewDimensions, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines,
|
|
30
|
+
var sights = _a.sights, selectedSight = _a.selectedSight, _b = _a.onSelectedSight, onSelectedSight = _b === void 0 ? function () { } : _b, _c = _a.onRetakeSight, onRetakeSight = _c === void 0 ? function () { } : _c, _d = _a.onAddDamage, onAddDamage = _d === void 0 ? function () { } : _d, _e = _a.onDisableSightGuidelines, onDisableSightGuidelines = _e === void 0 ? function () { } : _e, sightsTaken = _a.sightsTaken, previewDimensions = _a.previewDimensions, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines, showSightGuidelines = _a.showSightGuidelines, tutorialStep = _a.tutorialStep;
|
|
31
31
|
var style = (0, hooks_1.usePhotoCaptureHUDSightPreviewStyle)({ previewDimensions: previewDimensions });
|
|
32
32
|
var showSight = previewDimensions && (!tutorialStep || tutorialStep === hooks_2.TutorialSteps.SIGHT);
|
|
33
|
-
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDElementsSight_styles_1.styles['container'] }, { children: [showSight && (0, jsx_runtime_1.jsx)(common_ui_web_1.SightOverlay, { style: style.overlay, sight: selectedSight }), !tutorialStep && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.top }, { children: [(0, jsx_runtime_1.jsx)(SightGuideline_1.SightGuideline, { sightId: selectedSight.id, sightGuidelines: sightGuidelines,
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDElementsSight_styles_1.styles['container'] }, { children: [showSight && (0, jsx_runtime_1.jsx)(common_ui_web_1.SightOverlay, { style: style.overlay, sight: selectedSight }), !tutorialStep && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.top }, { children: [(0, jsx_runtime_1.jsx)(SightGuideline_1.SightGuideline, { sightId: selectedSight.id, sightGuidelines: sightGuidelines, disabled: !showSightGuidelines, addDamage: addDamage, onDisableSightGuidelines: onDisableSightGuidelines }), (0, jsx_runtime_1.jsx)(AddDamageButton_1.AddDamageButton, { onAddDamage: onAddDamage, addDamage: addDamage })] })), (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.bottom }, { children: [(0, jsx_runtime_1.jsx)(components_1.Counter, { mode: types_1.CaptureMode.SIGHT, totalSights: sights.length, sightsTaken: sightsTaken.length }), (0, jsx_runtime_1.jsx)(SightSlider_1.SightSlider, { sights: sights, selectedSight: selectedSight, sightsTaken: sightsTaken, onSelectedSight: onSelectedSight, onRetakeSight: onRetakeSight, images: images })] }))] })))] })));
|
|
34
34
|
}
|
|
35
35
|
exports.PhotoCaptureHUDElementsSight = PhotoCaptureHUDElementsSight;
|
|
@@ -3,7 +3,7 @@ import { PhotoCaptureAppConfig } from '@monkvision/types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Props of the SightGuideline component.
|
|
5
5
|
*/
|
|
6
|
-
export interface SightGuidelineProps extends Pick<PhotoCaptureAppConfig, 'addDamage' | 'sightGuidelines'
|
|
6
|
+
export interface SightGuidelineProps extends Pick<PhotoCaptureAppConfig, 'addDamage' | 'sightGuidelines'> {
|
|
7
7
|
/**
|
|
8
8
|
* The id of the sight.
|
|
9
9
|
*/
|
|
@@ -14,8 +14,18 @@ export interface SightGuidelineProps extends Pick<PhotoCaptureAppConfig, 'addDam
|
|
|
14
14
|
* @default false
|
|
15
15
|
*/
|
|
16
16
|
enableDefaultMessage?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Boolean indicating if the sight guidelines are enabled.
|
|
19
|
+
*
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
|
|
25
|
+
*/
|
|
26
|
+
onDisableSightGuidelines?: () => void;
|
|
17
27
|
}
|
|
18
28
|
/**
|
|
19
29
|
* Custom button displaying the sight guideline.
|
|
20
30
|
*/
|
|
21
|
-
export declare function SightGuideline({ sightId, sightGuidelines,
|
|
31
|
+
export declare function SightGuideline({ sightId, sightGuidelines, addDamage, enableDefaultMessage, disabled, onDisableSightGuidelines, }: SightGuidelineProps): JSX.Element;
|
|
@@ -14,27 +14,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.SightGuideline = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var react_1 = require("react");
|
|
17
|
-
var common_ui_web_1 = require("@monkvision/common-ui-web");
|
|
18
|
-
var types_1 = require("@monkvision/types");
|
|
19
17
|
var react_i18next_1 = require("react-i18next");
|
|
20
18
|
var common_1 = require("@monkvision/common");
|
|
21
19
|
var SightGuideline_styles_1 = require("./SightGuideline.styles");
|
|
22
|
-
var hooks_1 = require("
|
|
20
|
+
var hooks_1 = require("./hooks");
|
|
23
21
|
/**
|
|
24
22
|
* Custom button displaying the sight guideline.
|
|
25
23
|
*/
|
|
26
24
|
function SightGuideline(_a) {
|
|
27
|
-
var sightId = _a.sightId, sightGuidelines = _a.sightGuidelines,
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var style =
|
|
25
|
+
var sightId = _a.sightId, sightGuidelines = _a.sightGuidelines, addDamage = _a.addDamage, _b = _a.enableDefaultMessage, enableDefaultMessage = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.onDisableSightGuidelines, onDisableSightGuidelines = _d === void 0 ? function () { } : _d;
|
|
26
|
+
var _e = (0, react_1.useState)(true), showGuideline = _e[0], setShowGuideline = _e[1];
|
|
27
|
+
var _f = (0, react_1.useState)(false), checked = _f[0], setChecked = _f[1];
|
|
28
|
+
var _g = (0, react_i18next_1.useTranslation)(), i18n = _g.i18n, t = _g.t;
|
|
29
|
+
var style = (0, hooks_1.useSightGuidelineStyle)({ addDamage: addDamage });
|
|
32
30
|
var guidelineFound = sightGuidelines === null || sightGuidelines === void 0 ? void 0 : sightGuidelines.find(function (value) { return value.sightIds.includes(sightId); });
|
|
33
31
|
var defaultMessage = enableDefaultMessage
|
|
34
32
|
? t('photo.hud.guidelines.defaultGuideline')
|
|
35
33
|
: undefined;
|
|
36
34
|
var guideline = guidelineFound ? guidelineFound[(0, common_1.getLanguage)(i18n.language)] : defaultMessage;
|
|
35
|
+
var handleShowSightGuidelines = function () {
|
|
36
|
+
if (checked) {
|
|
37
|
+
onDisableSightGuidelines();
|
|
38
|
+
}
|
|
39
|
+
setShowGuideline(false);
|
|
40
|
+
};
|
|
37
41
|
(0, react_1.useEffect)(function () { return setShowGuideline(true); }, [sightId]);
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)("div", __assign({ style: style }, { children:
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ style: style.container, "data-testid": 'container' }, { children: !disabled && showGuideline && guideline && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.guideline, "data-testid": 'guideline' }, { children: [guideline, (0, jsx_runtime_1.jsxs)("div", __assign({ style: SightGuideline_styles_1.styles['buttonContainer'] }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: SightGuideline_styles_1.styles['checkbox'], role: 'checkbox', "aria-checked": checked, tabIndex: 0, onClick: function () { return setChecked(!checked); }, onKeyDown: function (e) {
|
|
43
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
44
|
+
setChecked(!checked);
|
|
45
|
+
}
|
|
46
|
+
}, "data-testid": 'checkbox-container' }, { children: [(0, jsx_runtime_1.jsx)("input", { type: 'checkbox', checked: checked, onChange: function (e) { return e.stopPropagation(); } }), (0, jsx_runtime_1.jsx)("span", { children: t('photo.hud.guidelines.disable') })] })), (0, jsx_runtime_1.jsx)("button", __assign({ style: SightGuideline_styles_1.styles['button'], onClick: handleShowSightGuidelines, "data-testid": 'button' }, { children: t('photo.hud.guidelines.validate') }))] }))] }))) })));
|
|
39
47
|
}
|
|
40
48
|
exports.SightGuideline = SightGuideline;
|
|
@@ -15,13 +15,29 @@ exports.styles = {
|
|
|
15
15
|
width: "calc(98% - (".concat(HUDButtons_styles_1.PHOTO_CAPTURE_HUD_BUTTONS_BAR_WIDTH * 4, "px))"),
|
|
16
16
|
justifyContent: 'center',
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
guideline: {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
20
22
|
borderRadius: '12px',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
justifyContent: 'start',
|
|
24
|
+
padding: '10px',
|
|
25
|
+
gap: '8px',
|
|
26
|
+
letterSpacing: '0.15px',
|
|
27
|
+
fontSize: '14',
|
|
28
|
+
},
|
|
29
|
+
buttonContainer: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'space-between',
|
|
32
|
+
padding: '0px 10px 0px',
|
|
33
|
+
},
|
|
34
|
+
checkbox: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
cursor: 'pointer',
|
|
37
|
+
gap: '5px',
|
|
38
|
+
},
|
|
39
|
+
button: {
|
|
40
|
+
all: 'unset',
|
|
41
|
+
cursor: 'pointer',
|
|
26
42
|
},
|
|
27
43
|
};
|