@ohif/extension-default 3.14.0-beta.98 → 3.14.0-beta.99

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 (215) hide show
  1. package/dist/ohif-extension-default.umd.js +1 -1
  2. package/package.json +9 -6
  3. package/src/Actions/createReportAsync.tsx +45 -0
  4. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  5. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  6. package/src/Components/ItemListComponent.tsx +95 -0
  7. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  8. package/src/Components/LineChartViewport/index.ts +1 -0
  9. package/src/Components/MoreDropdownMenu.tsx +112 -0
  10. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  11. package/src/Components/SidePanelWithServices.tsx +122 -0
  12. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  13. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  15. package/src/CustomizableContextMenu/index.ts +5 -0
  16. package/src/CustomizableContextMenu/types.ts +126 -0
  17. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  18. package/src/DicomJSONDataSource/index.js +326 -0
  19. package/src/DicomLocalDataSource/index.js +273 -0
  20. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  22. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  23. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  24. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  25. package/src/DicomWebDataSource/index.ts +808 -0
  26. package/src/DicomWebDataSource/qido.js +215 -0
  27. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  29. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  30. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  31. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  33. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  34. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  35. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  36. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  37. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  38. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  40. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  41. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  42. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  43. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  44. package/src/DicomWebDataSource/utils/index.ts +9 -0
  45. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  46. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  50. package/src/DicomWebProxyDataSource/index.ts +90 -0
  51. package/src/MergeDataSource/index.test.ts +212 -0
  52. package/src/MergeDataSource/index.ts +319 -0
  53. package/src/MergeDataSource/types.ts +46 -0
  54. package/src/Panels/DataSourceSelector.tsx +55 -0
  55. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  57. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  58. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  59. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  60. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  62. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  63. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  64. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  65. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  66. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  67. package/src/Panels/debounce.js +25 -0
  68. package/src/Panels/getImageSrcFromImageId.js +16 -0
  69. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  70. package/src/Panels/index.js +5 -0
  71. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  72. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  74. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  75. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  76. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  77. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  78. package/src/Toolbar/Toolbar.tsx +98 -0
  79. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  80. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  81. package/src/Toolbar/index.ts +7 -0
  82. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  84. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  85. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  86. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  87. package/src/ViewerLayout/constants/panels.ts +42 -0
  88. package/src/ViewerLayout/index.tsx +227 -0
  89. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  90. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  91. package/src/commandsModule.ts +970 -0
  92. package/src/customizations/aboutModalCustomization.tsx +42 -0
  93. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  94. package/src/customizations/contextMenuCustomization.ts +25 -0
  95. package/src/customizations/contextMenuUICustomization.ts +5 -0
  96. package/src/customizations/customRoutesCustomization.ts +6 -0
  97. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  98. package/src/customizations/datasourcesCustomization.tsx +14 -0
  99. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  100. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  101. package/src/customizations/headerRightSideCustomization.ts +19 -0
  102. package/src/customizations/helloPageCustomization.tsx +14 -0
  103. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  104. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  105. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  106. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  107. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  109. package/src/customizations/menuContentCustomization.tsx +67 -0
  110. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  111. package/src/customizations/metadataContextCustomization.ts +28 -0
  112. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  113. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  114. package/src/customizations/multimonitorCustomization.ts +63 -0
  115. package/src/customizations/notificationCustomization.ts +29 -0
  116. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  117. package/src/customizations/onboardingCustomization.ts +200 -0
  118. package/src/customizations/overlayItemCustomization.tsx +33 -0
  119. package/src/customizations/progressDropdownCustomization.ts +5 -0
  120. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  121. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  122. package/src/customizations/reportDialogCustomization.tsx +661 -0
  123. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  124. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  125. package/src/customizations/studyBrowserCustomization.ts +95 -0
  126. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  127. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  128. package/src/customizations/workListCustomization.ts +107 -0
  129. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  131. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  132. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  133. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  134. package/src/findViewportsByPosition.ts +102 -0
  135. package/src/getCustomizationModule.tsx +109 -0
  136. package/src/getDataSourcesModule.js +44 -0
  137. package/src/getDisplaySetMessages.ts +54 -0
  138. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  140. package/src/getHangingProtocolModule.js +155 -0
  141. package/src/getLayoutTemplateModule.js +28 -0
  142. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  143. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  144. package/src/getPanelModule.tsx +29 -0
  145. package/src/getSopClassHandlerModule.js +152 -0
  146. package/src/getSopClassHandlerModule.test.js +78 -0
  147. package/src/getToolbarModule.tsx +63 -0
  148. package/src/getViewportModule.tsx +12 -0
  149. package/src/hangingprotocols/hpCompare.ts +189 -0
  150. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  151. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  152. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  153. package/src/hangingprotocols/hpMammo.ts +202 -0
  154. package/src/hangingprotocols/hpScale.ts +132 -0
  155. package/src/hangingprotocols/index.ts +16 -0
  156. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  157. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  158. package/src/hangingprotocols/utils/laterality.ts +9 -0
  159. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  160. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  161. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  162. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  163. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  164. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  165. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  166. package/src/hooks/usePatientInfo.tsx +63 -0
  167. package/src/id.js +5 -0
  168. package/src/index.ts +113 -0
  169. package/src/init.ts +169 -0
  170. package/src/stores/index.ts +7 -0
  171. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  172. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  173. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  174. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  175. package/src/stores/useUIStateStore.ts +87 -0
  176. package/src/stores/useViewportGridStore.ts +89 -0
  177. package/src/stores/useViewportsByPositionStore.ts +100 -0
  178. package/src/types/AppTypes.ts +20 -0
  179. package/src/types/commandModuleTypes.tsx +6 -0
  180. package/src/utils/Toolbox.tsx +123 -0
  181. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  182. package/src/utils/addIcon.ts +6 -0
  183. package/src/utils/appendFrameQueryToImageId.js +9 -0
  184. package/src/utils/callInputDialog.tsx +126 -0
  185. package/src/utils/colorPickerDialog.css +4 -0
  186. package/src/utils/colorPickerDialog.tsx +45 -0
  187. package/src/utils/createRenderedRetrieve.js +32 -0
  188. package/src/utils/createRenderedRetrieve.test.js +46 -0
  189. package/src/utils/dicomWriter.test.ts +228 -0
  190. package/src/utils/dicomWriter.ts +110 -0
  191. package/src/utils/getBulkdataValue.js +45 -0
  192. package/src/utils/getBulkdataValue.test.js +105 -0
  193. package/src/utils/getDirectURL.test.ts +207 -0
  194. package/src/utils/getDirectURL.ts +65 -0
  195. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  196. package/src/utils/index.ts +2 -0
  197. package/src/utils/layerConfigurationUtils.ts +202 -0
  198. package/src/utils/promptLabelAnnotation.js +47 -0
  199. package/src/utils/promptSaveReport.test.ts +106 -0
  200. package/src/utils/promptSaveReport.tsx +117 -0
  201. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  203. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  204. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  205. package/src/utils/reuseCachedLayouts.ts +92 -0
  206. package/src/utils/secureConfigFetch.js +115 -0
  207. package/src/utils/secureConfigFetch.test.js +163 -0
  208. package/src/utils/seriesDescriptionHistory.ts +83 -0
  209. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  210. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  212. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  213. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  214. package/src/utils/validations/checkMultiframe.ts +25 -0
  215. package/src/utils/validations/checkSingleFrames.ts +36 -0
@@ -0,0 +1,195 @@
1
+ // Updated ToolbarLayoutSelector.tsx
2
+ import React from 'react';
3
+ import { CommandsManager } from '@ohif/core';
4
+
5
+ import { LayoutSelector } from '@ohif/ui-next';
6
+ import { useTranslation } from 'react-i18next';
7
+
8
+ function ToolbarLayoutSelectorWithServices({
9
+ commandsManager,
10
+ servicesManager,
11
+ rows = 3,
12
+ columns = 4,
13
+ ...props
14
+ }) {
15
+ const { customizationService } = servicesManager.services;
16
+ const { t } = useTranslation('ToolbarLayoutSelector');
17
+
18
+ // Get the presets from the customization service
19
+ const commonPresets = customizationService?.getCustomization('layoutSelector.commonPresets') || [
20
+ {
21
+ icon: 'layout-single',
22
+ commandOptions: {
23
+ numRows: 1,
24
+ numCols: 1,
25
+ },
26
+ },
27
+ {
28
+ icon: 'layout-side-by-side',
29
+ commandOptions: {
30
+ numRows: 1,
31
+ numCols: 2,
32
+ },
33
+ },
34
+ {
35
+ icon: 'layout-four-up',
36
+ commandOptions: {
37
+ numRows: 2,
38
+ numCols: 2,
39
+ },
40
+ },
41
+ {
42
+ icon: 'layout-three-row',
43
+ commandOptions: {
44
+ numRows: 3,
45
+ numCols: 1,
46
+ },
47
+ },
48
+ ];
49
+
50
+ // Get the advanced presets generator from the customization service
51
+ const advancedPresetsGenerator = customizationService?.getCustomization(
52
+ 'layoutSelector.advancedPresetGenerator'
53
+ );
54
+
55
+ // Generate the advanced presets
56
+ const advancedPresets = advancedPresetsGenerator
57
+ ? advancedPresetsGenerator({ servicesManager })
58
+ : [
59
+ {
60
+ title: 'MPR',
61
+ icon: 'layout-three-col',
62
+ commandOptions: {
63
+ protocolId: 'mpr',
64
+ },
65
+ },
66
+ {
67
+ title: '3D four up',
68
+ icon: 'layout-four-up',
69
+ commandOptions: {
70
+ protocolId: '3d-four-up',
71
+ },
72
+ },
73
+ {
74
+ title: '3D main',
75
+ icon: 'layout-three-row',
76
+ commandOptions: {
77
+ protocolId: '3d-main',
78
+ },
79
+ },
80
+ {
81
+ title: 'Axial Primary',
82
+ icon: 'layout-side-by-side',
83
+ commandOptions: {
84
+ protocolId: 'axial-primary',
85
+ },
86
+ },
87
+ {
88
+ title: '3D only',
89
+ icon: 'layout-single',
90
+ commandOptions: {
91
+ protocolId: '3d-only',
92
+ },
93
+ },
94
+ {
95
+ title: '3D primary',
96
+ icon: 'layout-side-by-side',
97
+ commandOptions: {
98
+ protocolId: '3d-primary',
99
+ },
100
+ },
101
+ {
102
+ title: 'Frame View',
103
+ icon: 'icon-stack',
104
+ commandOptions: {
105
+ protocolId: 'frame-view',
106
+ },
107
+ },
108
+ ];
109
+
110
+ // Unified selection handler that dispatches to the appropriate command
111
+ const handleSelectionChange = (commandOptions, isPreset) => {
112
+ if (isPreset) {
113
+ // Advanced preset selection: apply the stage layout, not a cached custom grid
114
+ commandsManager.run({
115
+ commandName: 'setHangingProtocol',
116
+ commandOptions: { ...commandOptions, restoreCachedLayout: false },
117
+ });
118
+ } else {
119
+ // Common preset or custom grid selection
120
+ commandsManager.run({
121
+ commandName: 'setViewportGridLayout',
122
+ commandOptions,
123
+ });
124
+ }
125
+ };
126
+
127
+ return (
128
+ <div
129
+ id="Layout"
130
+ data-cy="Layout"
131
+ >
132
+ <LayoutSelector
133
+ onSelectionChange={handleSelectionChange}
134
+ {...props}
135
+ >
136
+ <LayoutSelector.Trigger tooltip={t('Change layout')} />
137
+ <LayoutSelector.Content>
138
+ {/* Left side - Presets */}
139
+ {(commonPresets.length > 0 || advancedPresets.length > 0) && (
140
+ <div className="bg-popover flex flex-col gap-2.5 rounded-lg p-2">
141
+ {commonPresets.length > 0 && (
142
+ <>
143
+ <LayoutSelector.PresetSection title={t('Common')}>
144
+ {commonPresets.map((preset, index) => (
145
+ <LayoutSelector.Preset
146
+ key={`common-preset-${index}`}
147
+ icon={preset.icon}
148
+ commandOptions={preset.commandOptions}
149
+ isPreset={false}
150
+ />
151
+ ))}
152
+ </LayoutSelector.PresetSection>
153
+ <LayoutSelector.Divider />
154
+ </>
155
+ )}
156
+
157
+ {advancedPresets.length > 0 && (
158
+ <LayoutSelector.PresetSection title={t('Advanced')}>
159
+ {advancedPresets.map((preset, index) => (
160
+ <LayoutSelector.Preset
161
+ key={`advanced-preset-${index}`}
162
+ title={preset.title}
163
+ icon={preset.icon}
164
+ commandOptions={preset.commandOptions}
165
+ disabled={preset.disabled}
166
+ isPreset={true}
167
+ />
168
+ ))}
169
+ </LayoutSelector.PresetSection>
170
+ )}
171
+ </div>
172
+ )}
173
+
174
+ {/* Right Side - Grid Layout */}
175
+ <div className="bg-muted flex flex-col gap-2.5 border-l-2 border-solid border-background p-2">
176
+ <div className="text-muted-foreground text-xs">{t('Custom')}</div>
177
+ <LayoutSelector.GridSelector
178
+ rows={rows}
179
+ columns={columns}
180
+ />
181
+ <LayoutSelector.HelpText>
182
+ {t('Hover to select')} <br />
183
+ {t('rows and columns')} <br />
184
+ {t('Click to apply')}
185
+ </LayoutSelector.HelpText>
186
+ </div>
187
+ </LayoutSelector.Content>
188
+ </LayoutSelector>
189
+ </div>
190
+ );
191
+ }
192
+
193
+
194
+
195
+ export default ToolbarLayoutSelectorWithServices;
@@ -0,0 +1,7 @@
1
+ export * from './Toolbar';
2
+ export * from './ToolButtonWrapper';
3
+ export * from './ToolButtonListWrapper';
4
+ export * from './ToolRowWrapper';
5
+ export * from './ToolBoxWrapper';
6
+ export * from './ToolbarDivider';
7
+ export * from './ToolbarLayoutSelector';
@@ -0,0 +1,96 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { useSystem } from '@ohif/core';
3
+ import usePatientInfo from '../../hooks/usePatientInfo';
4
+ import { Icons } from '@ohif/ui-next';
5
+
6
+ export enum PatientInfoVisibility {
7
+ VISIBLE = 'visible',
8
+ VISIBLE_COLLAPSED = 'visibleCollapsed',
9
+ DISABLED = 'disabled',
10
+ VISIBLE_READONLY = 'visibleReadOnly',
11
+ }
12
+
13
+ const formatWithEllipsis = (str, maxLength) => {
14
+ if (str?.length > maxLength) {
15
+ return str.substring(0, maxLength) + '...';
16
+ }
17
+ return str;
18
+ };
19
+
20
+ function PatientInfo({ showPatientInfo }) {
21
+ const initialExpandedState =
22
+ showPatientInfo === PatientInfoVisibility.VISIBLE ||
23
+ showPatientInfo === PatientInfoVisibility.VISIBLE_READONLY;
24
+ const [expanded, setExpanded] = useState(initialExpandedState);
25
+ const { patientInfo, isMixedPatients } = usePatientInfo();
26
+
27
+ useEffect(() => {
28
+ if (isMixedPatients && expanded) {
29
+ setExpanded(false);
30
+ }
31
+ }, [isMixedPatients, expanded]);
32
+
33
+ const handleOnClick = () => {
34
+ if (!isMixedPatients && showPatientInfo !== PatientInfoVisibility.VISIBLE_READONLY) {
35
+ setExpanded(!expanded);
36
+ }
37
+ };
38
+
39
+ const formattedPatientName = formatWithEllipsis(patientInfo.PatientName, 27);
40
+ const formattedPatientID = formatWithEllipsis(patientInfo.PatientID, 15);
41
+
42
+ return (
43
+ <div
44
+ className="hover:bg-muted flex cursor-pointer items-center justify-center gap-1 rounded-lg"
45
+ onClick={handleOnClick}
46
+ >
47
+ {isMixedPatients ? (
48
+ <Icons.MultiplePatients className="text-primary" />
49
+ ) : (
50
+ <Icons.Patient className="text-primary" />
51
+ )}
52
+ <div className="flex flex-col justify-center">
53
+ {expanded ? (
54
+ <>
55
+ <div className="text-foreground self-start text-[13px] font-bold">
56
+ {formattedPatientName}
57
+ </div>
58
+ <div className="text-muted-foreground flex gap-2 text-[11px]">
59
+ <div>{formattedPatientID}</div>
60
+ <div>{patientInfo.PatientSex}</div>
61
+ <div>{patientInfo.PatientDOB}</div>
62
+ </div>
63
+ </>
64
+ ) : (
65
+ <div className="text-primary self-center text-[13px]">
66
+ {isMixedPatients ? 'Multiple Patients' : 'Patient'}
67
+ </div>
68
+ )}
69
+ </div>
70
+ <Icons.ArrowLeft className={`text-primary ${expanded ? 'rotate-180' : ''}`} />
71
+ </div>
72
+ );
73
+ }
74
+
75
+ /**
76
+ * Patient name/ID/sex/DOB, shipped as one of the `ohif.headerRightSide` items.
77
+ * Like every item in that list it takes no props, and it renders nothing when
78
+ * `showPatientInfo` is `disabled` — the header slot collapses with it.
79
+ *
80
+ * The visibility check lives out here rather than inside `PatientInfo` so that
81
+ * `disabled` never mounts the body: `usePatientInfo` subscribes to display set
82
+ * events and recomputes on every batch, which is wasted work when the result is
83
+ * always `null`.
84
+ */
85
+ function HeaderPatientInfo() {
86
+ const { extensionManager } = useSystem();
87
+ const { showPatientInfo } = extensionManager.appConfig;
88
+
89
+ if (showPatientInfo === PatientInfoVisibility.DISABLED) {
90
+ return null;
91
+ }
92
+
93
+ return <PatientInfo showPatientInfo={showPatientInfo} />;
94
+ }
95
+
96
+ export default HeaderPatientInfo;
@@ -0,0 +1,3 @@
1
+ import HeaderPatientInfo from './HeaderPatientInfo';
2
+
3
+ export default HeaderPatientInfo;
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Button, Icons } from '@ohif/ui-next';
4
+ import { useSystem } from '@ohif/core';
5
+ import { useUndoRedoState } from './useUndoRedoState';
6
+
7
+ /**
8
+ * Undo/redo buttons, shipped as one of the `ohif.headerRightSide` items. Like
9
+ * every item in that list it takes no props and gets what it needs from
10
+ * `useSystem()`, so a site can reorder or drop it without touching the header.
11
+ */
12
+ function HeaderUndoRedo() {
13
+ const { commandsManager } = useSystem();
14
+ const { t } = useTranslation();
15
+ const { canUndo, canRedo } = useUndoRedoState();
16
+
17
+ return (
18
+ <div className="text-primary flex items-center">
19
+ <Button
20
+ variant="ghost"
21
+ className="hover:bg-muted cursor-pointer"
22
+ data-cy="undo-btn"
23
+ disabled={!canUndo}
24
+ aria-label={t('Header:Undo')}
25
+ onClick={() => {
26
+ commandsManager.run('undo');
27
+ }}
28
+ >
29
+ <Icons.Undo className="" />
30
+ </Button>
31
+ <Button
32
+ variant="ghost"
33
+ className="hover:bg-muted cursor-pointer"
34
+ data-cy="redo-btn"
35
+ disabled={!canRedo}
36
+ aria-label={t('Header:Redo')}
37
+ onClick={() => {
38
+ commandsManager.run('redo');
39
+ }}
40
+ >
41
+ <Icons.Redo className="" />
42
+ </Button>
43
+ </div>
44
+ );
45
+ }
46
+
47
+ export default HeaderUndoRedo;
@@ -0,0 +1,334 @@
1
+ import { useState, useCallback, useLayoutEffect, useRef } from 'react';
2
+ import { getPanelElement, getPanelGroupElement } from 'react-resizable-panels';
3
+ import { getPanelGroupDefinition } from './constants/panels';
4
+
5
+ /**
6
+ * Set the minimum and maximum css style width attributes for the given element.
7
+ * The two style attributes are cleared whenever the width
8
+ * argument is undefined.
9
+ * <p>
10
+ * This utility is used as part of a HACK throughout the ViewerLayout component as
11
+ * the means of restricting the side panel widths during the resizing of the
12
+ * browser window. In general, the widths are always set unless the resize
13
+ * handle for either side panel is being dragged (i.e. a side panel is being resized).
14
+ *
15
+ * @param elem the element
16
+ * @param width the max and min width to set on the element
17
+ */
18
+ const setMinMaxWidth = (elem, width?) => {
19
+ if (!elem) {
20
+ return;
21
+ }
22
+
23
+ elem.style.minWidth = width === undefined ? '' : `${width}px`;
24
+ elem.style.maxWidth = elem.style.minWidth;
25
+ };
26
+
27
+ const useResizablePanels = (
28
+ leftPanelClosed,
29
+ setLeftPanelClosed,
30
+ rightPanelClosed,
31
+ setRightPanelClosed,
32
+ hasLeftPanels,
33
+ hasRightPanels,
34
+ leftPanelInitialExpandedWidth,
35
+ rightPanelInitialExpandedWidth,
36
+ leftPanelMinimumExpandedWidth,
37
+ rightPanelMinimumExpandedWidth
38
+ ) => {
39
+ const [panelGroupDefinition] = useState(
40
+ getPanelGroupDefinition({
41
+ leftPanelInitialExpandedWidth,
42
+ rightPanelInitialExpandedWidth,
43
+ leftPanelMinimumExpandedWidth,
44
+ rightPanelMinimumExpandedWidth,
45
+ })
46
+ );
47
+
48
+ const [leftPanelExpandedWidth, setLeftPanelExpandedWidth] = useState(
49
+ panelGroupDefinition.left.initialExpandedWidth
50
+ );
51
+ const [rightPanelExpandedWidth, setRightPanelExpandedWidth] = useState(
52
+ panelGroupDefinition.right.initialExpandedWidth
53
+ );
54
+ const [leftResizablePanelMinimumSize, setLeftResizablePanelMinimumSize] = useState(0);
55
+ const [rightResizablePanelMinimumSize, setRightResizablePanelMinimumSize] = useState(0);
56
+ const [leftResizablePanelCollapsedSize, setLeftResizePanelCollapsedSize] = useState(0);
57
+ const [rightResizePanelCollapsedSize, setRightResizePanelCollapsedSize] = useState(0);
58
+
59
+ const resizablePanelGroupElemRef = useRef(null);
60
+ const resizableLeftPanelElemRef = useRef(null);
61
+ const resizableRightPanelElemRef = useRef(null);
62
+ const resizableLeftPanelAPIRef = useRef(null);
63
+ const resizableRightPanelAPIRef = useRef(null);
64
+ const isResizableHandleDraggingRef = useRef(false);
65
+
66
+ // The total width of both handles.
67
+ const resizableHandlesWidth = useRef(null);
68
+
69
+ /**
70
+ * Gets the percentage size corresponding to the given pixel size.
71
+ * Note that the width attributed to the handles must be taken into account.
72
+ */
73
+ const getPercentageSize = pixelSize => {
74
+ const { width: panelGroupWidth } = resizablePanelGroupElemRef.current?.getBoundingClientRect();
75
+ return (pixelSize / (panelGroupWidth - resizableHandlesWidth.current)) * 100;
76
+ };
77
+
78
+ /**
79
+ * Gets the width in pixels for an expanded panel given its percentage size/width.
80
+ * Note that the width attributed to the handles must be taken into account.
81
+ */
82
+ const getExpandedPixelWidth = percentageSize => {
83
+ const { width: panelGroupWidth } = resizablePanelGroupElemRef.current?.getBoundingClientRect();
84
+ const expandedWidth =
85
+ (percentageSize / 100) * (panelGroupWidth - resizableHandlesWidth.current) -
86
+ panelGroupDefinition.shared.expandedInsideBorderSize;
87
+ return expandedWidth;
88
+ };
89
+
90
+ // This useLayoutEffect is used to...
91
+ // - Grab a reference to the various resizable panel elements needed for
92
+ // converting between percentages and pixels in various callbacks.
93
+ // - Expand those panels that are initially expanded.
94
+ useLayoutEffect(() => {
95
+ const panelGroupElem = getPanelGroupElement(panelGroupDefinition.groupId);
96
+ resizablePanelGroupElemRef.current = panelGroupElem;
97
+
98
+ const leftPanelElem = getPanelElement(panelGroupDefinition.left.panelId);
99
+ resizableLeftPanelElemRef.current = leftPanelElem;
100
+
101
+ const rightPanelElem = getPanelElement(panelGroupDefinition.right.panelId);
102
+ resizableRightPanelElemRef.current = rightPanelElem;
103
+
104
+ // Calculate and set the width of both handles combined.
105
+ const resizeHandles = document.querySelectorAll('[data-panel-resize-handle-id]');
106
+ resizableHandlesWidth.current = 0;
107
+ resizeHandles.forEach(resizeHandle => {
108
+ resizableHandlesWidth.current += resizeHandle.offsetWidth;
109
+ });
110
+
111
+ // Since both resizable panels are collapsed by default (i.e. their default size is zero),
112
+ // on the very first render check if either/both side panels should be expanded.
113
+ // we use the initialExpandedOffsetWidth on the first render incase the panel has min width but we want the initial state to be larger than that
114
+
115
+ if (!leftPanelClosed) {
116
+ const leftResizablePanelExpandedSize = getPercentageSize(
117
+ panelGroupDefinition.left.initialExpandedOffsetWidth
118
+ );
119
+ resizableLeftPanelAPIRef?.current?.expand(leftResizablePanelExpandedSize);
120
+ setMinMaxWidth(leftPanelElem, panelGroupDefinition.left.initialExpandedOffsetWidth);
121
+ }
122
+
123
+ if (!rightPanelClosed) {
124
+ const rightResizablePanelExpandedSize = getPercentageSize(
125
+ panelGroupDefinition.right.initialExpandedOffsetWidth
126
+ );
127
+ resizableRightPanelAPIRef?.current?.expand(rightResizablePanelExpandedSize);
128
+ setMinMaxWidth(rightPanelElem, panelGroupDefinition.right.initialExpandedOffsetWidth);
129
+ }
130
+ }, []); // no dependencies because this useLayoutEffect is only needed on the very first render
131
+
132
+ // This useLayoutEffect follows the pattern prescribed by the react-resizable-panels
133
+ // readme for converting between pixel values and percentages. An example of
134
+ // the pattern can be found here:
135
+ // https://github.com/bvaughn/react-resizable-panels/issues/46#issuecomment-1368108416
136
+ // This useLayoutEffect is used to...
137
+ // - Ensure that the percentage size is up-to-date with the pixel sizes
138
+ // - Add a resize observer to the resizable panel group to reset various state
139
+ // values whenever the resizable panel group is resized (e.g. whenever the
140
+ // browser window is resized).
141
+ useLayoutEffect(() => {
142
+ // Ensure the side panels' percentage size is in synch with the pixel width of the
143
+ // expanded side panels. In general the two get out-of-sync during a browser
144
+ // window resize. Note that this code is here and NOT in the ResizeObserver
145
+ // because it has to be done AFTER the minimum percentage size for a panel is
146
+ // updated which occurs only AFTER the render following a browser window resize.
147
+ // And by virtue of the dependency on the minimum size state variables, this code
148
+ // is executed on the render following an update of the minimum percentage sizes
149
+ // for a panel.
150
+ if (!resizableLeftPanelAPIRef.current?.isCollapsed()) {
151
+ const leftSize = getPercentageSize(
152
+ leftPanelExpandedWidth + panelGroupDefinition.shared.expandedInsideBorderSize
153
+ );
154
+ resizableLeftPanelAPIRef.current?.resize(leftSize);
155
+ }
156
+
157
+ if (!resizableRightPanelAPIRef?.current?.isCollapsed()) {
158
+ const rightSize = getPercentageSize(
159
+ rightPanelExpandedWidth + panelGroupDefinition.shared.expandedInsideBorderSize
160
+ );
161
+ resizableRightPanelAPIRef?.current?.resize(rightSize);
162
+ }
163
+
164
+ // This observer kicks in when the ViewportLayout resizable panel group
165
+ // component is resized. This typically occurs when the browser window resizes.
166
+ const observer = new ResizeObserver(() => {
167
+ const minimumLeftSize = getPercentageSize(
168
+ panelGroupDefinition.left.minimumExpandedOffsetWidth
169
+ );
170
+ const minimumRightSize = getPercentageSize(
171
+ panelGroupDefinition.right.minimumExpandedOffsetWidth
172
+ );
173
+
174
+ // Set the new minimum and collapsed resizable panel sizes.
175
+ setLeftResizablePanelMinimumSize(minimumLeftSize);
176
+ setRightResizablePanelMinimumSize(minimumRightSize);
177
+ setLeftResizePanelCollapsedSize(
178
+ getPercentageSize(panelGroupDefinition.left.collapsedOffsetWidth)
179
+ );
180
+ setRightResizePanelCollapsedSize(
181
+ getPercentageSize(panelGroupDefinition.right.collapsedOffsetWidth)
182
+ );
183
+ });
184
+
185
+ observer.observe(resizablePanelGroupElemRef.current);
186
+
187
+ return () => {
188
+ observer.disconnect();
189
+ };
190
+ }, [
191
+ leftPanelExpandedWidth,
192
+ rightPanelExpandedWidth,
193
+ leftResizablePanelMinimumSize,
194
+ rightResizablePanelMinimumSize,
195
+ hasLeftPanels,
196
+ hasRightPanels,
197
+ ]);
198
+
199
+ /**
200
+ * Handles dragging of either side panel resize handle.
201
+ */
202
+ const onHandleDragging = isStartDrag => {
203
+ if (isStartDrag) {
204
+ isResizableHandleDraggingRef.current = true;
205
+
206
+ setMinMaxWidth(resizableLeftPanelElemRef.current);
207
+ setMinMaxWidth(resizableRightPanelElemRef.current);
208
+ } else {
209
+ isResizableHandleDraggingRef.current = false;
210
+
211
+ if (resizableLeftPanelAPIRef?.current?.isExpanded()) {
212
+ setMinMaxWidth(
213
+ resizableLeftPanelElemRef.current,
214
+ leftPanelExpandedWidth + panelGroupDefinition.shared.expandedInsideBorderSize
215
+ );
216
+ }
217
+
218
+ if (resizableRightPanelAPIRef?.current?.isExpanded()) {
219
+ setMinMaxWidth(
220
+ resizableRightPanelElemRef.current,
221
+ rightPanelExpandedWidth + panelGroupDefinition.shared.expandedInsideBorderSize
222
+ );
223
+ }
224
+ }
225
+ };
226
+
227
+ const onLeftPanelClose = useCallback(() => {
228
+ setLeftPanelClosed(true);
229
+ setMinMaxWidth(resizableLeftPanelElemRef.current);
230
+ resizableLeftPanelAPIRef?.current?.collapse();
231
+ }, [setLeftPanelClosed]);
232
+
233
+ const onLeftPanelOpen = () => {
234
+ resizableLeftPanelAPIRef?.current?.expand(
235
+ getPercentageSize(panelGroupDefinition.left.initialExpandedOffsetWidth)
236
+ );
237
+ setLeftPanelClosed(false);
238
+ };
239
+
240
+ const onLeftPanelResize = size => {
241
+ if (!resizablePanelGroupElemRef?.current || resizableLeftPanelAPIRef.current?.isCollapsed()) {
242
+ return;
243
+ }
244
+
245
+ const newExpandedWidth = getExpandedPixelWidth(size);
246
+ setLeftPanelExpandedWidth(newExpandedWidth);
247
+
248
+ if (!isResizableHandleDraggingRef.current) {
249
+ // This typically gets executed when the left panel is expanded via one of the UI
250
+ // buttons. It is done here instead of in the onLeftPanelOpen method
251
+ // because here we know the size of the expanded panel.
252
+ setMinMaxWidth(resizableLeftPanelElemRef.current, newExpandedWidth);
253
+ }
254
+ };
255
+
256
+ const onRightPanelClose = useCallback(() => {
257
+ setRightPanelClosed(true);
258
+ setMinMaxWidth(resizableRightPanelElemRef.current);
259
+ resizableRightPanelAPIRef?.current?.collapse();
260
+ }, [setRightPanelClosed]);
261
+
262
+ const onRightPanelOpen = () => {
263
+ resizableRightPanelAPIRef?.current?.expand(
264
+ getPercentageSize(panelGroupDefinition.right.initialExpandedOffsetWidth)
265
+ );
266
+ setRightPanelClosed(false);
267
+ };
268
+
269
+ const onRightPanelResize = size => {
270
+ if (!resizablePanelGroupElemRef?.current || resizableRightPanelAPIRef?.current?.isCollapsed()) {
271
+ return;
272
+ }
273
+
274
+ const newExpandedWidth = getExpandedPixelWidth(size);
275
+ setRightPanelExpandedWidth(newExpandedWidth);
276
+
277
+ if (!isResizableHandleDraggingRef.current) {
278
+ // This typically gets executed when the right panel is expanded via one of the UI
279
+ // buttons. It is done here instead of in the onRightPanelOpen method
280
+ // because here we know the size of the expanded panel.
281
+ setMinMaxWidth(resizableRightPanelElemRef.current, newExpandedWidth);
282
+ }
283
+ };
284
+
285
+ return [
286
+ {
287
+ expandedWidth: leftPanelExpandedWidth,
288
+ collapsedWidth: panelGroupDefinition.shared.collapsedWidth,
289
+ collapsedInsideBorderSize: panelGroupDefinition.shared.collapsedInsideBorderSize,
290
+ collapsedOutsideBorderSize: panelGroupDefinition.shared.collapsedOutsideBorderSize,
291
+ expandedInsideBorderSize: panelGroupDefinition.shared.expandedInsideBorderSize,
292
+ onClose: onLeftPanelClose,
293
+ onOpen: onLeftPanelOpen,
294
+ },
295
+ {
296
+ expandedWidth: rightPanelExpandedWidth,
297
+ collapsedWidth: panelGroupDefinition.shared.collapsedWidth,
298
+ collapsedInsideBorderSize: panelGroupDefinition.shared.collapsedInsideBorderSize,
299
+ collapsedOutsideBorderSize: panelGroupDefinition.shared.collapsedOutsideBorderSize,
300
+ expandedInsideBorderSize: panelGroupDefinition.shared.expandedInsideBorderSize,
301
+ onClose: onRightPanelClose,
302
+ onOpen: onRightPanelOpen,
303
+ },
304
+ { direction: 'horizontal', id: panelGroupDefinition.groupId },
305
+ {
306
+ defaultSize: leftResizablePanelMinimumSize,
307
+ minSize: leftResizablePanelMinimumSize,
308
+ onResize: onLeftPanelResize,
309
+ collapsible: true,
310
+ collapsedSize: leftResizablePanelCollapsedSize,
311
+ onCollapse: () => setLeftPanelClosed(true),
312
+ onExpand: () => setLeftPanelClosed(false),
313
+ ref: resizableLeftPanelAPIRef,
314
+ order: 0,
315
+ id: panelGroupDefinition.left.panelId,
316
+ },
317
+ { order: 1, id: 'viewerLayoutResizableViewportGridPanel' },
318
+ {
319
+ defaultSize: rightResizablePanelMinimumSize,
320
+ minSize: rightResizablePanelMinimumSize,
321
+ onResize: onRightPanelResize,
322
+ collapsible: true,
323
+ collapsedSize: rightResizePanelCollapsedSize,
324
+ onCollapse: () => setRightPanelClosed(true),
325
+ onExpand: () => setRightPanelClosed(false),
326
+ ref: resizableRightPanelAPIRef,
327
+ order: 2,
328
+ id: panelGroupDefinition.right.panelId,
329
+ },
330
+ onHandleDragging,
331
+ ];
332
+ };
333
+
334
+ export default useResizablePanels;