dbf-mirador 4.2.3

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 (384) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +133 -0
  3. package/dist/CommentSharp-B0J_-jEq.js +325 -0
  4. package/dist/CommentSharp-B0J_-jEq.js.map +1 -0
  5. package/dist/FailedImageContext-aQXnWSHN.js +318 -0
  6. package/dist/FailedImageContext-aQXnWSHN.js.map +1 -0
  7. package/dist/PluginHook-CFw_6P5c.js +54 -0
  8. package/dist/PluginHook-CFw_6P5c.js.map +1 -0
  9. package/dist/WindowCanvasNavigationControls-CUX723BQ.js +242 -0
  10. package/dist/WindowCanvasNavigationControls-CUX723BQ.js.map +1 -0
  11. package/dist/action-types-DjIbTE-A.js +74 -0
  12. package/dist/action-types-DjIbTE-A.js.map +1 -0
  13. package/dist/canvas-C8oHvXFN.js +41 -0
  14. package/dist/canvas-C8oHvXFN.js.map +1 -0
  15. package/dist/canvases-gRqhr-IH.js +3154 -0
  16. package/dist/canvases-gRqhr-IH.js.map +1 -0
  17. package/dist/createSvgIcon-Cwt8YPfm.js +2 -0
  18. package/dist/getters-COus7Mvg.js +2066 -0
  19. package/dist/getters-COus7Mvg.js.map +1 -0
  20. package/dist/index.module-CbBRf_R8.js +403 -0
  21. package/dist/index.module-CbBRf_R8.js.map +1 -0
  22. package/dist/mirador.es.js +39600 -0
  23. package/dist/mirador.es.js.map +1 -0
  24. package/dist/mirador.min.js +334 -0
  25. package/dist/mirador.min.js.map +1 -0
  26. package/dist/react-error-boundary.esm-B_pT-oCS.js +67 -0
  27. package/dist/react-error-boundary.esm-B_pT-oCS.js.map +1 -0
  28. package/dist/visuallyHidden-DmYvwNdU.js +98 -0
  29. package/dist/visuallyHidden-DmYvwNdU.js.map +1 -0
  30. package/dist/window-zelwU7wz.js +138 -0
  31. package/dist/window-zelwU7wz.js.map +1 -0
  32. package/package.json +138 -0
  33. package/src/components/AccessTokenSender.jsx +34 -0
  34. package/src/components/AnnotationSettings.jsx +31 -0
  35. package/src/components/AnnotationsOverlay.jsx +328 -0
  36. package/src/components/App.jsx +34 -0
  37. package/src/components/AppProviders.jsx +129 -0
  38. package/src/components/AttributionPanel.jsx +78 -0
  39. package/src/components/AudioViewer.jsx +39 -0
  40. package/src/components/BackgroundPluginArea.jsx +9 -0
  41. package/src/components/Branding.jsx +33 -0
  42. package/src/components/CanvasAnnotations.jsx +125 -0
  43. package/src/components/CanvasInfo.jsx +46 -0
  44. package/src/components/CanvasLayers.jsx +367 -0
  45. package/src/components/ChangeThemeDialog.jsx +65 -0
  46. package/src/components/CollapsibleSection.jsx +53 -0
  47. package/src/components/CollectionDialog.jsx +236 -0
  48. package/src/components/CollectionInfo.jsx +48 -0
  49. package/src/components/CompanionArea.jsx +140 -0
  50. package/src/components/CompanionWindow.jsx +228 -0
  51. package/src/components/CompanionWindowFactory.jsx +38 -0
  52. package/src/components/CompanionWindowSection.jsx +11 -0
  53. package/src/components/CustomPanel.jsx +22 -0
  54. package/src/components/ErrorContent.jsx +65 -0
  55. package/src/components/ErrorDialog.jsx +47 -0
  56. package/src/components/FullScreenButton.jsx +47 -0
  57. package/src/components/GalleryView.jsx +36 -0
  58. package/src/components/GalleryViewThumbnail.jsx +160 -0
  59. package/src/components/IIIFAuthentication.jsx +144 -0
  60. package/src/components/IIIFDropTarget.jsx +168 -0
  61. package/src/components/IIIFIFrameCommunication.jsx +45 -0
  62. package/src/components/IIIFResourceLabel.jsx +26 -0
  63. package/src/components/IIIFThumbnail.jsx +214 -0
  64. package/src/components/ImageFailureMessage.jsx +42 -0
  65. package/src/components/LabelValueMetadata.jsx +46 -0
  66. package/src/components/LanguageSettings.jsx +46 -0
  67. package/src/components/LayersPanel.jsx +24 -0
  68. package/src/components/LocalePicker.jsx +56 -0
  69. package/src/components/ManifestForm.jsx +79 -0
  70. package/src/components/ManifestInfo.jsx +67 -0
  71. package/src/components/ManifestListItem.jsx +209 -0
  72. package/src/components/ManifestListItemError.jsx +53 -0
  73. package/src/components/ManifestRelatedLinks.jsx +154 -0
  74. package/src/components/MinimalWindow.jsx +104 -0
  75. package/src/components/MiradorMenuButton.jsx +71 -0
  76. package/src/components/MosaicRenderPreview.jsx +16 -0
  77. package/src/components/NestedMenu.jsx +42 -0
  78. package/src/components/NewBrowserWindow.jsx +34 -0
  79. package/src/components/OpenSeadragonComponent.jsx +258 -0
  80. package/src/components/OpenSeadragonTileSource.jsx +105 -0
  81. package/src/components/OpenSeadragonViewer.jsx +161 -0
  82. package/src/components/PluginHook.jsx +27 -0
  83. package/src/components/PrimaryWindow.jsx +115 -0
  84. package/src/components/SanitizedHtml.jsx +37 -0
  85. package/src/components/ScrollIndicatedDialogContent.jsx +60 -0
  86. package/src/components/ScrollTo.jsx +61 -0
  87. package/src/components/SearchHit.jsx +220 -0
  88. package/src/components/SearchPanel.jsx +80 -0
  89. package/src/components/SearchPanelControls.jsx +174 -0
  90. package/src/components/SearchPanelNavigation.jsx +84 -0
  91. package/src/components/SearchResults.jsx +138 -0
  92. package/src/components/SelectCollection.jsx +44 -0
  93. package/src/components/SidebarIndexItem.jsx +11 -0
  94. package/src/components/SidebarIndexList.jsx +73 -0
  95. package/src/components/SidebarIndexTableOfContents.jsx +170 -0
  96. package/src/components/SidebarIndexThumbnail.jsx +22 -0
  97. package/src/components/TextViewer.jsx +37 -0
  98. package/src/components/ThumbnailCanvasGrouping.jsx +122 -0
  99. package/src/components/ThumbnailNavigation.jsx +231 -0
  100. package/src/components/VideoViewer.jsx +35 -0
  101. package/src/components/ViewerInfo.jsx +55 -0
  102. package/src/components/ViewerNavigation.jsx +72 -0
  103. package/src/components/Window.jsx +150 -0
  104. package/src/components/WindowAuthenticationBar.jsx +176 -0
  105. package/src/components/WindowCanvasNavigationControls.jsx +91 -0
  106. package/src/components/WindowList.jsx +71 -0
  107. package/src/components/WindowListButton.jsx +57 -0
  108. package/src/components/WindowSideBar.jsx +48 -0
  109. package/src/components/WindowSideBarAnnotationsPanel.jsx +51 -0
  110. package/src/components/WindowSideBarButtons.jsx +151 -0
  111. package/src/components/WindowSideBarCanvasPanel.jsx +165 -0
  112. package/src/components/WindowSideBarCollectionPanel.jsx +179 -0
  113. package/src/components/WindowSideBarInfoPanel.jsx +67 -0
  114. package/src/components/WindowThumbnailSettings.jsx +130 -0
  115. package/src/components/WindowTopBar.jsx +125 -0
  116. package/src/components/WindowTopBarPluginArea.jsx +8 -0
  117. package/src/components/WindowTopBarPluginMenu.jsx +78 -0
  118. package/src/components/WindowTopBarTitle.jsx +73 -0
  119. package/src/components/WindowTopMenu.jsx +81 -0
  120. package/src/components/WindowTopMenuButton.jsx +49 -0
  121. package/src/components/WindowViewSettings.jsx +95 -0
  122. package/src/components/WindowViewer.jsx +26 -0
  123. package/src/components/Workspace.jsx +124 -0
  124. package/src/components/WorkspaceAdd.jsx +221 -0
  125. package/src/components/WorkspaceAddButton.jsx +73 -0
  126. package/src/components/WorkspaceArea.jsx +66 -0
  127. package/src/components/WorkspaceControlPanel.jsx +85 -0
  128. package/src/components/WorkspaceControlPanelButtons.jsx +20 -0
  129. package/src/components/WorkspaceDialog.jsx +11 -0
  130. package/src/components/WorkspaceElastic.jsx +88 -0
  131. package/src/components/WorkspaceElasticWindow.jsx +79 -0
  132. package/src/components/WorkspaceExport.jsx +99 -0
  133. package/src/components/WorkspaceImport.jsx +89 -0
  134. package/src/components/WorkspaceMenu.jsx +126 -0
  135. package/src/components/WorkspaceMenuButton.jsx +42 -0
  136. package/src/components/WorkspaceMosaic.jsx +149 -0
  137. package/src/components/WorkspaceOptionsButton.jsx +35 -0
  138. package/src/components/WorkspaceOptionsMenu.jsx +112 -0
  139. package/src/components/WorkspaceSelectionDialog.jsx +165 -0
  140. package/src/components/ZoomControls.jsx +57 -0
  141. package/src/components/icons/BookViewIcon.jsx +14 -0
  142. package/src/components/icons/CanvasIndexIcon.jsx +14 -0
  143. package/src/components/icons/GalleryViewIcon.jsx +17 -0
  144. package/src/components/icons/MiradorIcon.jsx +14 -0
  145. package/src/components/icons/RestoreZoomIcon.jsx +15 -0
  146. package/src/components/icons/ThumbnailNavigationBottomIcon.jsx +15 -0
  147. package/src/components/icons/ThumbnailNavigationRightIcon.jsx +16 -0
  148. package/src/components/icons/WindowMaxIcon.jsx +15 -0
  149. package/src/components/icons/WindowMinIcon.jsx +15 -0
  150. package/src/components/icons/WindowOptionsIcon.jsx +16 -0
  151. package/src/components/icons/WorkspaceTypeElasticIcon.jsx +157 -0
  152. package/src/components/icons/WorkspaceTypeMosaicIcon.jsx +162 -0
  153. package/src/components/icons/index.js +27 -0
  154. package/src/components/index.js +108 -0
  155. package/src/config/css-ns.js +10 -0
  156. package/src/config/index.js +2 -0
  157. package/src/config/settings.js +607 -0
  158. package/src/containers/AnnotationSettings.js +27 -0
  159. package/src/containers/AnnotationsOverlay.js +51 -0
  160. package/src/containers/AppProviders.js +20 -0
  161. package/src/containers/AttributionPanel.js +20 -0
  162. package/src/containers/AudioViewer.js +16 -0
  163. package/src/containers/BackgroundPluginArea.js +4 -0
  164. package/src/containers/Branding.js +4 -0
  165. package/src/containers/CanvasAnnotations.js +32 -0
  166. package/src/containers/CanvasInfo.js +20 -0
  167. package/src/containers/CanvasLayers.js +25 -0
  168. package/src/containers/ChangeThemeDialog.js +29 -0
  169. package/src/containers/CollapsibleSection.js +3 -0
  170. package/src/containers/CollectionDialog.js +48 -0
  171. package/src/containers/CollectionInfo.js +29 -0
  172. package/src/containers/CompanionArea.js +22 -0
  173. package/src/containers/CompanionWindow.js +40 -0
  174. package/src/containers/CompanionWindowFactory.js +23 -0
  175. package/src/containers/CustomPanel.js +13 -0
  176. package/src/containers/ErrorContent.js +20 -0
  177. package/src/containers/ErrorDialog.js +28 -0
  178. package/src/containers/FullScreenButton.js +22 -0
  179. package/src/containers/GalleryView.js +23 -0
  180. package/src/containers/GalleryViewThumbnail.js +51 -0
  181. package/src/containers/IIIFAuthentication.js +86 -0
  182. package/src/containers/IIIFThumbnail.js +17 -0
  183. package/src/containers/LabelValueMetadata.js +14 -0
  184. package/src/containers/LanguageSettings.js +26 -0
  185. package/src/containers/LayersPanel.js +16 -0
  186. package/src/containers/LocalePicker.js +3 -0
  187. package/src/containers/ManifestForm.js +16 -0
  188. package/src/containers/ManifestInfo.js +29 -0
  189. package/src/containers/ManifestListItem.js +52 -0
  190. package/src/containers/ManifestListItemError.js +15 -0
  191. package/src/containers/ManifestRelatedLinks.js +28 -0
  192. package/src/containers/MinimalWindow.js +25 -0
  193. package/src/containers/MiradorMenuButton.js +7 -0
  194. package/src/containers/MosaicRenderPreview.js +14 -0
  195. package/src/containers/OpenSeadragonViewer.js +59 -0
  196. package/src/containers/PrimaryWindow.js +27 -0
  197. package/src/containers/SanitizedHtml.js +3 -0
  198. package/src/containers/ScrollIndicatedDialogContent.js +3 -0
  199. package/src/containers/SearchHit.js +71 -0
  200. package/src/containers/SearchPanel.js +23 -0
  201. package/src/containers/SearchPanelControls.js +36 -0
  202. package/src/containers/SearchPanelNavigation.js +39 -0
  203. package/src/containers/SearchResults.js +38 -0
  204. package/src/containers/SelectCollection.js +24 -0
  205. package/src/containers/SidebarIndexItem.js +8 -0
  206. package/src/containers/SidebarIndexList.js +28 -0
  207. package/src/containers/SidebarIndexTableOfContents.js +31 -0
  208. package/src/containers/SidebarIndexThumbnail.js +18 -0
  209. package/src/containers/TextViewer.js +19 -0
  210. package/src/containers/ThumbnailCanvasGrouping.js +29 -0
  211. package/src/containers/ThumbnailNavigation.js +48 -0
  212. package/src/containers/VideoViewer.js +16 -0
  213. package/src/containers/ViewerInfo.js +30 -0
  214. package/src/containers/ViewerNavigation.js +31 -0
  215. package/src/containers/Window.js +45 -0
  216. package/src/containers/WindowAuthenticationBar.js +7 -0
  217. package/src/containers/WindowCanvasNavigationControls.js +15 -0
  218. package/src/containers/WindowList.js +30 -0
  219. package/src/containers/WindowListButton.js +15 -0
  220. package/src/containers/WindowSideBar.js +20 -0
  221. package/src/containers/WindowSideBarAnnotationsPanel.js +23 -0
  222. package/src/containers/WindowSideBarButtons.js +75 -0
  223. package/src/containers/WindowSideBarCanvasPanel.js +50 -0
  224. package/src/containers/WindowSideBarCollectionPanel.js +48 -0
  225. package/src/containers/WindowSideBarInfoPanel.js +35 -0
  226. package/src/containers/WindowThumbnailSettings.js +31 -0
  227. package/src/containers/WindowTopBar.js +39 -0
  228. package/src/containers/WindowTopBarPluginArea.js +8 -0
  229. package/src/containers/WindowTopBarPluginMenu.js +7 -0
  230. package/src/containers/WindowTopBarTitle.js +17 -0
  231. package/src/containers/WindowTopMenu.js +28 -0
  232. package/src/containers/WindowTopMenuButton.js +7 -0
  233. package/src/containers/WindowViewSettings.js +30 -0
  234. package/src/containers/WindowViewer.js +10 -0
  235. package/src/containers/Workspace.js +36 -0
  236. package/src/containers/WorkspaceAdd.js +27 -0
  237. package/src/containers/WorkspaceAddButton.js +30 -0
  238. package/src/containers/WorkspaceArea.js +21 -0
  239. package/src/containers/WorkspaceControlPanel.js +10 -0
  240. package/src/containers/WorkspaceControlPanelButtons.js +7 -0
  241. package/src/containers/WorkspaceElastic.js +41 -0
  242. package/src/containers/WorkspaceElasticWindow.js +36 -0
  243. package/src/containers/WorkspaceExport.js +18 -0
  244. package/src/containers/WorkspaceImport.js +19 -0
  245. package/src/containers/WorkspaceMenu.js +30 -0
  246. package/src/containers/WorkspaceMenuButton.js +10 -0
  247. package/src/containers/WorkspaceMosaic.js +32 -0
  248. package/src/containers/WorkspaceOptionsButton.js +7 -0
  249. package/src/containers/WorkspaceOptionsMenu.js +3 -0
  250. package/src/containers/WorkspaceSelectionDialog.js +26 -0
  251. package/src/containers/ZoomControls.js +26 -0
  252. package/src/containers/index.js +94 -0
  253. package/src/contexts/FailedImageContext.js +8 -0
  254. package/src/contexts/FailedImageProvider.jsx +34 -0
  255. package/src/contexts/FullScreenContext.js +5 -0
  256. package/src/contexts/LocaleContext.js +5 -0
  257. package/src/contexts/OpenSeadragonViewerContext.js +5 -0
  258. package/src/contexts/WorkspaceContext.js +5 -0
  259. package/src/contexts/index.js +4 -0
  260. package/src/extend/PluginContext.js +5 -0
  261. package/src/extend/PluginProvider.jsx +22 -0
  262. package/src/extend/index.js +9 -0
  263. package/src/extend/pluginMapping.js +44 -0
  264. package/src/extend/pluginPreprocessing.js +45 -0
  265. package/src/extend/pluginValidation.js +58 -0
  266. package/src/extend/usePlugins.js +13 -0
  267. package/src/extend/withPlugins.jsx +46 -0
  268. package/src/hooks/index.js +4 -0
  269. package/src/hooks/useCanvasWorldService.js +10 -0
  270. package/src/hooks/useThumbnailService.js +8 -0
  271. package/src/i18n.js +71 -0
  272. package/src/index.js +18 -0
  273. package/src/init.js +20 -0
  274. package/src/lib/AnnotationFactory.js +23 -0
  275. package/src/lib/AnnotationItem.js +123 -0
  276. package/src/lib/AnnotationList.js +31 -0
  277. package/src/lib/AnnotationPage.js +41 -0
  278. package/src/lib/AnnotationResource.js +122 -0
  279. package/src/lib/CanvasAnnotationDisplay.js +148 -0
  280. package/src/lib/CanvasGroupings.js +55 -0
  281. package/src/lib/CanvasWorld.js +214 -0
  282. package/src/lib/CompanionWindowRegistry.js +23 -0
  283. package/src/lib/FullScreenHandle.jsx +76 -0
  284. package/src/lib/MiradorCanvas.js +211 -0
  285. package/src/lib/MiradorManifest.js +44 -0
  286. package/src/lib/MiradorViewer.jsx +53 -0
  287. package/src/lib/MosaicLayout.js +77 -0
  288. package/src/lib/OpenSeadragonCanvasOverlay.js +114 -0
  289. package/src/lib/ThumbnailFactory.js +310 -0
  290. package/src/lib/TruncatedHit.js +34 -0
  291. package/src/lib/asArray.js +11 -0
  292. package/src/lib/htmlRules.js +28 -0
  293. package/src/lib/iiif.js +12 -0
  294. package/src/lib/index.js +23 -0
  295. package/src/lib/readImageMetadata.js +21 -0
  296. package/src/lib/svgShapesToPath.js +49 -0
  297. package/src/locales/README.md +60 -0
  298. package/src/locales/ar/translation.json +141 -0
  299. package/src/locales/bg/translation.json +164 -0
  300. package/src/locales/de/translation.json +169 -0
  301. package/src/locales/en/translation.json +170 -0
  302. package/src/locales/et/translation.json +164 -0
  303. package/src/locales/fa/translation.json +164 -0
  304. package/src/locales/fr/translation.json +158 -0
  305. package/src/locales/hr/translation.json +164 -0
  306. package/src/locales/hu/translation.json +166 -0
  307. package/src/locales/it/translation.json +162 -0
  308. package/src/locales/ja/translation.json +156 -0
  309. package/src/locales/kr/translation.json +162 -0
  310. package/src/locales/lt/translation.json +153 -0
  311. package/src/locales/nbNo/translation.json +162 -0
  312. package/src/locales/nl/translation.json +139 -0
  313. package/src/locales/pl/translation.json +162 -0
  314. package/src/locales/ptBr/translation.json +133 -0
  315. package/src/locales/sr/translation.json +155 -0
  316. package/src/locales/sv/translation.json +157 -0
  317. package/src/locales/ta/translation.json +167 -0
  318. package/src/locales/vi/translation.json +156 -0
  319. package/src/locales/zhCn/translation.json +163 -0
  320. package/src/locales/zhTw/translation.json +163 -0
  321. package/src/plugins/OSDReferences.js +15 -0
  322. package/src/plugins/index.js +1 -0
  323. package/src/state/actions/action-types.js +76 -0
  324. package/src/state/actions/annotation.js +123 -0
  325. package/src/state/actions/auth.js +109 -0
  326. package/src/state/actions/canvas.js +65 -0
  327. package/src/state/actions/catalog.js +22 -0
  328. package/src/state/actions/companionWindow.js +107 -0
  329. package/src/state/actions/config.js +49 -0
  330. package/src/state/actions/elasticLayout.js +10 -0
  331. package/src/state/actions/errors.js +22 -0
  332. package/src/state/actions/index.js +19 -0
  333. package/src/state/actions/infoResponse.js +90 -0
  334. package/src/state/actions/layers.js +14 -0
  335. package/src/state/actions/manifest.js +65 -0
  336. package/src/state/actions/search.js +97 -0
  337. package/src/state/actions/window.js +209 -0
  338. package/src/state/actions/workspace.js +84 -0
  339. package/src/state/createPluggableStore.js +24 -0
  340. package/src/state/createStore.js +33 -0
  341. package/src/state/index.js +21 -0
  342. package/src/state/reducers/accessTokens.js +59 -0
  343. package/src/state/reducers/annotations.js +48 -0
  344. package/src/state/reducers/auth.js +43 -0
  345. package/src/state/reducers/catalog.js +30 -0
  346. package/src/state/reducers/companionWindows.js +49 -0
  347. package/src/state/reducers/config.js +39 -0
  348. package/src/state/reducers/elasticLayout.js +29 -0
  349. package/src/state/reducers/errors.js +51 -0
  350. package/src/state/reducers/index.js +15 -0
  351. package/src/state/reducers/infoResponses.js +61 -0
  352. package/src/state/reducers/layers.js +23 -0
  353. package/src/state/reducers/manifests.js +52 -0
  354. package/src/state/reducers/rootReducer.js +44 -0
  355. package/src/state/reducers/search.js +145 -0
  356. package/src/state/reducers/utils.js +45 -0
  357. package/src/state/reducers/viewers.js +42 -0
  358. package/src/state/reducers/windows.js +185 -0
  359. package/src/state/reducers/workspace.js +111 -0
  360. package/src/state/sagas/annotations.js +48 -0
  361. package/src/state/sagas/app.js +56 -0
  362. package/src/state/sagas/auth.js +151 -0
  363. package/src/state/sagas/iiif.js +233 -0
  364. package/src/state/sagas/index.js +30 -0
  365. package/src/state/sagas/windows.js +293 -0
  366. package/src/state/selectors/annotations.js +138 -0
  367. package/src/state/selectors/auth.js +100 -0
  368. package/src/state/selectors/canvases.js +260 -0
  369. package/src/state/selectors/companionWindows.js +182 -0
  370. package/src/state/selectors/config.js +100 -0
  371. package/src/state/selectors/getters.js +90 -0
  372. package/src/state/selectors/index.js +17 -0
  373. package/src/state/selectors/layers.js +79 -0
  374. package/src/state/selectors/manifests.js +433 -0
  375. package/src/state/selectors/ranges.js +147 -0
  376. package/src/state/selectors/searches.js +249 -0
  377. package/src/state/selectors/sequences.js +134 -0
  378. package/src/state/selectors/thumbnails.js +28 -0
  379. package/src/state/selectors/utils.js +18 -0
  380. package/src/state/selectors/viewer.js +19 -0
  381. package/src/state/selectors/windows.js +98 -0
  382. package/src/state/selectors/workspace.js +52 -0
  383. package/src/state/selectors/wrappers.js +15 -0
  384. package/src/styles/react-mosaic-component.js +288 -0
@@ -0,0 +1,174 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '@mui/material/styles';
4
+ import deburr from 'lodash/deburr';
5
+ import isObject from 'lodash/isObject';
6
+ import { useDebouncedCallback } from 'use-debounce';
7
+ import Autocomplete from '@mui/material/Autocomplete';
8
+ import CircularProgress from '@mui/material/CircularProgress';
9
+ import TextField from '@mui/material/TextField';
10
+ import InputAdornment from '@mui/material/InputAdornment';
11
+ import SearchIcon from '@mui/icons-material/SearchSharp';
12
+ import { useTranslation } from 'react-i18next';
13
+ import MiradorMenuButton from '../containers/MiradorMenuButton';
14
+ import SearchPanelNavigation from '../containers/SearchPanelNavigation';
15
+
16
+ const StyledForm = styled('form', { name: 'SearchPanelControls', slot: 'form' })(({ theme }) => ({
17
+ paddingBottom: theme.spacing(1),
18
+ paddingRight: theme.spacing(1.5),
19
+ width: '100%',
20
+ }));
21
+
22
+ /** Sometimes an autocomplete match can be a simple string, other times an object
23
+ with a `match` property, this function abstracts that away */
24
+ const getMatch = (option) => (isObject(option) ? option.match : option);
25
+
26
+ /** */
27
+ export function SearchPanelControls({
28
+ autocompleteService = undefined,
29
+ companionWindowId,
30
+ fetchSearch,
31
+ query = '',
32
+ searchIsFetching = false,
33
+ searchService,
34
+ windowId,
35
+ }) {
36
+ const { t } = useTranslation();
37
+ const [input, setInput] = useState(query);
38
+ const [search, setSearch] = useState(query);
39
+ const [suggestions, setSuggestions] = useState([]);
40
+
41
+ useEffect(() => {
42
+ setInput(query);
43
+ setSearch(query);
44
+ setSuggestions([]);
45
+ }, [query]);
46
+
47
+ useEffect(() => {
48
+ if (search && search !== '' && searchService) {
49
+ fetchSearch(windowId, companionWindowId, `${searchService.id}?${new URLSearchParams({ q: search })}`, search);
50
+ }
51
+ }, [search, searchService, companionWindowId, fetchSearch, windowId]);
52
+
53
+ /** */
54
+ const handleChange = (event, value, reason) => {
55
+ // For some reason the value gets reset to an empty value from the
56
+ // useAutocomplete hook sometimes, we just ignore these cases
57
+ if (reason === 'reset' && !value) {
58
+ return;
59
+ }
60
+ setInput(value);
61
+ setSuggestions([]);
62
+
63
+ if (value) {
64
+ fetchAutocomplete(value);
65
+ }
66
+ };
67
+
68
+ /** */
69
+ const fetchAutocomplete = useDebouncedCallback(
70
+ useCallback(() => {
71
+ if (!autocompleteService) return;
72
+ if (!input) return;
73
+
74
+ fetch(`${autocompleteService.id}?${new URLSearchParams({ q: input })}`)
75
+ .then((response) => response.json())
76
+ .then(receiveAutocomplete);
77
+ }, [autocompleteService, input]),
78
+ 500,
79
+ );
80
+
81
+ /** */
82
+ const receiveAutocomplete = (json) => {
83
+ setSuggestions(json.terms);
84
+ };
85
+
86
+ /** */
87
+ const submitSearch = (event) => {
88
+ if (!input) return;
89
+
90
+ if (event) {
91
+ event.preventDefault();
92
+ }
93
+
94
+ setSearch(input);
95
+ };
96
+
97
+ /** */
98
+ const selectItem = (_event, selectedItem, _reason) => {
99
+ if (selectedItem && getMatch(selectedItem)) {
100
+ setSearch(getMatch(selectedItem));
101
+ }
102
+ };
103
+
104
+ const id = `search-${companionWindowId}`;
105
+ return (
106
+ <>
107
+ <StyledForm aria-label={t('searchTitle')} onSubmit={submitSearch}>
108
+ <Autocomplete
109
+ id={id}
110
+ inputValue={input}
111
+ options={suggestions}
112
+ getOptionLabel={getMatch}
113
+ isOptionEqualToValue={(option, value) =>
114
+ deburr(getMatch(option).trim()).toLowerCase() === deburr(getMatch(value).trim()).toLowerCase()
115
+ }
116
+ noOptionsText=""
117
+ onChange={selectItem}
118
+ onInputChange={handleChange}
119
+ freeSolo
120
+ disableClearable
121
+ renderInput={(params) => (
122
+ <TextField
123
+ {...params}
124
+ label={t('searchInputLabel')}
125
+ variant="standard"
126
+ slotProps={{
127
+ ...params.slotProps,
128
+
129
+ input: {
130
+ ...params.InputProps,
131
+ ...params.slotProps?.input,
132
+ endAdornment: (
133
+ <InputAdornment sx={{ position: 'relative' }} position="end">
134
+ <MiradorMenuButton aria-label={t('searchSubmitAria')} type="submit">
135
+ <SearchIcon />
136
+ </MiradorMenuButton>
137
+ {Boolean(searchIsFetching) && (
138
+ <CircularProgress
139
+ sx={{
140
+ left: '50%',
141
+ marginLeft: '-25px',
142
+ marginTop: '-25px',
143
+ position: 'absolute',
144
+ top: '50%',
145
+ }}
146
+ size={50}
147
+ />
148
+ )}
149
+ </InputAdornment>
150
+ ),
151
+ },
152
+ }}
153
+ />
154
+ )}
155
+ />
156
+ </StyledForm>
157
+ <SearchPanelNavigation windowId={windowId} companionWindowId={companionWindowId} />
158
+ </>
159
+ );
160
+ }
161
+
162
+ SearchPanelControls.propTypes = {
163
+ autocompleteService: PropTypes.shape({
164
+ id: PropTypes.string,
165
+ }),
166
+ companionWindowId: PropTypes.string.isRequired,
167
+ fetchSearch: PropTypes.func.isRequired,
168
+ query: PropTypes.string,
169
+ searchIsFetching: PropTypes.bool,
170
+ searchService: PropTypes.shape({
171
+ id: PropTypes.string,
172
+ }).isRequired,
173
+ windowId: PropTypes.string.isRequired,
174
+ };
@@ -0,0 +1,84 @@
1
+ import PropTypes from 'prop-types';
2
+ import ChevronLeftIcon from '@mui/icons-material/ChevronLeftSharp';
3
+ import ChevronRightIcon from '@mui/icons-material/ChevronRightSharp';
4
+ import Typography from '@mui/material/Typography';
5
+ import { useTranslation } from 'react-i18next';
6
+ import MiradorMenuButton from '../containers/MiradorMenuButton';
7
+
8
+ /**
9
+ * SearchPanelNavigation ~
10
+ */
11
+ export function SearchPanelNavigation({
12
+ numTotal = undefined,
13
+ searchHits = [],
14
+ selectedContentSearchAnnotation,
15
+ direction,
16
+ selectAnnotation,
17
+ }) {
18
+ const { t } = useTranslation();
19
+ /** */
20
+ const nextSearchResult = (currentHitIndex) => {
21
+ selectAnnotation(searchHits[currentHitIndex + 1].annotations[0]);
22
+ };
23
+
24
+ /** */
25
+ const previousSearchResult = (currentHitIndex) => {
26
+ selectAnnotation(searchHits[currentHitIndex - 1].annotations[0]);
27
+ };
28
+
29
+ /** */
30
+ const hasNextResult = (currentHitIndex) => {
31
+ if (searchHits.length === 0) return false;
32
+ if (currentHitIndex < searchHits.length - 1) return true;
33
+ return false;
34
+ };
35
+
36
+ /** */
37
+ const hasPreviousResult = (currentHitIndex) => {
38
+ if (searchHits.length === 0) return false;
39
+ if (currentHitIndex > 0) return true;
40
+ return false;
41
+ };
42
+
43
+ const iconStyle = direction === 'rtl' ? { transform: 'rotate(180deg)' } : {};
44
+
45
+ const currentHitIndex = searchHits.findIndex((val) => val.annotations.includes(selectedContentSearchAnnotation[0]));
46
+ let lengthText = searchHits.length;
47
+ if (searchHits.length < numTotal) {
48
+ lengthText += '+';
49
+ }
50
+
51
+ if (searchHits.length === 0) return null;
52
+
53
+ return (
54
+ <Typography variant="body2" align="center">
55
+ <MiradorMenuButton
56
+ aria-label={t('searchPreviousResult')}
57
+ disabled={!hasPreviousResult(currentHitIndex)}
58
+ onClick={() => previousSearchResult(currentHitIndex)}
59
+ >
60
+ <ChevronLeftIcon style={iconStyle} />
61
+ </MiradorMenuButton>
62
+ <span style={{ unicodeBidi: 'plaintext' }} role="status">
63
+ {t('pagination', { current: currentHitIndex + 1, total: lengthText })}
64
+ </span>
65
+ <MiradorMenuButton
66
+ aria-label={t('searchNextResult')}
67
+ disabled={!hasNextResult(currentHitIndex)}
68
+ onClick={() => nextSearchResult(currentHitIndex)}
69
+ >
70
+ <ChevronRightIcon style={iconStyle} />
71
+ </MiradorMenuButton>
72
+ </Typography>
73
+ );
74
+ }
75
+
76
+ SearchPanelNavigation.propTypes = {
77
+ direction: PropTypes.string.isRequired,
78
+ numTotal: PropTypes.number,
79
+ searchHits: PropTypes.arrayOf(PropTypes.object),
80
+ selectAnnotation: PropTypes.func.isRequired,
81
+ selectedContentSearchAnnotation: PropTypes.arrayOf(PropTypes.string).isRequired,
82
+ // eslint-disable-next-line react/no-unused-prop-types
83
+ windowId: PropTypes.string.isRequired,
84
+ };
@@ -0,0 +1,138 @@
1
+ import { useState, useCallback } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Button from '@mui/material/Button';
4
+ import List from '@mui/material/List';
5
+ import Typography from '@mui/material/Typography';
6
+ import BackIcon from '@mui/icons-material/ArrowBackSharp';
7
+ import { announce } from '@react-aria/live-announcer';
8
+ import { useTranslation } from 'react-i18next';
9
+ import SearchHit from '../containers/SearchHit';
10
+ import { ScrollTo } from './ScrollTo';
11
+
12
+ /**
13
+ * Return SearchHits for every hit in the response
14
+ * Return SearchHits for every annotation in the response if there are no hits
15
+ */
16
+ function SearchHitsAndAnnotations({
17
+ companionWindowId,
18
+ containerRef,
19
+ searchAnnotations,
20
+ searchHits,
21
+ windowId,
22
+ focused,
23
+ toggleFocus,
24
+ }) {
25
+ if (searchHits.length === 0 && searchAnnotations.length > 0) {
26
+ return searchAnnotations.map((anno, index) => (
27
+ <SearchHit
28
+ announcer={announce}
29
+ annotationId={anno.id}
30
+ companionWindowId={companionWindowId}
31
+ containerRef={containerRef}
32
+ key={anno.id}
33
+ focused={focused}
34
+ index={index}
35
+ total={searchAnnotations.length}
36
+ windowId={windowId}
37
+ showDetails={toggleFocus}
38
+ />
39
+ ));
40
+ }
41
+
42
+ return searchHits.map((hit, index) => (
43
+ <SearchHit
44
+ announcer={announce}
45
+ containerRef={containerRef}
46
+ companionWindowId={companionWindowId}
47
+ key={hit.annotations[0]}
48
+ focused={focused}
49
+ hit={hit}
50
+ index={index}
51
+ total={searchHits.length}
52
+ windowId={windowId}
53
+ showDetails={toggleFocus}
54
+ />
55
+ ));
56
+ }
57
+
58
+ /** */
59
+ export function SearchResults({
60
+ companionWindowId,
61
+ containerRef = undefined,
62
+ isFetching = false,
63
+ fetchSearch,
64
+ nextSearch = undefined,
65
+ query = undefined,
66
+ searchAnnotations = [],
67
+ searchHits = [],
68
+ searchNumTotal = undefined,
69
+ windowId,
70
+ }) {
71
+ const { t } = useTranslation();
72
+ const [focused, setFocused] = useState(false);
73
+
74
+ /** */
75
+ const toggleFocus = useCallback(() => {
76
+ setFocused(!focused);
77
+ }, [setFocused, focused]);
78
+
79
+ const noResultsState = query && !isFetching && searchHits.length === 0 && searchAnnotations.length === 0;
80
+
81
+ return (
82
+ <>
83
+ {focused && (
84
+ <ScrollTo containerRef={containerRef} offsetTop={96} scrollTo>
85
+ <Button onClick={toggleFocus} sx={{ textTransform: 'none' }} size="small">
86
+ <BackIcon />
87
+ {t('backToResults')}
88
+ </Button>
89
+ </ScrollTo>
90
+ )}
91
+ {noResultsState && (
92
+ <Typography
93
+ sx={{
94
+ padding: 2,
95
+ typography: 'h6',
96
+ }}
97
+ >
98
+ {t('searchNoResults')}
99
+ </Typography>
100
+ )}
101
+ <List disablePadding>
102
+ <SearchHitsAndAnnotations
103
+ companionWindowId={companionWindowId}
104
+ containerRef={containerRef}
105
+ searchAnnotations={searchAnnotations}
106
+ searchHits={searchHits}
107
+ windowId={windowId}
108
+ focused={focused}
109
+ toggleFocus={toggleFocus}
110
+ />
111
+ </List>
112
+ {nextSearch && (
113
+ <Button
114
+ sx={{ width: '100%' }}
115
+ color="secondary"
116
+ onClick={() => fetchSearch(windowId, companionWindowId, nextSearch, query)}
117
+ >
118
+ {t('moreResults')}
119
+ <br />
120
+ {`(${t('searchResultsRemaining', { numLeft: searchNumTotal - searchHits.length })})`}
121
+ </Button>
122
+ )}
123
+ </>
124
+ );
125
+ }
126
+
127
+ SearchResults.propTypes = {
128
+ companionWindowId: PropTypes.string.isRequired,
129
+ containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]),
130
+ fetchSearch: PropTypes.func.isRequired,
131
+ isFetching: PropTypes.bool,
132
+ nextSearch: PropTypes.string,
133
+ query: PropTypes.string,
134
+ searchAnnotations: PropTypes.arrayOf(PropTypes.object),
135
+ searchHits: PropTypes.arrayOf(PropTypes.object),
136
+ searchNumTotal: PropTypes.number,
137
+ windowId: PropTypes.string.isRequired,
138
+ };
@@ -0,0 +1,44 @@
1
+ import { useCallback } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Button from '@mui/material/Button';
4
+ import Grid from '@mui/material/Grid';
5
+ import Stack from '@mui/material/Stack';
6
+ import Typography from '@mui/material/Typography';
7
+ import ListSharpIcon from '@mui/icons-material/ListSharp';
8
+ import { useTranslation } from 'react-i18next';
9
+
10
+ /**
11
+ *
12
+ */
13
+ export function SelectCollection({ collectionPath = [], manifestId = null, showCollectionDialog, windowId = null }) {
14
+ const { t } = useTranslation();
15
+ const openCollectionDialog = useCallback(() => {
16
+ showCollectionDialog(manifestId, collectionPath.slice(0, -1), windowId);
17
+ }, [collectionPath, manifestId, showCollectionDialog, windowId]);
18
+
19
+ return (
20
+ <Grid container sx={{ alignContent: 'center', justifyContent: 'center', width: '100%' }}>
21
+ <Stack>
22
+ <Typography variant="h4" component="p" sx={{ mb: 2, textAlign: 'center' }}>
23
+ <em>{t('noItemSelected')}</em>
24
+ </Typography>
25
+ <Button
26
+ aria-label="show collection"
27
+ color="primary"
28
+ variant="contained"
29
+ onClick={openCollectionDialog}
30
+ startIcon={<ListSharpIcon />}
31
+ >
32
+ {t('showCollection')}
33
+ </Button>
34
+ </Stack>
35
+ </Grid>
36
+ );
37
+ }
38
+
39
+ SelectCollection.propTypes = {
40
+ collectionPath: PropTypes.arrayOf(PropTypes.string),
41
+ manifestId: PropTypes.string,
42
+ showCollectionDialog: PropTypes.func.isRequired,
43
+ windowId: PropTypes.string,
44
+ };
@@ -0,0 +1,11 @@
1
+ import PropTypes from 'prop-types';
2
+ import Typography from '@mui/material/Typography';
3
+
4
+ /** */
5
+ export function SidebarIndexItem({ label }) {
6
+ return <Typography variant="body1">{label}</Typography>;
7
+ }
8
+
9
+ SidebarIndexItem.propTypes = {
10
+ label: PropTypes.string.isRequired,
11
+ };
@@ -0,0 +1,73 @@
1
+ import { useMemo } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import MenuList from '@mui/material/MenuList';
4
+ import MenuItem from '@mui/material/MenuItem';
5
+ import { styled } from '@mui/material/styles';
6
+ import { ScrollTo } from './ScrollTo';
7
+ import MiradorCanvas from '../lib/MiradorCanvas';
8
+ import SidebarIndexItem from '../containers/SidebarIndexItem';
9
+ import SidebarIndexThumbnail from '../containers/SidebarIndexThumbnail';
10
+
11
+ const StyledItem = styled(MenuItem, { name: 'SidebarIndexList', slot: 'item' })(({ theme }) => ({
12
+ alignItems: 'flex-start',
13
+ gap: theme.spacing(1),
14
+ paddingLeft: theme.spacing(2),
15
+ paddingRight: theme.spacing(1),
16
+ position: 'initial',
17
+ whiteSpace: 'normal',
18
+ }));
19
+
20
+ /** */
21
+ function getIdAndLabelOfCanvases(canvases) {
22
+ return canvases.map((canvas) => ({
23
+ id: canvas.id,
24
+ label: new MiradorCanvas(canvas).getLabel(),
25
+ }));
26
+ }
27
+
28
+ /** */
29
+ export function SidebarIndexList({ canvases, containerRef, selectedCanvasIds = [], setCanvas, variant = 'item', windowId }) {
30
+ const canvasesIdAndLabel = useMemo(() => getIdAndLabelOfCanvases(canvases), [canvases]);
31
+ let Item;
32
+
33
+ switch (variant) {
34
+ case 'thumbnail':
35
+ Item = SidebarIndexThumbnail;
36
+ break;
37
+ default:
38
+ Item = SidebarIndexItem;
39
+ }
40
+
41
+ return (
42
+ <MenuList variant="selectedMenu">
43
+ {canvasesIdAndLabel.map((canvas, canvasIndex) => {
44
+ const onClick = () => {
45
+ setCanvas(windowId, canvas.id);
46
+ };
47
+
48
+ return (
49
+ <ScrollTo
50
+ containerRef={containerRef}
51
+ key={`${canvas.id}-${variant}`}
52
+ offsetTop={96} // offset for the height of the form above
53
+ selected={selectedCanvasIds.includes(canvas.id)}
54
+ scrollTo={selectedCanvasIds.includes(canvas.id)}
55
+ >
56
+ <StyledItem key={canvas.id} divider onClick={onClick} component="li">
57
+ <Item label={canvas.label} canvas={canvases[canvasIndex]} />
58
+ </StyledItem>
59
+ </ScrollTo>
60
+ );
61
+ })}
62
+ </MenuList>
63
+ );
64
+ }
65
+
66
+ SidebarIndexList.propTypes = {
67
+ canvases: PropTypes.array.isRequired,
68
+ containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]).isRequired,
69
+ selectedCanvasIds: PropTypes.arrayOf(PropTypes.string),
70
+ setCanvas: PropTypes.func.isRequired,
71
+ variant: PropTypes.oneOf(['item', 'thumbnail']),
72
+ windowId: PropTypes.string.isRequired,
73
+ };
@@ -0,0 +1,170 @@
1
+ import PropTypes from 'prop-types';
2
+ import { alpha, styled } from '@mui/material/styles';
3
+ import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
4
+ import { TreeItem } from '@mui/x-tree-view/TreeItem';
5
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
6
+ import ChevronRightIcon from '@mui/icons-material/ChevronRight';
7
+ import { ScrollTo } from './ScrollTo';
8
+
9
+ const StyledVisibleNode = styled('div')(() => ({}));
10
+
11
+ /** */
12
+ function getStartCanvasId(node) {
13
+ const jsonld = node.data.__jsonld;
14
+ if (jsonld.startCanvas && typeof jsonld.startCanvas === 'string') {
15
+ return jsonld.startCanvas;
16
+ }
17
+ if (jsonld.start) {
18
+ if (jsonld.start.type === 'Canvas' && typeof jsonld.start.id === 'string') {
19
+ return jsonld.start.id;
20
+ }
21
+ if (jsonld.start.type === 'SpecificResource' && typeof jsonld.start.source === 'string') {
22
+ return jsonld.start.source;
23
+ }
24
+ }
25
+ return node.data.getCanvasIds()[0];
26
+ }
27
+
28
+ /** */
29
+ function deepFind(treeNode, id) {
30
+ if (treeNode.id === id) {
31
+ return treeNode;
32
+ }
33
+
34
+ let result = null;
35
+
36
+ if (treeNode.nodes) {
37
+ for (let i = 0; result == null && i < treeNode.nodes.length; i += 1) {
38
+ result = deepFind(treeNode.nodes[i], id);
39
+ }
40
+ }
41
+
42
+ return result;
43
+ }
44
+
45
+ /** */
46
+ const ScrollToForTreeItem = ({ children, itemId, ...props }) => <ScrollTo {...props}>{children}</ScrollTo>;
47
+
48
+ ScrollToForTreeItem.propTypes = {
49
+ children: PropTypes.node.isRequired,
50
+ itemId: PropTypes.string.isRequired,
51
+ };
52
+
53
+ /** */
54
+ const CollapseIcon = (props) => <ExpandMoreIcon {...props} color="action" />;
55
+ /** */
56
+ const ExpandIcon = (props) => <ChevronRightIcon {...props} color="action" />;
57
+ /** */
58
+ export function SidebarIndexTableOfContents({
59
+ toggleNode,
60
+ expandNodes,
61
+ setCanvas,
62
+ windowId,
63
+ treeStructure,
64
+ visibleNodeIds,
65
+ expandedNodeIds,
66
+ containerRef,
67
+ nodeIdToScrollTo,
68
+ }) {
69
+ /** */
70
+ const handleNodeSelect = (event, itemId) => {
71
+ if (event.key === ' ' || event.key === 'Spacebar') {
72
+ toggleNode(itemId);
73
+ }
74
+
75
+ selectTreeItem(itemId);
76
+ };
77
+
78
+ /** */
79
+ const handleNodeToggle = (_event, itemIds) => {
80
+ expandNodes(itemIds);
81
+ };
82
+
83
+ /** */
84
+ const selectTreeItem = (itemId) => {
85
+ const node = deepFind(treeStructure, itemId);
86
+
87
+ // Do not select if there are no canvases listed or it has children
88
+ if (!node.data.getCanvasIds() || node.data.getCanvasIds().length === 0 || node.nodes.length > 0) {
89
+ return;
90
+ }
91
+ const target = getStartCanvasId(node);
92
+ const canvasId = target.indexOf('#') === -1 ? target : target.substr(0, target.indexOf('#'));
93
+ setCanvas(windowId, canvasId);
94
+ };
95
+
96
+ if (!treeStructure) {
97
+ return null;
98
+ }
99
+
100
+ /** */
101
+ const renderTree = (node) => (
102
+ <ScrollToForTreeItem
103
+ containerRef={containerRef}
104
+ key={node.id}
105
+ itemId={node.id}
106
+ offsetTop={96}
107
+ scrollTo={nodeIdToScrollTo === node.id}
108
+ >
109
+ <TreeItem
110
+ itemId={node.id}
111
+ label={
112
+ <StyledVisibleNode
113
+ sx={(theme) => ({
114
+ backgroundColor:
115
+ visibleNodeIds.indexOf(node.id) !== -1 &&
116
+ alpha(theme.palette.highlights?.primary || theme.palette.action.selected, 0.35),
117
+ display: visibleNodeIds.indexOf(node.id) !== -1 && 'inline',
118
+ })}
119
+ >
120
+ {node.label}
121
+ </StyledVisibleNode>
122
+ }
123
+ >
124
+ {node.nodes && node.nodes.length > 0 ? node.nodes.map(renderTree) : null}
125
+ </TreeItem>
126
+ </ScrollToForTreeItem>
127
+ );
128
+
129
+ return (
130
+ <SimpleTreeView
131
+ sx={{ flexGrow: 1 }}
132
+ slots={{
133
+ collapseIcon: CollapseIcon,
134
+ endIcon: null,
135
+ expandIcon: ExpandIcon,
136
+ }}
137
+ onSelectedItemsChange={handleNodeSelect}
138
+ onExpandedItemsChange={handleNodeToggle}
139
+ expandedItems={expandedNodeIds}
140
+ >
141
+ {Array.isArray(treeStructure.nodes) && treeStructure.nodes.length > 0 ? (
142
+ treeStructure.nodes.map((n) => renderTree(n))
143
+ ) : (
144
+ <p>No items found</p>
145
+ )}
146
+ </SimpleTreeView>
147
+ );
148
+ }
149
+
150
+ SidebarIndexTableOfContents.propTypes = {
151
+ containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]).isRequired,
152
+ expandedNodeIds: PropTypes.arrayOf(PropTypes.string).isRequired,
153
+ expandNodes: PropTypes.func.isRequired,
154
+ nodeIdToScrollTo: PropTypes.string.isRequired,
155
+ setCanvas: PropTypes.func.isRequired,
156
+ toggleNode: PropTypes.func.isRequired,
157
+ treeStructure: PropTypes.shape({
158
+ id: PropTypes.string.isRequired,
159
+ label: PropTypes.string.isRequired,
160
+ nodes: PropTypes.arrayOf(
161
+ PropTypes.shape({
162
+ id: PropTypes.string.isRequired,
163
+ label: PropTypes.string.isRequired,
164
+ nodes: PropTypes.array,
165
+ }),
166
+ ),
167
+ }).isRequired,
168
+ visibleNodeIds: PropTypes.arrayOf(PropTypes.string).isRequired,
169
+ windowId: PropTypes.string.isRequired,
170
+ };