@3cr/viewer-browser 0.0.200 → 0.0.246

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 (383) hide show
  1. package/.circleci/config.yml +46 -22
  2. package/.prettierrc +6 -0
  3. package/components.d.ts +27 -10
  4. package/dist/Viewer3CR.js +36 -45
  5. package/dist/Viewer3CR.mjs +26893 -21667
  6. package/dist/Viewer3CR.umd.js +36 -45
  7. package/dist/android-chrome-192x192.png +0 -0
  8. package/dist/android-chrome-512x512.png +0 -0
  9. package/dist/apple-touch-icon.png +0 -0
  10. package/dist/browserconfig.xml +9 -0
  11. package/dist/favicon-16x16.png +0 -0
  12. package/dist/favicon-32x32.png +0 -0
  13. package/dist/favicon.ico +0 -0
  14. package/dist/mstile-144x144.png +0 -0
  15. package/dist/mstile-150x150.png +0 -0
  16. package/dist/mstile-310x150.png +0 -0
  17. package/dist/mstile-310x310.png +0 -0
  18. package/dist/mstile-70x70.png +0 -0
  19. package/dist/safari-pinned-tab.svg +50 -0
  20. package/dist/site.webmanifest +19 -0
  21. package/index.html +34 -41
  22. package/package.json +24 -20
  23. package/playground/android-chrome-192x192.png +0 -0
  24. package/playground/android-chrome-512x512.png +0 -0
  25. package/playground/apple-touch-icon.png +0 -0
  26. package/playground/browserconfig.xml +9 -0
  27. package/playground/favicon-16x16.png +0 -0
  28. package/playground/favicon-32x32.png +0 -0
  29. package/playground/favicon.ico +0 -0
  30. package/playground/index.html +30 -41
  31. package/playground/mstile-144x144.png +0 -0
  32. package/playground/mstile-150x150.png +0 -0
  33. package/playground/mstile-310x150.png +0 -0
  34. package/playground/mstile-310x310.png +0 -0
  35. package/playground/mstile-70x70.png +0 -0
  36. package/playground/safari-pinned-tab.svg +50 -0
  37. package/playground/site.webmanifest +19 -0
  38. package/playground/sw.js +15 -1
  39. package/public/android-chrome-192x192.png +0 -0
  40. package/public/android-chrome-512x512.png +0 -0
  41. package/public/apple-touch-icon.png +0 -0
  42. package/public/browserconfig.xml +9 -0
  43. package/public/favicon-16x16.png +0 -0
  44. package/public/favicon-32x32.png +0 -0
  45. package/public/favicon.ico +0 -0
  46. package/public/mstile-144x144.png +0 -0
  47. package/public/mstile-150x150.png +0 -0
  48. package/public/mstile-310x150.png +0 -0
  49. package/public/mstile-310x310.png +0 -0
  50. package/public/mstile-70x70.png +0 -0
  51. package/public/safari-pinned-tab.svg +50 -0
  52. package/public/site.webmanifest +19 -0
  53. package/src/App.vue +55 -50
  54. package/src/__tests__/app.spec.ts +7 -8
  55. package/{__tests__/index.spec.ts → src/__tests__/main.spec.ts} +5 -6
  56. package/src/assets/logos/3dicom/white-mini.svg +20 -0
  57. package/src/assets/logos/3dicom/white.svg +30 -0
  58. package/src/assets/styles.scss +18 -4
  59. package/src/components/demo/DemoPatientModal.vue +12 -22
  60. package/src/components/demo/__tests__/DemoModal.spec.ts +9 -8
  61. package/src/components/demo/__tests__/DemoPatientModal.spec.ts +11 -10
  62. package/src/components/demo/__tests__/options.spec.ts +1 -1
  63. package/src/components/demo/licence/DemoLicenceInfoModal.vue +11 -29
  64. package/src/components/demo/licence/__tests__/DemoLicenceEnableCloudStorageModal.spec.ts +11 -10
  65. package/src/components/demo/licence/__tests__/DemoLicenceInfoModal.spec.ts +21 -11
  66. package/src/components/demo/licence/__tests__/DemoLicenceSendToPartyModal.spec.ts +10 -10
  67. package/src/components/demo/licence/__tests__/DemoLicenceShareToMobileModal.spec.ts +14 -13
  68. package/src/components/demo/options.ts +74 -76
  69. package/src/components/demo/patient/DemoPatientInfoModal.vue +11 -29
  70. package/src/components/demo/patient/__tests__/DemoPatientEnableCloudStorageModal.spec.ts +11 -10
  71. package/src/components/demo/patient/__tests__/DemoPatientInfoModal.spec.ts +12 -11
  72. package/src/components/demo/patient/__tests__/DemoPatientSendToPartyModal.spec.ts +10 -10
  73. package/src/components/demo/patient/__tests__/DemoPatientShareToMobileModal.spec.ts +14 -13
  74. package/src/components/modal/ActionRail.vue +7 -11
  75. package/src/components/modal/AskAI.vue +35 -50
  76. package/src/components/modal/CloseViewerModal.vue +22 -57
  77. package/src/components/modal/MftpWebGL3DRModal.vue +230 -635
  78. package/src/components/modal/ViewerActionRail.vue +44 -39
  79. package/src/components/modal/ViewerNavigationDrawer.vue +10 -8
  80. package/src/components/modal/ViewerNavigationDrawerContent.vue +91 -49
  81. package/src/components/modal/ViewerNavigationDrawerFooter.vue +83 -63
  82. package/src/components/modal/ViewerNavigationDrawerHeader.vue +14 -44
  83. package/src/components/modal/ViewerScanView.vue +114 -0
  84. package/src/components/modal/WebGL3DR.vue +91 -0
  85. package/src/components/modal/__tests__/ActionRail.spec.ts +10 -0
  86. package/src/components/modal/__tests__/AskAI.spec.ts +33 -0
  87. package/src/components/modal/__tests__/CloseViewerModal.spec.ts +24 -14
  88. package/src/components/modal/__tests__/MftpWebGL3DRModal.spec.ts +147 -176
  89. package/src/components/modal/__tests__/ViewerActionRail.spec.ts +11 -0
  90. package/src/components/modal/__tests__/ViewerNavigationDrawer.spec.ts +10 -12
  91. package/src/components/modal/__tests__/ViewerNavigationDrawerContent.spec.ts +4 -22
  92. package/src/components/modal/__tests__/ViewerNavigationDrawerFooter.spec.ts +35 -32
  93. package/src/components/modal/__tests__/ViewerNavigationDrawerHeader.spec.ts +14 -11
  94. package/src/components/modal/__tests__/ViewerScanView.spec.ts +60 -0
  95. package/src/components/modal/__tests__/WebGL3DR.spec.ts +57 -0
  96. package/src/components/modal/actions/Flip3dAction.vue +1 -1
  97. package/src/components/modal/actions/FlipHorizontalAction.vue +5 -10
  98. package/src/components/modal/actions/FlipVerticalAction.vue +5 -10
  99. package/src/components/modal/actions/FullscreenAction.vue +6 -11
  100. package/src/components/modal/actions/NavigationCubeAction.vue +7 -14
  101. package/src/components/modal/actions/PanAction.vue +4 -4
  102. package/src/components/modal/actions/ResetViewAction.vue +1 -1
  103. package/src/components/modal/actions/Rotate2dAction.vue +8 -20
  104. package/src/components/modal/actions/Slice3dAction.vue +10 -32
  105. package/src/components/modal/actions/ZoomAction.vue +1 -1
  106. package/src/components/modal/actions/__tests__/Action.spec.ts +8 -9
  107. package/src/components/modal/actions/__tests__/Flip3dAction.spec.ts +6 -8
  108. package/src/components/modal/actions/__tests__/FlipHorizontalAction.spec.ts +6 -7
  109. package/src/components/modal/actions/__tests__/FlipVerticalAction.spec.ts +6 -7
  110. package/src/components/modal/actions/__tests__/FullscreenAction.spec.ts +9 -10
  111. package/src/components/modal/actions/__tests__/NavigationCubeAction.spec.ts +11 -11
  112. package/src/components/modal/actions/__tests__/PanAction.spec.ts +9 -10
  113. package/src/components/modal/actions/__tests__/ResetViewAction.spec.ts +7 -7
  114. package/src/components/modal/actions/__tests__/Rotate2dAction.spec.ts +6 -8
  115. package/src/components/modal/actions/__tests__/Slice3dAction.spec.ts +23 -5
  116. package/src/components/modal/actions/__tests__/ZoomAction.spec.ts +8 -10
  117. package/src/components/modal/buttons/AutoAnnotateBtn.vue +197 -0
  118. package/src/components/modal/buttons/__tests__/AutoAnnotateBtn.spec.ts +28 -0
  119. package/src/components/modal/menus/FileMenu.vue +73 -0
  120. package/src/components/modal/menus/SettingsMenu.vue +106 -0
  121. package/src/components/modal/menus/__tests__/FileMenu.spec.ts +110 -0
  122. package/src/components/modal/menus/__tests__/SettingsMenu.spec.ts +71 -0
  123. package/src/components/navigation/mcad/McadGlobalActions.vue +20 -0
  124. package/src/components/navigation/mcad/McadGlobalOpacitySlider.vue +103 -0
  125. package/src/components/navigation/mcad/McadGlobalScanViewBtn.vue +28 -0
  126. package/src/components/navigation/mcad/McadGlobalVisibilityBtn.vue +38 -0
  127. package/src/components/shared/DoubleSliderSelector.vue +142 -0
  128. package/src/components/{loading → shared}/LoadingSpinner.vue +27 -36
  129. package/src/components/shared/UpdateSnackbar.vue +72 -0
  130. package/src/components/{selectors → shared}/ValueSelector.vue +9 -12
  131. package/src/components/shared/__tests__/DoubleSliderSelector.spec.ts +83 -0
  132. package/src/components/shared/__tests__/LoadingSpinner.spec.ts +9 -0
  133. package/src/components/shared/__tests__/UpdateSnackbar.spec.ts +116 -0
  134. package/src/components/shared/__tests__/ValueSelector.spec.ts +39 -0
  135. package/src/components/shared/__tests__/VerticalSliderSelector.spec.ts +50 -0
  136. package/src/components/views/AnnotationTreeView.vue +236 -0
  137. package/src/components/{modal/ViewerDisplaySettings.vue → views/DisplaySettings.vue} +7 -15
  138. package/src/components/views/MarkupTreeView.vue +201 -0
  139. package/src/components/views/McadObjectTreeView.vue +129 -0
  140. package/src/components/views/__tests__/AnnotationTreeView.spec.ts +62 -0
  141. package/src/components/{modal/__tests__/ViewerDisplaySettings.spec.ts → views/__tests__/DisplaySettings.spec.ts} +24 -20
  142. package/src/components/views/__tests__/MarkupTreeView.spec.ts +41 -0
  143. package/src/components/views/__tests__/McadObjectTreeView.spec.ts +47 -0
  144. package/src/components/views/modals/DataOverlayGeneralModal.vue +71 -0
  145. package/src/components/views/modals/DataOverlayMarkupModal.vue +60 -0
  146. package/src/components/views/modals/DataOverlayModal.vue +88 -0
  147. package/src/components/views/shared/MaskIcon.vue +44 -0
  148. package/src/components/views/shared/ObjectColor.vue +31 -0
  149. package/src/components/views/shared/ObjectLabel.vue +30 -0
  150. package/src/components/views/shared/Opacity.vue +65 -0
  151. package/src/components/views/shared/VisibilityBtn.vue +25 -0
  152. package/src/components/views/shared/__tests__/MaskIcon.spec.ts +10 -0
  153. package/src/components/views/shared/__tests__/ObjectColor.spec.ts +10 -0
  154. package/src/components/views/shared/__tests__/ObjectLabel.spec.ts +10 -0
  155. package/src/components/views/shared/__tests__/Opacity.spec.ts +24 -0
  156. package/src/components/views/shared/__tests__/VisibilityBtn.spec.ts +11 -0
  157. package/src/components/views/types/annotation-tree-view-item-child-action.ts +6 -0
  158. package/src/components/views/types/annotation-tree-view-item-child.ts +9 -0
  159. package/src/components/views/types/annotation-tree-view-item.ts +13 -0
  160. package/src/components/views/types/markup-tree-view-item-child.ts +6 -0
  161. package/src/components/views/types/markup-tree-view-item.ts +14 -0
  162. package/src/components/views/types/mcad-object-tree-view-item.ts +13 -0
  163. package/src/composables/__tests__/useAnnotations.spec.ts +35 -0
  164. package/src/composables/__tests__/useEventListener.spec.ts +32 -0
  165. package/src/composables/__tests__/useIntroJs.spec.ts +51 -0
  166. package/src/composables/__tests__/useMarkups.spec.ts +39 -0
  167. package/src/composables/__tests__/useMcadObjects.spec.ts +36 -0
  168. package/src/composables/__tests__/useMouse.spec.ts +20 -0
  169. package/src/{components/modal/composables → composables}/__tests__/useNavigationCubeObserver.spec.ts +17 -12
  170. package/src/{dataLayer → composables}/__tests__/useViewer3cr.spec.ts +1 -2
  171. package/src/composables/useAnnotations.ts +37 -0
  172. package/src/composables/useDebounce.ts +11 -0
  173. package/src/composables/useEventListener.ts +25 -0
  174. package/src/composables/useIntroJs.ts +142 -0
  175. package/src/composables/useMarkups.ts +41 -0
  176. package/src/composables/useMcadObjects.ts +32 -0
  177. package/src/composables/useMouse.ts +14 -0
  178. package/src/{components/modal/composables → composables}/useNavigationCubeObserver.ts +35 -25
  179. package/src/composables/useScanMovement.ts +25 -0
  180. package/src/composables/useScanSliders.ts +36 -0
  181. package/src/composables/useVersion3cr.ts +7 -0
  182. package/src/composables/useViewer3cr.ts +7 -0
  183. package/src/composables/useViewerOptions.ts +36 -0
  184. package/src/{dataLayer → functions}/__tests__/clamp.spec.ts +1 -2
  185. package/src/functions/__tests__/layoutOverlayStyle.spec.ts +325 -0
  186. package/src/{helpers/__tests__/model-helper.spec.ts → functions/__tests__/modelHelper.spec.ts} +77 -40
  187. package/src/{notifications → functions}/__tests__/notification.spec.ts +19 -29
  188. package/src/functions/__tests__/parseAction.spec.ts +9 -0
  189. package/src/functions/__tests__/parseCallToAction.spec.ts +11 -0
  190. package/src/functions/__tests__/parseDataOverlay.spec.ts +15 -0
  191. package/src/functions/__tests__/parseDataOverlayData.spec.ts +9 -0
  192. package/src/functions/__tests__/parseDataOverlayEvent.spec.ts +10 -0
  193. package/src/functions/__tests__/parseMcadEvent.spec.ts +10 -0
  194. package/src/functions/guards/isDataOverlayAngle.ts +6 -0
  195. package/src/functions/guards/isDataOverlayLength.ts +6 -0
  196. package/src/functions/guards/isDataOverlayPolygon.ts +6 -0
  197. package/src/functions/layoutOverlayStyle.ts +84 -0
  198. package/src/{helpers → functions}/modelHelper.ts +81 -18
  199. package/src/functions/notification.ts +82 -0
  200. package/src/functions/parseAction.ts +9 -0
  201. package/src/functions/parseCallToAction.ts +9 -0
  202. package/src/functions/parseDataOverlay.ts +10 -0
  203. package/src/functions/parseDataOverlayData.ts +10 -0
  204. package/src/functions/parseDataOverlayEvent.ts +17 -0
  205. package/src/functions/parseMcadEvent.ts +10 -0
  206. package/src/functions/rgbaToCss.ts +13 -0
  207. package/src/main.ts +57 -9
  208. package/src/{dataLayer → models}/__tests__/eventHandlers.spec.ts +2 -3
  209. package/src/models/__tests__/loadViewerOptions.spec.ts +72 -0
  210. package/src/models/__tests__/loadViewerPayload.spec.ts +10 -0
  211. package/src/models/__tests__/scanState.spec.ts +190 -0
  212. package/src/models/callbacks.ts +4 -0
  213. package/src/models/loadViewerOptions.ts +79 -0
  214. package/src/models/loadViewerPayload.ts +17 -0
  215. package/src/{dataLayer → models}/scanState.ts +63 -74
  216. package/src/plugins/__tests__/usePlugins.spec.ts +12 -0
  217. package/src/plugins/__tests__/vuetify.spec.ts +3 -4
  218. package/src/plugins/usePlugins.ts +8 -0
  219. package/src/plugins/vuetify.ts +31 -65
  220. package/src/services/{gpt/__tests__ → __tests__}/gpt.service.spec.ts +2 -2
  221. package/src/services/__tests__/service-worker.service.spec.ts +32 -0
  222. package/src/{dataLayer/__tests__/viewer3cr.spec.ts → services/__tests__/viewer-3cr.service.spec.ts} +97 -36
  223. package/src/services/gpt.service.ts +17 -0
  224. package/src/services/service-worker.service.ts +16 -0
  225. package/src/{dataLayer/viewer3cr.ts → services/viewer-3cr.service.ts} +281 -150
  226. package/src/tools/data-overlay.tool.ts +71 -0
  227. package/src/types/action.ts +13 -0
  228. package/src/types/call-to-action.ts +9 -0
  229. package/src/types/colour.ts +6 -0
  230. package/src/types/data-overlay-angle.ts +16 -0
  231. package/src/types/data-overlay-annotation.ts +18 -0
  232. package/src/types/data-overlay-data.ts +15 -0
  233. package/src/types/data-overlay-event.ts +5 -0
  234. package/src/types/data-overlay-info.ts +18 -0
  235. package/src/types/data-overlay-interaction.ts +15 -0
  236. package/src/types/data-overlay-length.ts +16 -0
  237. package/src/types/data-overlay-markup.ts +7 -0
  238. package/src/types/data-overlay-mcad.ts +20 -0
  239. package/src/types/data-overlay-polygon.ts +18 -0
  240. package/src/types/data-overlay.ts +16 -0
  241. package/src/types/demo-type.ts +4 -0
  242. package/src/types/gpt-question.ts +4 -0
  243. package/src/types/gpt-response-payload.ts +6 -0
  244. package/src/types/mcad-object-interaction.ts +15 -0
  245. package/src/types/segment-angle.ts +5 -0
  246. package/src/types/vector2.ts +4 -0
  247. package/src/types/vector3.ts +5 -0
  248. package/test/fakers/action-data.faker.ts +11 -0
  249. package/test/fakers/action.faker.ts +19 -0
  250. package/test/fakers/call-to-action.faker.ts +17 -0
  251. package/test/fakers/colour.faker.ts +17 -0
  252. package/test/fakers/data-overlay-angle.faker.ts +37 -0
  253. package/test/fakers/data-overlay-annotation.faker.ts +41 -0
  254. package/test/fakers/data-overlay-data.faker.ts +97 -0
  255. package/test/fakers/data-overlay-info.faker.ts +29 -0
  256. package/test/fakers/data-overlay-interaction.faker.ts +62 -0
  257. package/test/fakers/data-overlay-length.faker.ts +37 -0
  258. package/test/fakers/data-overlay-mcad.faker.ts +40 -0
  259. package/test/fakers/data-overlay-polygon.faker.ts +39 -0
  260. package/test/fakers/gpt-question.faker.ts +11 -0
  261. package/test/fakers/gpt-response.faker.ts +12 -0
  262. package/test/fakers/invert-transform.faker.ts +16 -0
  263. package/test/fakers/mcad-object-interaction.faker.ts +22 -0
  264. package/test/fakers/orientation.faker.ts +17 -0
  265. package/test/fakers/segment-angle.faker.ts +12 -0
  266. package/test/fakers/vector2.faker.ts +12 -0
  267. package/test/fakers/vector3.faker.ts +16 -0
  268. package/test/plugins/findByTestId.ts +25 -0
  269. package/test/plugins/vuetify.ts +16 -0
  270. package/test/setup.ts +16 -5
  271. package/tsconfig.json +4 -15
  272. package/vite.config.mts +20 -46
  273. package/vitest.config.mts +24 -43
  274. package/index.ts +0 -72
  275. package/src/assets/images/dark/3DICOM.png +0 -0
  276. package/src/assets/images/dark/3dicom-logo.svg +0 -1
  277. package/src/assets/images/light/3DICOM.png +0 -0
  278. package/src/assets/images/light/3dicom-logo.svg +0 -1
  279. package/src/assets/logo.png +0 -0
  280. package/src/assets/logo.svg +0 -6
  281. package/src/components/WebGL3DR.vue +0 -102
  282. package/src/components/__tests__/webgl3dr.spec.ts +0 -37
  283. package/src/components/icons/liver.vue +0 -21
  284. package/src/components/loading/__tests__/loading-spinner.spec.ts +0 -11
  285. package/src/components/modal/ViewerAnnotationModal.vue +0 -111
  286. package/src/components/modal/ViewerAnnotations.vue +0 -289
  287. package/src/components/modal/__tests__/ViewerAnnotationModal.spec.ts +0 -79
  288. package/src/components/modal/composables/useEventListener.ts +0 -22
  289. package/src/components/selectors/__tests__/value-selector.spec.ts +0 -53
  290. package/src/components/sliders/DoubleSliderSelector.vue +0 -141
  291. package/src/components/sliders/__tests__/double-slider-selector.spec.ts +0 -104
  292. package/src/components/sliders/__tests__/vertical-slider-selector.spec.ts +0 -61
  293. package/src/dataLayer/__tests__/getIconForPreset.spec.ts +0 -40
  294. package/src/dataLayer/__tests__/patchDataOverlay.spec.ts +0 -88
  295. package/src/dataLayer/__tests__/scanState.spec.ts +0 -93
  296. package/src/dataLayer/getIconForPreset.ts +0 -11
  297. package/src/dataLayer/patchDataOverlay.ts +0 -101
  298. package/src/dataLayer/useViewer3cr.ts +0 -7
  299. package/src/helpers/__tests__/layout-overlay-style.spec.ts +0 -290
  300. package/src/helpers/__tests__/utils.spec.ts +0 -70
  301. package/src/helpers/layoutOverlayStyle.ts +0 -96
  302. package/src/helpers/utils.ts +0 -16
  303. package/src/models/Callbacks.ts +0 -2
  304. package/src/models/LoadViewerOptions.ts +0 -31
  305. package/src/models/LoadViewerPayload.ts +0 -9
  306. package/src/models/__tests__/load-viewer-options.spec.ts +0 -22
  307. package/src/notifications/notification.ts +0 -50
  308. package/src/plugins/__tests__/index.spec.ts +0 -19
  309. package/src/plugins/index.ts +0 -17
  310. package/src/services/gpt/gpt.service.ts +0 -35
  311. package/static/3cr-types-browser/index.ts +0 -74
  312. package/static/3cr-types-browser/types/Action.ts +0 -6
  313. package/static/3cr-types-browser/types/AlphaKeys.ts +0 -5
  314. package/static/3cr-types-browser/types/AnchorPoint.ts +0 -12
  315. package/static/3cr-types-browser/types/CallToAction.ts +0 -5
  316. package/static/3cr-types-browser/types/ColourData.ts +0 -7
  317. package/static/3cr-types-browser/types/ColourPresetData.ts +0 -9
  318. package/static/3cr-types-browser/types/CurrentDataOverlayState.ts +0 -6
  319. package/static/3cr-types-browser/types/CurrentScanState.ts +0 -22
  320. package/static/3cr-types-browser/types/DataOverlay.ts +0 -22
  321. package/static/3cr-types-browser/types/DataOverlayActions.ts +0 -14
  322. package/static/3cr-types-browser/types/DataOverlayData.ts +0 -8
  323. package/static/3cr-types-browser/types/DataOverlayEvent.ts +0 -8
  324. package/static/3cr-types-browser/types/DecryptionKey.ts +0 -4
  325. package/static/3cr-types-browser/types/DisplaySettings.ts +0 -10
  326. package/static/3cr-types-browser/types/EmptyPayload.ts +0 -3
  327. package/static/3cr-types-browser/types/EnumPayload.ts +0 -4
  328. package/static/3cr-types-browser/types/FileManagementActions.ts +0 -11
  329. package/static/3cr-types-browser/types/FlipValue.ts +0 -7
  330. package/static/3cr-types-browser/types/FrontEndInterfaces.ts +0 -14
  331. package/static/3cr-types-browser/types/GradientKeys.ts +0 -7
  332. package/static/3cr-types-browser/types/GreyscalePresetData.ts +0 -6
  333. package/static/3cr-types-browser/types/InitialDataOverlayState.ts +0 -6
  334. package/static/3cr-types-browser/types/InitialScanState.ts +0 -19
  335. package/static/3cr-types-browser/types/InteractionType.ts +0 -8
  336. package/static/3cr-types-browser/types/InteractivityActions.ts +0 -6
  337. package/static/3cr-types-browser/types/InteractivityState.ts +0 -4
  338. package/static/3cr-types-browser/types/InvertTransformData.ts +0 -6
  339. package/static/3cr-types-browser/types/LayoutActions.ts +0 -6
  340. package/static/3cr-types-browser/types/LayoutData.ts +0 -7
  341. package/static/3cr-types-browser/types/LoadDataSet.ts +0 -6
  342. package/static/3cr-types-browser/types/LoadSessionState.ts +0 -4
  343. package/static/3cr-types-browser/types/LocalLoadDataset.ts +0 -3
  344. package/static/3cr-types-browser/types/MovementData.ts +0 -7
  345. package/static/3cr-types-browser/types/NavigationCubeActions.ts +0 -8
  346. package/static/3cr-types-browser/types/NavigationCubeData.ts +0 -12
  347. package/static/3cr-types-browser/types/NavigationCubeTransform.ts +0 -9
  348. package/static/3cr-types-browser/types/NotificationPayload.ts +0 -7
  349. package/static/3cr-types-browser/types/NotificationsActions.ts +0 -6
  350. package/static/3cr-types-browser/types/Object.ts +0 -1
  351. package/static/3cr-types-browser/types/ObjectColour.ts +0 -7
  352. package/static/3cr-types-browser/types/ObjectIcon.ts +0 -5
  353. package/static/3cr-types-browser/types/ObjectInvert.ts +0 -7
  354. package/static/3cr-types-browser/types/ObjectSize.ts +0 -7
  355. package/static/3cr-types-browser/types/ObjectSize2D.ts +0 -7
  356. package/static/3cr-types-browser/types/ObjectVisible.ts +0 -5
  357. package/static/3cr-types-browser/types/PositionData.ts +0 -14
  358. package/static/3cr-types-browser/types/PresetsActions.ts +0 -4
  359. package/static/3cr-types-browser/types/RotationValue.ts +0 -7
  360. package/static/3cr-types-browser/types/ScanMovementActions.ts +0 -27
  361. package/static/3cr-types-browser/types/ScanMovementData.ts +0 -3
  362. package/static/3cr-types-browser/types/ScanOrientationActions.ts +0 -6
  363. package/static/3cr-types-browser/types/ScanStateActions.ts +0 -4
  364. package/static/3cr-types-browser/types/ScanView.ts +0 -6
  365. package/static/3cr-types-browser/types/SettingsData.ts +0 -12
  366. package/static/3cr-types-browser/types/SlicerData.ts +0 -9
  367. package/static/3cr-types-browser/types/SliderValue.ts +0 -4
  368. package/static/3cr-types-browser/types/SlidersActions.ts +0 -18
  369. package/static/3cr-types-browser/types/Vector2Data.ts +0 -5
  370. package/static/3cr-types-browser/types/Vector3Data.ts +0 -6
  371. package/static/3cr-types-browser/types/VectorMovementData.ts +0 -8
  372. package/static/3cr-types-browser/types/ViewInteractiveMode.ts +0 -5
  373. package/static/3cr-types-browser/types/ViewOrientation.ts +0 -8
  374. package/static/3cr-types-browser/types/ViewOrientations.ts +0 -10
  375. package/static/3cr-types-browser/types/ViewSelectionActions.ts +0 -9
  376. package/static/3cr-types-browser/types/ViewToggleData.ts +0 -7
  377. package/static/3cr-types-browser/types/VolumeOrientation.ts +0 -7
  378. package/test/helper.ts +0 -44
  379. /package/src/components/{sliders → shared}/VerticalSliderSelector.vue +0 -0
  380. /package/{config.ts → src/config.ts} +0 -0
  381. /package/src/{dataLayer → functions}/clamp.ts +0 -0
  382. /package/src/{dataLayer → models}/eventHandlers.ts +0 -0
  383. /package/{static/3cr-types-browser/types/ActionData.ts → src/types/action-data.ts} +0 -0
@@ -0,0 +1,71 @@
1
+ <template>
2
+ <v-card density="compact">
3
+ <v-card-title>{{ dataOverlay.Title }}</v-card-title>
4
+ <v-list density="compact" :lines="false">
5
+ <v-list-item v-if="hasDescription" prepend-icon="description">
6
+ <v-list-item-title>Description</v-list-item-title>
7
+ <v-list-item-subtitle>{{ dataOverlay.Description }}</v-list-item-subtitle>
8
+ </v-list-item>
9
+ <v-list-item v-else prepend-icon="psychology">
10
+ <v-list-item-title>Smart Description</v-list-item-title>
11
+ <v-list-item-subtitle v-if="hasSmartDescription">
12
+ {{ smartDescriptions[dataOverlay.Title].GptResponse }}
13
+ </v-list-item-subtitle>
14
+ <v-list-item-subtitle v-else>
15
+ <v-progress-linear class="mt-2" indeterminate />
16
+ </v-list-item-subtitle>
17
+ </v-list-item>
18
+ <v-list-item prepend-icon="info">
19
+ <v-list-item-title>Resources</v-list-item-title>
20
+ <v-list-item-subtitle v-if="hasActions">
21
+ <template v-for="action in dataOverlay.CallToAction!.Actions">
22
+ <a @click.stop class="text-small" :href="action.ActionData.Url" target="_blank">
23
+ {{ action.ActionData.Description }}
24
+ </a>
25
+ <br />
26
+ </template>
27
+ </v-list-item-subtitle>
28
+ <v-list-item-subtitle v-else class="font-italic">No resources provided</v-list-item-subtitle>
29
+ </v-list-item>
30
+ </v-list>
31
+ </v-card>
32
+ </template>
33
+
34
+ <script setup lang="ts">
35
+ import { DataOverlay } from '@/types/data-overlay';
36
+ import { computed, ref, watch } from 'vue';
37
+ import { GptResponsePayload } from '@/types/gpt-response-payload';
38
+ import { GptService } from '@/services/gpt.service';
39
+
40
+ interface Props {
41
+ dataOverlay: DataOverlay;
42
+ }
43
+
44
+ const props = defineProps<Props>();
45
+
46
+ const smartDescriptions = ref<Record<string, GptResponsePayload>>({});
47
+
48
+ const hasDescription = computed(() => !!props.dataOverlay.Description);
49
+
50
+ const hasSmartDescription = computed(() => props.dataOverlay.Title in smartDescriptions.value);
51
+
52
+ const hasActions = computed(() => {
53
+ return props.dataOverlay.CallToAction?.Actions && props.dataOverlay.CallToAction.Actions.length > 0;
54
+ });
55
+
56
+ watch(
57
+ () => props.dataOverlay,
58
+ async (value: DataOverlay) => {
59
+ await generateSmartDescriptions(value);
60
+ },
61
+ { immediate: true }
62
+ );
63
+
64
+ async function generateSmartDescriptions(overlay: DataOverlay): Promise<void> {
65
+ const key = overlay.Title;
66
+ if (!(key in smartDescriptions.value)) {
67
+ const response = await GptService.Instantiate().GenerateAnnotations(key);
68
+ smartDescriptions.value[key] = response.data;
69
+ }
70
+ }
71
+ </script>
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <v-card density="compact">
3
+ <v-card-title>{{ markup.Title }}</v-card-title>
4
+ <v-list density="compact" :lines="false">
5
+ <v-list-item prepend-icon="analytics">
6
+ <v-list-item-title>Data</v-list-item-title>
7
+ <v-list-item-subtitle>
8
+ <template v-if="'SegmentLengths' in markup">
9
+ <v-row no-gutters v-for="(segment, idx) in markup.SegmentLengths">
10
+ <v-col style="width: 200px">Segment {{ idx + 1 }}</v-col>
11
+ <v-col class="text-mono">{{ segment }}{{ markup.Units }}</v-col>
12
+ </v-row>
13
+ <v-row no-gutters>
14
+ <v-col style="width: 200px">Total Length</v-col>
15
+ <v-col class="text-mono">{{ markup.TotalLength }}{{ markup.Units }}</v-col>
16
+ </v-row>
17
+ </template>
18
+ <template v-if="'Area' in markup">
19
+ <v-row no-gutters>
20
+ <v-col style="width: 200px">Area</v-col>
21
+ <v-col class="text-mono">{{ markup.Area }}</v-col>
22
+ </v-row>
23
+ <v-row no-gutters>
24
+ <v-col style="width: 200px">Perimeter</v-col>
25
+ <v-col class="text-mono">{{ markup.Perimeter }}</v-col>
26
+ </v-row>
27
+ <v-row no-gutters>
28
+ <v-col style="width: 200px">Average HU</v-col>
29
+ <v-col class="text-mono">{{ markup.AverageHU }}</v-col>
30
+ </v-row>
31
+ <v-row no-gutters>
32
+ <v-col style="width: 200px">Lowest HU</v-col>
33
+ <v-col class="text-mono">{{ markup.LowestHU }}</v-col>
34
+ </v-row>
35
+ <v-row no-gutters>
36
+ <v-col style="width: 200px">Highest HU</v-col>
37
+ <v-col class="text-mono">{{ markup.HighestHU }}</v-col>
38
+ </v-row>
39
+ </template>
40
+ <template v-if="'SegmentAngles' in markup">
41
+ <v-row no-gutters v-for="(angle, idx) in markup.SegmentAngles">
42
+ <v-col style="width: 200px">Angle {{ idx + 1 }}</v-col>
43
+ <v-col class="text-mono">{{ angle.Acute }}{{ markup.Units }}</v-col>
44
+ </v-row>
45
+ </template>
46
+ </v-list-item-subtitle>
47
+ </v-list-item>
48
+ </v-list>
49
+ </v-card>
50
+ </template>
51
+
52
+ <script setup lang="ts">
53
+ import { DataOverlayMarkup } from '@/types/data-overlay-markup';
54
+
55
+ interface Props {
56
+ markup: DataOverlayMarkup;
57
+ }
58
+
59
+ defineProps<Props>();
60
+ </script>
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <v-menu v-model="menu" max-width="500" persistent :no-click-animation="true" :target="menuTarget">
3
+ <template v-if="selected">
4
+ <data-overlay-markup-modal v-if="isMarkup" :markup="selected as DataOverlayMarkup" />
5
+ <data-overlay-general-modal v-else :data-overlay="selected" />
6
+ </template>
7
+ </v-menu>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
12
+ import { useEventListener } from '@/composables/useEventListener';
13
+ import { DataOverlay } from '@/types/data-overlay';
14
+ import { DataOverlayMarkup } from '@/types/data-overlay-markup';
15
+ import { isDataOverlayLength } from '@/functions/guards/isDataOverlayLength';
16
+ import { isDataOverlayPolygon } from '@/functions/guards/isDataOverlayPolygon';
17
+ import { isDataOverlayAngle } from '@/functions/guards/isDataOverlayAngle';
18
+ import { useDataOverlayTool } from '@/tools/data-overlay.tool';
19
+
20
+ useEventListener(document, 'mousemove', onMouseMove);
21
+ useEventListener(document, 'mousedown', onMouseDown);
22
+
23
+ const dataOverlayTool = useDataOverlayTool();
24
+ const menu = ref<boolean>(false);
25
+ const currentTarget = ref<[number, number]>([0, 0]);
26
+ const menuTarget = ref<[number, number]>([0, 0]);
27
+
28
+ const selected = computed(() => dataOverlayTool.selected.value);
29
+
30
+ const isMarkup = computed(() => {
31
+ const val = selected.value;
32
+ return val && (isDataOverlayLength(val) || isDataOverlayPolygon(val) || isDataOverlayAngle(val));
33
+ });
34
+
35
+ onMounted(() => {
36
+ dataOverlayTool.activate();
37
+ });
38
+
39
+ onUnmounted(() => {
40
+ dataOverlayTool.deactivate();
41
+ });
42
+
43
+ watch(
44
+ selected,
45
+ async (value: DataOverlay | null) => {
46
+ if (value !== null) {
47
+ menuTarget.value = currentTarget.value;
48
+ menu.value = true;
49
+ }
50
+ },
51
+ { immediate: true }
52
+ );
53
+
54
+ function onMouseMove(event: MouseEvent): void {
55
+ currentTarget.value = [event.x, event.y];
56
+ }
57
+
58
+ function onMouseDown(): void {
59
+ menu.value = false;
60
+ }
61
+ </script>
62
+
63
+ <style scoped lang="scss">
64
+ :deep(.v-card) {
65
+ background: rgba(var(--v-theme-surface), 0.5) !important;
66
+ backdrop-filter: blur(24px);
67
+ }
68
+
69
+ :deep(.v-card-title) {
70
+ background: none;
71
+ font-size: 14px;
72
+ padding-bottom: 0;
73
+ }
74
+
75
+ :deep(.v-list) {
76
+ background: none;
77
+ padding-top: 4px;
78
+ padding-bottom: 4px;
79
+ }
80
+
81
+ :deep(.v-list-item-title) {
82
+ font-size: 13px;
83
+ }
84
+
85
+ :deep(.v-list-item-subtitle) {
86
+ font-size: 12px;
87
+ }
88
+ </style>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <div :style="maskStyles">
3
+ <div :style="backgroundStyles" />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed } from "vue";
9
+
10
+ interface Props {
11
+ data: string;
12
+ color: string;
13
+ size?: number;
14
+ }
15
+
16
+ const props = withDefaults(defineProps<Props>(), {
17
+ size: 12
18
+ });
19
+
20
+ const sizePx = computed(() => {
21
+ return `${props.size}px`;
22
+ });
23
+
24
+ const maskStyles = computed(() => {
25
+ const src = `data:image/png;base64, ${props.data}`;
26
+ const px = sizePx.value;
27
+ return {
28
+ 'display': 'inline-block',
29
+ 'mask-size': `${px} ${px}`,
30
+ 'mask-image': `url('${src}')`,
31
+ 'width': px,
32
+ 'height': px,
33
+ };
34
+ })
35
+
36
+ const backgroundStyles = computed(() => {
37
+ const px = sizePx.value;
38
+ return {
39
+ 'background-color': props.color,
40
+ 'width': px,
41
+ 'height': px,
42
+ };
43
+ })
44
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <div :style="styles" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { computed } from 'vue';
7
+
8
+ interface Props {
9
+ color: string;
10
+ size?: number;
11
+ }
12
+
13
+ const props = withDefaults(defineProps<Props>(), {
14
+ size: 12
15
+ });
16
+
17
+ const sizePx = computed(() => {
18
+ return `${props.size}px`;
19
+ });
20
+
21
+ const styles = computed(() => {
22
+ const px = sizePx.value;
23
+ return {
24
+ 'display': 'inline-block',
25
+ 'background-color': props.color,
26
+ 'border': '1px #333333 solid',
27
+ 'width': px,
28
+ 'height': px,
29
+ };
30
+ });
31
+ </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <div>
3
+ <slot name="prepend">
4
+ <v-icon
5
+ class="mr-2 material-icons-filled"
6
+ size="16"
7
+ :icon="icon"
8
+ :color="color"
9
+ />
10
+ </slot>
11
+ <span class="label text-truncate">{{ label }}</span>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ interface Props {
17
+ icon?: string;
18
+ color?: string;
19
+ label: string;
20
+ }
21
+
22
+ defineProps<Props>();
23
+ </script>
24
+
25
+ <style scoped lang="css">
26
+ .label {
27
+ font-size: 12px;
28
+ vertical-align: text-top;
29
+ }
30
+ </style>
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <v-text-field
3
+ v-model:model-value="value"
4
+ density="compact"
5
+ hide-details
6
+ max="100"
7
+ min="0"
8
+ suffix="%"
9
+ type="number"
10
+ variant="outlined"
11
+ @input="onInputOpacity"
12
+ />
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { clamp } from '@/functions/clamp';
17
+ import { computed, ref } from 'vue';
18
+
19
+ interface Props {
20
+ modelValue?: number;
21
+ }
22
+
23
+ type Emits = {
24
+ 'update:modelValue': [number];
25
+ };
26
+
27
+ const props = withDefaults(defineProps<Props>(), {
28
+ modelValue: 0
29
+ });
30
+
31
+ const emit = defineEmits<Emits>();
32
+
33
+ const value_ = ref<number>(props.modelValue);
34
+
35
+ const value = computed({
36
+ get(): number {
37
+ return value_.value;
38
+ },
39
+ set(val: number): void {
40
+ value_.value = clamp(val, 0, 100);
41
+ emit('update:modelValue', value_.value);
42
+ }
43
+ });
44
+
45
+ function onInputOpacity(event: InputEvent): void {
46
+ const input = event.target as HTMLInputElement;
47
+ const value = input.value ? parseInt(input.value) : 0;
48
+ input.value = clamp(value, parseInt(input.min), parseInt(input.max)).toString();
49
+ }
50
+ </script>
51
+
52
+ <style scoped lang="css">
53
+ :deep(.v-text-field__suffix) {
54
+ font-size: 12px;
55
+ color: rgba(255, 255, 255, 0.8);
56
+ padding: 4px 8px 4px 2px;
57
+ min-height: 0;
58
+ }
59
+
60
+ :deep(.v-field__input) {
61
+ font-size: 12px;
62
+ padding: 4px 0 4px 8px;
63
+ min-height: 0;
64
+ }
65
+ </style>
@@ -0,0 +1,25 @@
1
+ <template>
2
+ <v-btn size="x-small" :icon="icon" variant="text" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { computed } from 'vue';
7
+
8
+ interface Props {
9
+ isVisible: boolean;
10
+ }
11
+
12
+ const props = withDefaults(defineProps<Props>(), {
13
+ isVisible: true
14
+ });
15
+
16
+ const icon = computed(() => {
17
+ return props.isVisible ? 'visibility' : 'visibility_off';
18
+ });
19
+ </script>
20
+
21
+ <style scoped lang="css">
22
+ :deep(.v-icon) {
23
+ font-size: 20px;
24
+ }
25
+ </style>
@@ -0,0 +1,10 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import MaskIcon from '@/components/views/shared/MaskIcon.vue';
3
+
4
+ describe('MaskIcon tests', () => {
5
+ it('should mount', () => {
6
+ const props = { data: '0', color: 'white' };
7
+ const wrapper = mount(MaskIcon, { props });
8
+ expect(wrapper).toBeTruthy();
9
+ });
10
+ });
@@ -0,0 +1,10 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import ObjectColor from '@/components/views/shared/ObjectColor.vue';
3
+
4
+ describe('ObjectColor tests', () => {
5
+ it('should mount', () => {
6
+ const props = { color: 'red' };
7
+ const wrapper = mount(ObjectColor, { props });
8
+ expect(wrapper).toBeTruthy();
9
+ });
10
+ });
@@ -0,0 +1,10 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import ObjectLabel from '@/components/views/shared/ObjectLabel.vue';
3
+
4
+ describe('ObjectLabel tests', () => {
5
+ it('should mount', () => {
6
+ const props = { label: 'test' };
7
+ const wrapper = mount(ObjectLabel, { props });
8
+ expect(wrapper).toBeTruthy();
9
+ });
10
+ });
@@ -0,0 +1,24 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import Opacity from '@/components/views/shared/Opacity.vue';
3
+ import { VTextField } from 'vuetify/components';
4
+
5
+ describe('Opacity tests', () => {
6
+ it('should mount', () => {
7
+ const props = { modelValue: 50 };
8
+ const wrapper = mount(Opacity, { props });
9
+ expect(wrapper).toBeTruthy();
10
+ });
11
+
12
+ it('should set value', async () => {
13
+ const wrapper = mount(Opacity);
14
+ await wrapper.findComponent(VTextField).setValue('100');
15
+ expect(wrapper.emitted('update:modelValue')).toEqual([[100]]);
16
+ });
17
+
18
+ it('should set native value', async () => {
19
+ const wrapper = mount(Opacity);
20
+ await wrapper.find('input').setValue('');
21
+ await wrapper.find('input').setValue('100');
22
+ expect(wrapper.emitted('update:modelValue')).toEqual([[0], [100]]);
23
+ });
24
+ });
@@ -0,0 +1,11 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import VisibilityBtn from '@/components/views/shared/VisibilityBtn.vue';
3
+
4
+ describe('VisibilityBtn tests', () => {
5
+ it('should mount', async () => {
6
+ const props = { isVisible: true };
7
+ const wrapper = mount(VisibilityBtn, { props });
8
+ await wrapper.setProps({ isVisible: false });
9
+ expect(wrapper).toBeTruthy();
10
+ });
11
+ });
@@ -0,0 +1,6 @@
1
+ export interface AnnotationTreeViewItemChildAction {
2
+ title: string;
3
+ description: string;
4
+ url: string;
5
+ isBtn: boolean;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { AnnotationTreeViewItemChildAction } from '@/components/views/types/annotation-tree-view-item-child-action';
2
+
3
+ export interface AnnotationTreeViewItemChild {
4
+ props: {
5
+ key: string;
6
+ value: string;
7
+ actions: AnnotationTreeViewItemChildAction[];
8
+ };
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Vector3 } from '@/types/vector3';
2
+ import { Colour } from '@/types/colour';
3
+ import { AnnotationTreeViewItemChild } from '@/components/views/types/annotation-tree-view-item-child';
4
+
5
+ export interface AnnotationTreeViewItem {
6
+ id: string;
7
+ title: string;
8
+ isVisible: boolean;
9
+ icon: string;
10
+ position: Vector3;
11
+ colour: Colour;
12
+ children: AnnotationTreeViewItemChild[];
13
+ }
@@ -0,0 +1,6 @@
1
+ export interface MarkupTreeViewItemChild {
2
+ props: {
3
+ key: string;
4
+ value: string;
5
+ };
6
+ }
@@ -0,0 +1,14 @@
1
+ import { Vector3 } from '@/types/vector3';
2
+ import { MarkupTreeViewItemChild } from '@/components/views/types/markup-tree-view-item-child';
3
+
4
+ export interface MarkupTreeViewItem {
5
+ id: string;
6
+ title: string;
7
+ description: string;
8
+ isVisible: boolean;
9
+ tooltip: string;
10
+ colour: string;
11
+ icon: string;
12
+ position: Vector3;
13
+ children: MarkupTreeViewItemChild[];
14
+ }
@@ -0,0 +1,13 @@
1
+ export interface McadObjectTreeViewItem {
2
+ id: string;
3
+ key: string;
4
+ title: string;
5
+ description: string;
6
+ isVisible: boolean;
7
+ colour: {
8
+ r: number;
9
+ g: number;
10
+ b: number;
11
+ a: number;
12
+ };
13
+ }
@@ -0,0 +1,35 @@
1
+ import { useAnnotations } from '@/composables/useAnnotations';
2
+ import { dataOverlayEvent, dataOverlayState } from '@/models/scanState';
3
+ import { DataOverlayDataFaker } from '@test/fakers/data-overlay-data.faker';
4
+ import { Interactiontype } from '@3cr/types-ts';
5
+ import { inflateInitialDataOverlayState } from '@/functions/modelHelper';
6
+
7
+ describe('useAnnotations tests', () => {
8
+ it('should have no annotations', () => {
9
+ const { annotations, hasAnnotations } = useAnnotations();
10
+ expect(annotations.value.length).toBe(0);
11
+ expect(hasAnnotations.value).toBeFalsy();
12
+ });
13
+
14
+ it('should have annotations', () => {
15
+ const dataOverlay = inflateInitialDataOverlayState();
16
+ dataOverlay.DataOverlay.DataOverlay.push(DataOverlayDataFaker.annotationRaw());
17
+ dataOverlayState.value = dataOverlay;
18
+
19
+ const { annotations } = useAnnotations();
20
+ expect(annotations.value.length).toBe(1);
21
+ expect(typeof annotations.value[0].Data).not.toBe('string');
22
+ });
23
+
24
+ it('should have null event', () => {
25
+ const { annotationEvent } = useAnnotations();
26
+ expect(annotationEvent.value).toBeNull();
27
+ });
28
+
29
+ it('should have non-null event', () => {
30
+ dataOverlayEvent.value = DataOverlayDataFaker.annotationEventRaw(Interactiontype.HOVER_START);
31
+ const { annotationEvent } = useAnnotations();
32
+ expect(annotationEvent.value).not.toBeNull();
33
+ expect(typeof annotationEvent.value?.DataOverlay).not.toBe('string');
34
+ });
35
+ });
@@ -0,0 +1,32 @@
1
+ import { defineComponent, ref, PropType, nextTick } from 'vue';
2
+ import { useEventListener } from '@/composables/useEventListener';
3
+ import { mount } from '@vue/test-utils';
4
+
5
+ describe('useEventListener tests', () => {
6
+ it('should attach event listener', async () => {
7
+ const component = defineComponent({
8
+ template: '<div></div>',
9
+ props: {
10
+ callback: {
11
+ type: Function as PropType<(e: Event) => void>,
12
+ required: true
13
+ }
14
+ },
15
+ setup(props, context) {
16
+ const target = ref<EventTarget>(document);
17
+ useEventListener(target, 'click', props.callback);
18
+ const swap = () => (target.value = document.body);
19
+ context.expose({ swap });
20
+ }
21
+ });
22
+
23
+ const props = { callback: vi.fn() };
24
+ const wrapper = mount(component, { props });
25
+ document.dispatchEvent(new MouseEvent('click'));
26
+ (wrapper.vm as any).swap();
27
+ await nextTick();
28
+ document.body.dispatchEvent(new MouseEvent('click'));
29
+ expect(props.callback).toHaveBeenCalledTimes(2);
30
+ wrapper.unmount();
31
+ });
32
+ });