@monkvision/inspection-capture-web 5.0.21 → 5.1.0

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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/lib/PhotoCapture/PhotoCapture.d.ts +2 -2
  3. package/lib/PhotoCapture/PhotoCapture.js +15 -6
  4. package/lib/PhotoCapture/PhotoCapture.styles.js +1 -1
  5. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.d.ts +10 -2
  6. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.js +3 -2
  7. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.d.ts +5 -1
  8. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.js +1 -1
  9. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.d.ts +1 -1
  10. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.js +7 -3
  11. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.styles.js +1 -0
  12. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.d.ts +5 -1
  13. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.d.ts +23 -0
  14. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.js +65 -0
  15. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.styles.d.ts +7308 -0
  16. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.styles.js +170 -0
  17. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/index.d.ts +1 -0
  18. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/index.js +5 -0
  19. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.d.ts +5 -1
  20. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.js +3 -2
  21. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.styles.js +9 -3
  22. package/lib/PhotoCapture/hooks/index.d.ts +1 -0
  23. package/lib/PhotoCapture/hooks/index.js +1 -0
  24. package/lib/PhotoCapture/hooks/useInspectionComplete.d.ts +5 -1
  25. package/lib/PhotoCapture/hooks/useInspectionComplete.js +64 -16
  26. package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.d.ts +3 -7
  27. package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.js +2 -2
  28. package/lib/PhotoCapture/hooks/usePhotoCaptureSightTutorial.d.ts +14 -0
  29. package/lib/PhotoCapture/hooks/usePhotoCaptureSightTutorial.js +16 -0
  30. package/lib/PhotoCapture/hooks/usePhotoCaptureTutorial.js +1 -1
  31. package/lib/components/SightTutorialButton/SightTutorialButton.d.ts +14 -0
  32. package/lib/components/SightTutorialButton/SightTutorialButton.js +36 -0
  33. package/lib/components/SightTutorialButton/SightTutorialButton.styles.d.ts +2 -0
  34. package/lib/components/SightTutorialButton/SightTutorialButton.styles.js +6 -0
  35. package/lib/components/SightTutorialButton/index.d.ts +1 -0
  36. package/lib/components/SightTutorialButton/index.js +5 -0
  37. package/lib/components/index.d.ts +1 -0
  38. package/lib/components/index.js +1 -0
  39. package/lib/hooks/index.d.ts +1 -0
  40. package/lib/hooks/index.js +1 -0
  41. package/lib/hooks/useCaptureDuration.d.ts +39 -0
  42. package/lib/hooks/useCaptureDuration.js +208 -0
  43. package/lib/hooks/useTracking.js +6 -0
  44. package/lib/translations/de.json +4 -0
  45. package/lib/translations/en.json +4 -0
  46. package/lib/translations/fr.json +4 -0
  47. package/lib/translations/nl.json +4 -0
  48. package/package.json +15 -15
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.usePhotoCaptureHUDSightTutorialStyles = exports.styles = void 0;
15
+ var common_1 = require("@monkvision/common");
16
+ var react_1 = require("react");
17
+ var BORDER_WIDTH = 2;
18
+ exports.styles = {
19
+ container: {
20
+ width: '100%',
21
+ height: '100%',
22
+ position: 'fixed',
23
+ inset: 0,
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ zIndex: 10,
27
+ transition: 'opacity 0.3s ease-out, visibility 0.3s ease-out',
28
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
29
+ backdropFilter: 'blur(10px)',
30
+ opacity: 0,
31
+ visibility: 'hidden',
32
+ pointerEvents: 'none',
33
+ },
34
+ containerVisible: {
35
+ opacity: 1,
36
+ visibility: 'visible',
37
+ pointerEvents: 'auto',
38
+ },
39
+ iconsContainer: {
40
+ display: 'flex',
41
+ flexDirection: 'column',
42
+ justifyContent: 'space-around',
43
+ alignItems: 'center',
44
+ height: '100%',
45
+ width: '20%',
46
+ },
47
+ sightIcon: { width: '85px' },
48
+ tutorialContainer: {
49
+ position: 'absolute',
50
+ width: '60%',
51
+ height: '80%',
52
+ borderRadius: '9px',
53
+ transform: 'translate(-50%, -50%)',
54
+ top: '50%',
55
+ left: '50%',
56
+ display: 'flex',
57
+ flexDirection: 'column',
58
+ alignItems: 'center',
59
+ },
60
+ classicTutorialContainer: {
61
+ position: 'absolute',
62
+ width: '60%',
63
+ height: '80%',
64
+ transform: 'translate(-50%, -50%)',
65
+ top: '50%',
66
+ left: '50%',
67
+ display: 'flex',
68
+ flexDirection: 'column',
69
+ alignItems: 'center',
70
+ overflow: 'scroll',
71
+ },
72
+ modalContainer: {
73
+ display: 'flex',
74
+ flexDirection: 'column',
75
+ alignItems: 'center',
76
+ justifyContent: 'center',
77
+ },
78
+ titleContainer: {
79
+ display: 'flex',
80
+ width: '100%',
81
+ justifyContent: 'space-between',
82
+ alignItems: 'center',
83
+ height: '50px',
84
+ },
85
+ classicTitleContainer: {
86
+ display: 'flex',
87
+ width: '100%',
88
+ justifyContent: 'space-between',
89
+ alignItems: 'center',
90
+ height: '10%',
91
+ },
92
+ classicTitle: {
93
+ fontSize: '18px',
94
+ fontWeight: 700,
95
+ },
96
+ guidelineContainer: {
97
+ height: '40%',
98
+ overflow: 'auto',
99
+ display: 'flex',
100
+ flexDirection: 'column',
101
+ padding: '0 30px',
102
+ },
103
+ guideline: {
104
+ margin: 'auto',
105
+ textAlign: 'center',
106
+ whiteSpace: 'pre-line',
107
+ lineHeight: '24px',
108
+ },
109
+ classicGuidelineContainer: {
110
+ height: '40%',
111
+ overflow: 'auto',
112
+ display: 'flex',
113
+ flexDirection: 'column',
114
+ padding: '0 30px',
115
+ },
116
+ classicGuideline: {
117
+ margin: 'auto',
118
+ textAlign: 'center',
119
+ whiteSpace: 'pre-line',
120
+ lineHeight: '24px',
121
+ },
122
+ icon: { height: '33%', display: 'flex', justifyContent: 'center', alignItems: 'center' },
123
+ closeButton: {
124
+ padding: '0px 20px',
125
+ height: '100%',
126
+ borderRadius: 0,
127
+ },
128
+ closeButtonFiller: { visibility: 'hidden', padding: '0px 20px', height: '100%', borderRadius: 0 },
129
+ imageContainer: {
130
+ height: '60%',
131
+ width: '100%',
132
+ display: 'flex',
133
+ justifyContent: 'center',
134
+ alignItems: 'center',
135
+ },
136
+ classicImageContainer: {
137
+ height: '50%',
138
+ width: '100%',
139
+ display: 'flex',
140
+ justifyContent: 'center',
141
+ alignItems: 'center',
142
+ },
143
+ image: {
144
+ height: '90%',
145
+ objectFit: 'contain',
146
+ borderRadius: '9px',
147
+ },
148
+ sightIconWidth: {
149
+ strokeWidth: '6px',
150
+ },
151
+ };
152
+ function usePhotoCaptureHUDSightTutorialStyles(show, tutorialImage) {
153
+ var palette = (0, common_1.useMonkTheme)().palette;
154
+ var getIconAttributes = (0, react_1.useCallback)(function () { return ({ style: exports.styles['sightIconWidth'] }); }, []);
155
+ return {
156
+ container: __assign(__assign({}, exports.styles['container']), (show ? exports.styles['containerVisible'] : {})),
157
+ tutorialContainer: __assign(__assign({}, exports.styles['tutorialContainer']), { backgroundColor: (0, common_1.changeAlpha)(palette.background.base, 0.7), border: "solid ".concat(BORDER_WIDTH, "px ").concat((0, common_1.changeAlpha)(palette.surface.light, 0.5)) }),
158
+ classicTutorialContainer: __assign(__assign({}, exports.styles['classicTutorialContainer']), { backgroundColor: palette.text.white, color: palette.text.black }),
159
+ classicTitleContainer: __assign(__assign({}, exports.styles['classicTitleContainer']), { borderBottom: "solid ".concat(BORDER_WIDTH, "px ").concat(palette.secondary.xlight) }),
160
+ closeButton: __assign({}, exports.styles['closeButton']),
161
+ guidelineContainer: __assign(__assign({}, exports.styles['guidelineContainer']), (!tutorialImage ? { height: '90%' } : {})),
162
+ guideline: __assign(__assign({}, exports.styles['guideline']), (!tutorialImage ? { alignItems: 'center' } : {})),
163
+ classicGuidelineContainer: __assign(__assign({}, exports.styles['classicGuidelineContainer']), (!tutorialImage ? { height: '90%' } : {})),
164
+ classicGuideline: __assign(__assign({}, exports.styles['classicGuideline']), (!tutorialImage ? { alignItems: 'center' } : {})),
165
+ sightIcon: {
166
+ getAttributes: getIconAttributes,
167
+ },
168
+ };
169
+ }
170
+ exports.usePhotoCaptureHUDSightTutorialStyles = usePhotoCaptureHUDSightTutorialStyles;
@@ -0,0 +1 @@
1
+ export { PhotoCaptureHUDSightTutorial, type PhotoCaptureHUDSightTutorialProps, } from './PhotoCaptureHUDSightTutorial';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PhotoCaptureHUDSightTutorial = void 0;
4
+ var PhotoCaptureHUDSightTutorial_1 = require("./PhotoCaptureHUDSightTutorial");
5
+ Object.defineProperty(exports, "PhotoCaptureHUDSightTutorial", { enumerable: true, get: function () { return PhotoCaptureHUDSightTutorial_1.PhotoCaptureHUDSightTutorial; } });
@@ -21,8 +21,12 @@ export interface PhotoCaptureHUDTutorialProps extends Pick<PhotoCaptureAppConfig
21
21
  * Callback called when the user clicks on "Close" button in PhotoCapture tutorial.
22
22
  */
23
23
  onCloseTutorial: () => void;
24
+ /**
25
+ * Callback called when the user clicks on the "help" button in PhotoCapture.
26
+ */
27
+ toggleSightTutorial?: () => void;
24
28
  }
25
29
  /**
26
30
  * Component that displays an tutorial overlay on top of the PhotoCapture component.
27
31
  */
28
- export declare function PhotoCaptureHUDTutorial({ currentTutorialStep, allowSkipTutorial, sightGuidelines, sightId, onNextTutorialStep, onCloseTutorial, addDamage, }: PhotoCaptureHUDTutorialProps): JSX.Element | null;
32
+ export declare function PhotoCaptureHUDTutorial({ currentTutorialStep, allowSkipTutorial, sightGuidelines, sightId, onNextTutorialStep, onCloseTutorial, addDamage, toggleSightTutorial, }: PhotoCaptureHUDTutorialProps): JSX.Element | null;
@@ -22,6 +22,7 @@ var ArrowIcon_1 = require("./ArrowIcon");
22
22
  var DisplayText_1 = require("./DisplayText");
23
23
  var hooks_2 = require("../../../hooks");
24
24
  var hooks_3 = require("./hooks");
25
+ var components_1 = require("../../../components");
25
26
  function getButtonStyle(enableAddDamage) {
26
27
  return { visibility: enableAddDamage ? 'visible' : 'hidden' };
27
28
  }
@@ -29,10 +30,10 @@ function getButtonStyle(enableAddDamage) {
29
30
  * Component that displays an tutorial overlay on top of the PhotoCapture component.
30
31
  */
31
32
  function PhotoCaptureHUDTutorial(_a) {
32
- var currentTutorialStep = _a.currentTutorialStep, allowSkipTutorial = _a.allowSkipTutorial, sightGuidelines = _a.sightGuidelines, sightId = _a.sightId, onNextTutorialStep = _a.onNextTutorialStep, onCloseTutorial = _a.onCloseTutorial, addDamage = _a.addDamage;
33
+ var currentTutorialStep = _a.currentTutorialStep, allowSkipTutorial = _a.allowSkipTutorial, sightGuidelines = _a.sightGuidelines, sightId = _a.sightId, onNextTutorialStep = _a.onNextTutorialStep, onCloseTutorial = _a.onCloseTutorial, addDamage = _a.addDamage, toggleSightTutorial = _a.toggleSightTutorial;
33
34
  var t = (0, react_i18next_1.useTranslation)().t;
34
35
  var primaryColor = (0, hooks_2.useColorBackground)();
35
36
  var style = (0, hooks_3.usePhotoCaptureHUDTutorialStyle)();
36
- return currentTutorialStep ? ((0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['backdropContainer'], "data-testid": 'backdrop' }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['topContainer'] }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['buttonsContainer'] }, { children: [(0, jsx_runtime_1.jsx)("div", { style: PhotoCaptureHUDTutorial_styles_1.styles['closeButtonTwin'] }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.SightGuideline, { sightId: sightId, sightGuidelines: sightGuidelines, disabled: currentTutorialStep !== hooks_1.TutorialSteps.GUIDELINE, addDamage: addDamage, enableDefaultMessage: true }), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: __assign(__assign({}, PhotoCaptureHUDTutorial_styles_1.styles['closeButton']), getButtonStyle(allowSkipTutorial)), disabled: !allowSkipTutorial, icon: 'close', primaryColor: primaryColor, onClick: onCloseTutorial })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['arrows'] }, { children: (0, jsx_runtime_1.jsx)(ArrowIcon_1.ArrowIcon, { tutorialStep: currentTutorialStep }) }))] })), (0, jsx_runtime_1.jsx)(DisplayText_1.DisplayText, { tutorialStep: currentTutorialStep }), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['nextButton'], primaryColor: 'primary', onClick: onNextTutorialStep }, { children: t('photo.hud.tutorial.next') }))] })) }))) : null;
37
+ return currentTutorialStep ? ((0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['backdropContainer'], "data-testid": 'backdrop' }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['topContainer'] }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['buttonsContainer'] }, { children: [(0, jsx_runtime_1.jsx)("div", { style: PhotoCaptureHUDTutorial_styles_1.styles['closeButtonTwin'] }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.SightGuideline, { sightId: sightId, sightGuidelines: sightGuidelines, disabled: currentTutorialStep !== hooks_1.TutorialSteps.GUIDELINE, addDamage: addDamage, enableDefaultMessage: true }), currentTutorialStep === hooks_1.TutorialSteps.SIGHT_TUTORIAL && ((0, jsx_runtime_1.jsx)(components_1.SightTutorialButton, { toggleSightTutorial: toggleSightTutorial, style: PhotoCaptureHUDTutorial_styles_1.styles['sightTutorialBtn'] })), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: __assign(__assign({}, PhotoCaptureHUDTutorial_styles_1.styles['closeButton']), getButtonStyle(allowSkipTutorial)), disabled: !allowSkipTutorial, icon: 'close', primaryColor: primaryColor, onClick: onCloseTutorial })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['arrows'] }, { children: (0, jsx_runtime_1.jsx)(ArrowIcon_1.ArrowIcon, { tutorialStep: currentTutorialStep }) }))] })), (0, jsx_runtime_1.jsx)(DisplayText_1.DisplayText, { tutorialStep: currentTutorialStep }), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, __assign({ style: PhotoCaptureHUDTutorial_styles_1.styles['nextButton'], primaryColor: 'primary', onClick: onNextTutorialStep }, { children: t('photo.hud.tutorial.next') }))] })) }))) : null;
37
38
  }
38
39
  exports.PhotoCaptureHUDTutorial = PhotoCaptureHUDTutorial;
@@ -18,10 +18,11 @@ exports.styles = {
18
18
  flexDirection: 'column',
19
19
  position: 'fixed',
20
20
  width: "calc(98% - (".concat(HUDButtons_styles_1.PHOTO_CAPTURE_HUD_BUTTONS_BAR_WIDTH * 4, "px))"),
21
- top: '10px',
21
+ top: 0,
22
22
  bottom: '40px',
23
23
  justifyContent: 'space-between',
24
24
  alignItems: 'center',
25
+ margin: '10px',
25
26
  },
26
27
  elementsContainerPortrait: {
27
28
  __media: { portrait: true },
@@ -69,8 +70,13 @@ exports.styles = {
69
70
  },
70
71
  arrowSightTutorial: {
71
72
  position: 'fixed',
72
- bottom: '60px',
73
- left: "calc((".concat(HUDButtons_styles_1.PHOTO_CAPTURE_HUD_BUTTONS_BAR_WIDTH * 2, "px))"),
73
+ top: '30px',
74
+ left: '80px',
74
75
  width: '40px',
75
76
  },
77
+ sightTutorialBtn: {
78
+ position: 'fixed',
79
+ left: '10px',
80
+ padding: '8px',
81
+ },
76
82
  };
@@ -3,3 +3,4 @@ export * from './useComplianceAnalytics';
3
3
  export * from './usePhotoCaptureTutorial';
4
4
  export * from './usePhotoCaptureSightGuidelines';
5
5
  export * from './useInspectionComplete';
6
+ export * from './usePhotoCaptureSightTutorial';
@@ -19,3 +19,4 @@ __exportStar(require("./useComplianceAnalytics"), exports);
19
19
  __exportStar(require("./usePhotoCaptureTutorial"), exports);
20
20
  __exportStar(require("./usePhotoCaptureSightGuidelines"), exports);
21
21
  __exportStar(require("./useInspectionComplete"), exports);
22
+ __exportStar(require("./usePhotoCaptureSightTutorial"), exports);
@@ -18,6 +18,10 @@ export interface InspectionCompleteParams extends Pick<PhotoCaptureAppConfig, 's
18
18
  * Global loading state of the PhotoCapture component.
19
19
  */
20
20
  loading: LoadingState;
21
+ /**
22
+ * Callback called when the user updates the duration of the inspection capture.
23
+ */
24
+ onUpdateDuration: (forceUpdate?: boolean) => Promise<number>;
21
25
  /**
22
26
  * Callback called when the user clicks on the "Complete" button in the HUD.
23
27
  */
@@ -35,4 +39,4 @@ export interface InspectionCompleteHandle {
35
39
  /**
36
40
  * Custom hook used to generate the callback called when the user has completed the inspection.
37
41
  */
38
- export declare function useInspectionComplete({ startTasks, sightState, loading, startTasksOnComplete, onComplete, }: InspectionCompleteParams): InspectionCompleteHandle;
42
+ export declare function useInspectionComplete({ startTasks, sightState, loading, startTasksOnComplete, onUpdateDuration, onComplete, }: InspectionCompleteParams): InspectionCompleteHandle;
@@ -1,4 +1,40 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.useInspectionComplete = void 0;
4
40
  var common_1 = require("@monkvision/common");
@@ -9,25 +45,37 @@ var monitoring_1 = require("@monkvision/monitoring");
9
45
  * Custom hook used to generate the callback called when the user has completed the inspection.
10
46
  */
11
47
  function useInspectionComplete(_a) {
12
- var startTasks = _a.startTasks, sightState = _a.sightState, loading = _a.loading, startTasksOnComplete = _a.startTasksOnComplete, onComplete = _a.onComplete;
48
+ var _this = this;
49
+ var startTasks = _a.startTasks, sightState = _a.sightState, loading = _a.loading, startTasksOnComplete = _a.startTasksOnComplete, onUpdateDuration = _a.onUpdateDuration, onComplete = _a.onComplete;
13
50
  var analytics = (0, analytics_1.useAnalytics)();
14
51
  var monitoring = (0, monitoring_1.useMonitoring)();
15
- var handleInspectionCompleted = (0, react_1.useCallback)(function () {
16
- startTasks()
17
- .then(function () {
18
- analytics.trackEvent('Capture Completed');
19
- analytics.setUserProperties({
20
- captureCompleted: true,
21
- sightSelected: 'inspection-completed',
22
- });
23
- onComplete === null || onComplete === void 0 ? void 0 : onComplete();
24
- sightState.setIsInspectionCompleted(true);
25
- })
26
- .catch(function (err) {
27
- loading.onError(err);
28
- monitoring.handleError(err);
52
+ var handleInspectionCompleted = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
53
+ var updatedDuration;
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0: return [4 /*yield*/, onUpdateDuration(true)];
57
+ case 1:
58
+ updatedDuration = _a.sent();
59
+ startTasks()
60
+ .then(function () {
61
+ analytics.trackEvent('Capture Completed', {
62
+ capture_duration: updatedDuration,
63
+ });
64
+ analytics.setUserProperties({
65
+ captureCompleted: true,
66
+ sightSelected: 'inspection-completed',
67
+ });
68
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
69
+ sightState.setIsInspectionCompleted(true);
70
+ })
71
+ .catch(function (err) {
72
+ loading.onError(err);
73
+ monitoring.handleError(err);
74
+ });
75
+ return [2 /*return*/];
76
+ }
29
77
  });
30
- }, []);
78
+ }); }, []);
31
79
  (0, react_1.useEffect)(function () {
32
80
  var isInspectionCompliant = sightState.isInspectionCompliant, isInspectionCompleted = sightState.isInspectionCompleted;
33
81
  if (startTasksOnComplete && isInspectionCompliant && !isInspectionCompleted) {
@@ -1,7 +1,7 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
2
  import { MonkApiConfig } from '@monkvision/network';
3
3
  import { LoadingState } from '@monkvision/common';
4
- import { ComplianceOptions, Sight, TaskName, PhotoCaptureAppConfig } from '@monkvision/types';
4
+ import { ComplianceOptions, Sight, TaskName } from '@monkvision/types';
5
5
  /**
6
6
  * Object containing state management utilities for the PhotoCapture sights.
7
7
  */
@@ -54,7 +54,7 @@ export interface PhotoCaptureSightState {
54
54
  /**
55
55
  * Parameters of the usePhotoCaptureSightState hook.
56
56
  */
57
- export interface PhotoCaptureSightsParams extends Pick<PhotoCaptureAppConfig, 'startTasksOnComplete'> {
57
+ export interface PhotoCaptureSightsParams {
58
58
  /**
59
59
  * The inspection ID.
60
60
  */
@@ -88,13 +88,9 @@ export interface PhotoCaptureSightsParams extends Pick<PhotoCaptureAppConfig, 's
88
88
  * sight will be used.
89
89
  */
90
90
  tasksBySight?: Record<string, TaskName[]>;
91
- /**
92
- * Callback called when inspection capture is complete.
93
- */
94
- onComplete?: () => void;
95
91
  }
96
92
  /**
97
93
  * Custom hook used to manage the state of the PhotoCapture sights. This state is automatically fetched from the API at
98
94
  * the start of the PhotoCapture process in order to allow users to start the inspection where they left it before.
99
95
  */
100
- export declare function usePhotoCaptureSightState({ inspectionId, captureSights, apiConfig, loading, onLastSightTaken, tasksBySight, setIsInitialInspectionFetched, complianceOptions, startTasksOnComplete, onComplete, }: PhotoCaptureSightsParams): PhotoCaptureSightState;
96
+ export declare function usePhotoCaptureSightState({ inspectionId, captureSights, apiConfig, loading, onLastSightTaken, tasksBySight, setIsInitialInspectionFetched, complianceOptions, }: PhotoCaptureSightsParams): PhotoCaptureSightState;
@@ -77,7 +77,7 @@ function getNotCompliantSights(inspectionId, captureSights, entities, notComplia
77
77
  * the start of the PhotoCapture process in order to allow users to start the inspection where they left it before.
78
78
  */
79
79
  function usePhotoCaptureSightState(_a) {
80
- var inspectionId = _a.inspectionId, captureSights = _a.captureSights, apiConfig = _a.apiConfig, loading = _a.loading, onLastSightTaken = _a.onLastSightTaken, tasksBySight = _a.tasksBySight, setIsInitialInspectionFetched = _a.setIsInitialInspectionFetched, complianceOptions = _a.complianceOptions, startTasksOnComplete = _a.startTasksOnComplete, onComplete = _a.onComplete;
80
+ var inspectionId = _a.inspectionId, captureSights = _a.captureSights, apiConfig = _a.apiConfig, loading = _a.loading, onLastSightTaken = _a.onLastSightTaken, tasksBySight = _a.tasksBySight, setIsInitialInspectionFetched = _a.setIsInitialInspectionFetched, complianceOptions = _a.complianceOptions;
81
81
  if (captureSights.length === 0) {
82
82
  throw new Error('Empty sight list given to the Monk PhotoCapture component.');
83
83
  }
@@ -177,7 +177,7 @@ function usePhotoCaptureSightState(_a) {
177
177
  if (nextSight) {
178
178
  setSelectedSight(nextSight);
179
179
  }
180
- else if (!startTasksOnComplete || !onComplete) {
180
+ else {
181
181
  onLastSightTaken();
182
182
  }
183
183
  }, [sightsTaken, selectedSight, captureSights, onLastSightTaken]);
@@ -0,0 +1,14 @@
1
+ export interface HandlePhotoCaptureSightTutorial {
2
+ /**
3
+ * Boolean indicating whether the sight tutorial should be displayed.
4
+ */
5
+ showSightTutorial: boolean;
6
+ /**
7
+ * Callback called when the user clicks on the "help" button in PhotoCapture.
8
+ */
9
+ toggleSightTutorial: () => void;
10
+ }
11
+ /**
12
+ * Custom hook used to manage the state of photo capture sight tutorial.
13
+ */
14
+ export declare function usePhotoCaptureSightTutorial(): HandlePhotoCaptureSightTutorial;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePhotoCaptureSightTutorial = void 0;
4
+ var common_1 = require("@monkvision/common");
5
+ var react_1 = require("react");
6
+ /**
7
+ * Custom hook used to manage the state of photo capture sight tutorial.
8
+ */
9
+ function usePhotoCaptureSightTutorial() {
10
+ var _a = (0, react_1.useState)(false), showSightTutorial = _a[0], setShowSightTutorial = _a[1];
11
+ var toggleSightTutorial = function () {
12
+ setShowSightTutorial(!showSightTutorial);
13
+ };
14
+ return (0, common_1.useObjectMemo)({ showSightTutorial: showSightTutorial, toggleSightTutorial: toggleSightTutorial });
15
+ }
16
+ exports.usePhotoCaptureSightTutorial = usePhotoCaptureSightTutorial;
@@ -45,7 +45,7 @@ function usePhotoCaptureTutorial(_a) {
45
45
  if (!enableSightGuidelines) {
46
46
  steps = steps.filter(function (v) { return v !== TutorialSteps.GUIDELINE; });
47
47
  }
48
- if (!enableSightTutorial) {
48
+ if (enableSightTutorial === types_1.PhotoCaptureSightTutorialOption.DISABLED) {
49
49
  steps = steps.filter(function (v) { return v !== TutorialSteps.SIGHT_TUTORIAL; });
50
50
  }
51
51
  if (currentTutorialStep === steps.at(-1)) {
@@ -0,0 +1,14 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ /**
3
+ * Props of the SightTutorialButton component.
4
+ */
5
+ export interface SightTutorialButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
6
+ /**
7
+ * Callback called when the user clicks on the "help" button in PhotoCapture.
8
+ */
9
+ toggleSightTutorial?: () => void;
10
+ }
11
+ /**
12
+ * Component implementing a cancel button displayed in the Camera HUD.
13
+ */
14
+ export declare function SightTutorialButton({ toggleSightTutorial, ...passThroughProps }: SightTutorialButtonProps): JSX.Element;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.SightTutorialButton = void 0;
26
+ var jsx_runtime_1 = require("react/jsx-runtime");
27
+ var common_ui_web_1 = require("@monkvision/common-ui-web");
28
+ var SightTutorialButton_styles_1 = require("./SightTutorialButton.styles");
29
+ /**
30
+ * Component implementing a cancel button displayed in the Camera HUD.
31
+ */
32
+ function SightTutorialButton(_a) {
33
+ var toggleSightTutorial = _a.toggleSightTutorial, passThroughProps = __rest(_a, ["toggleSightTutorial"]);
34
+ return ((0, jsx_runtime_1.jsx)(common_ui_web_1.Button, __assign({ variant: 'text', onClick: toggleSightTutorial, style: SightTutorialButton_styles_1.styles['sightTutorialButton'] }, passThroughProps, { children: (0, jsx_runtime_1.jsx)(common_ui_web_1.Icon, { size: 50, icon: 'help-outline', primaryColor: 'text-primary' }) })));
35
+ }
36
+ exports.SightTutorialButton = SightTutorialButton;
@@ -0,0 +1,2 @@
1
+ import { Styles } from '@monkvision/types';
2
+ export declare const styles: Styles;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.styles = void 0;
4
+ exports.styles = {
5
+ sightTutorialButton: { padding: '8px' },
6
+ };
@@ -0,0 +1 @@
1
+ export { SightTutorialButton, type SightTutorialButtonProps } from './SightTutorialButton';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SightTutorialButton = void 0;
4
+ var SightTutorialButton_1 = require("./SightTutorialButton");
5
+ Object.defineProperty(exports, "SightTutorialButton", { enumerable: true, get: function () { return SightTutorialButton_1.SightTutorialButton; } });
@@ -6,3 +6,4 @@ export * from './PartSelection';
6
6
  export * from './Counter';
7
7
  export * from './ZoomOutShot';
8
8
  export * from './HUDOverlay';
9
+ export * from './SightTutorialButton';
@@ -22,3 +22,4 @@ __exportStar(require("./PartSelection"), exports);
22
22
  __exportStar(require("./Counter"), exports);
23
23
  __exportStar(require("./ZoomOutShot"), exports);
24
24
  __exportStar(require("./HUDOverlay"), exports);
25
+ __exportStar(require("./SightTutorialButton"), exports);
@@ -8,3 +8,4 @@ export * from './usePhotoCaptureImages';
8
8
  export * from './useBadConnectionWarning';
9
9
  export * from './useAdaptiveCameraConfig';
10
10
  export * from './useTracking';
11
+ export * from './useCaptureDuration';
@@ -24,3 +24,4 @@ __exportStar(require("./usePhotoCaptureImages"), exports);
24
24
  __exportStar(require("./useBadConnectionWarning"), exports);
25
25
  __exportStar(require("./useAdaptiveCameraConfig"), exports);
26
26
  __exportStar(require("./useTracking"), exports);
27
+ __exportStar(require("./useCaptureDuration"), exports);
@@ -0,0 +1,39 @@
1
+ import { MonkApiConfig } from '@monkvision/network';
2
+ /**
3
+ * Parameters of the useCaptureDuration hook.
4
+ */
5
+ export interface CaptureDurationParams {
6
+ /**
7
+ * The inspection ID.
8
+ */
9
+ inspectionId: string;
10
+ /**
11
+ * The api config used to communicate with the API.
12
+ */
13
+ apiConfig: MonkApiConfig;
14
+ /**
15
+ * Boolean indicating if the inspection is completed or not.
16
+ */
17
+ isInspectionCompleted: boolean;
18
+ /**
19
+ * Interval in milliseconds for the heartbeat to update the duration.
20
+ */
21
+ heartbeatInterval?: number;
22
+ /**
23
+ * Idle timeout in milliseconds to pause the capture duration tracking.
24
+ */
25
+ idleTimeout?: number;
26
+ }
27
+ /**
28
+ * Handle used to manage the capture duration.
29
+ */
30
+ export interface HandleCaptureDuration {
31
+ /**
32
+ * Callback to update the capture duration in the API.
33
+ */
34
+ updateDuration: () => Promise<number>;
35
+ }
36
+ /**
37
+ * Custom hook used to track the duration of an inspection session.
38
+ */
39
+ export declare function useCaptureDuration({ apiConfig, inspectionId, isInspectionCompleted, heartbeatInterval, idleTimeout, }: CaptureDurationParams): HandleCaptureDuration;