@ohif/extension-default 3.14.0-beta.10 → 3.14.0-beta.100

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 (216) hide show
  1. package/dist/ohif-extension-default.css +1 -1
  2. package/dist/ohif-extension-default.umd.js +1 -1
  3. package/package.json +14 -10
  4. package/src/Actions/createReportAsync.tsx +45 -0
  5. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  6. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  7. package/src/Components/ItemListComponent.tsx +95 -0
  8. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  9. package/src/Components/LineChartViewport/index.ts +1 -0
  10. package/src/Components/MoreDropdownMenu.tsx +112 -0
  11. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  12. package/src/Components/SidePanelWithServices.tsx +122 -0
  13. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  15. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  16. package/src/CustomizableContextMenu/index.ts +5 -0
  17. package/src/CustomizableContextMenu/types.ts +126 -0
  18. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  19. package/src/DicomJSONDataSource/index.js +326 -0
  20. package/src/DicomLocalDataSource/index.js +273 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  22. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  23. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  24. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  25. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  26. package/src/DicomWebDataSource/index.ts +808 -0
  27. package/src/DicomWebDataSource/qido.js +215 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  29. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  30. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  31. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  33. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  34. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  35. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  36. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  37. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  38. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  40. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  41. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  42. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  43. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  44. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  45. package/src/DicomWebDataSource/utils/index.ts +9 -0
  46. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  50. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  51. package/src/DicomWebProxyDataSource/index.ts +90 -0
  52. package/src/MergeDataSource/index.test.ts +212 -0
  53. package/src/MergeDataSource/index.ts +319 -0
  54. package/src/MergeDataSource/types.ts +46 -0
  55. package/src/Panels/DataSourceSelector.tsx +55 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  57. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  58. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  59. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  60. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  62. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  63. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  64. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  65. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  66. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  67. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  68. package/src/Panels/debounce.js +25 -0
  69. package/src/Panels/getImageSrcFromImageId.js +16 -0
  70. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  71. package/src/Panels/index.js +5 -0
  72. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  74. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  75. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  76. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  77. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  78. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  79. package/src/Toolbar/Toolbar.tsx +98 -0
  80. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  81. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  82. package/src/Toolbar/index.ts +7 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  84. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  85. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  86. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  87. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  88. package/src/ViewerLayout/constants/panels.ts +42 -0
  89. package/src/ViewerLayout/index.tsx +227 -0
  90. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  91. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  92. package/src/commandsModule.ts +970 -0
  93. package/src/customizations/aboutModalCustomization.tsx +42 -0
  94. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  95. package/src/customizations/contextMenuCustomization.ts +25 -0
  96. package/src/customizations/contextMenuUICustomization.ts +5 -0
  97. package/src/customizations/customRoutesCustomization.ts +6 -0
  98. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  99. package/src/customizations/datasourcesCustomization.tsx +14 -0
  100. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  101. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  102. package/src/customizations/headerRightSideCustomization.ts +19 -0
  103. package/src/customizations/helloPageCustomization.tsx +14 -0
  104. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  105. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  106. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  107. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  109. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  110. package/src/customizations/menuContentCustomization.tsx +67 -0
  111. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  112. package/src/customizations/metadataContextCustomization.ts +28 -0
  113. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  114. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  115. package/src/customizations/multimonitorCustomization.ts +63 -0
  116. package/src/customizations/notificationCustomization.ts +29 -0
  117. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  118. package/src/customizations/onboardingCustomization.ts +200 -0
  119. package/src/customizations/overlayItemCustomization.tsx +33 -0
  120. package/src/customizations/progressDropdownCustomization.ts +5 -0
  121. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  122. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  123. package/src/customizations/reportDialogCustomization.tsx +661 -0
  124. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  125. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  126. package/src/customizations/studyBrowserCustomization.ts +95 -0
  127. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  128. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  129. package/src/customizations/workListCustomization.ts +107 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  131. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  132. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  133. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  134. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  135. package/src/findViewportsByPosition.ts +102 -0
  136. package/src/getCustomizationModule.tsx +109 -0
  137. package/src/getDataSourcesModule.js +44 -0
  138. package/src/getDisplaySetMessages.ts +54 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  140. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  141. package/src/getHangingProtocolModule.js +155 -0
  142. package/src/getLayoutTemplateModule.js +28 -0
  143. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  144. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  145. package/src/getPanelModule.tsx +29 -0
  146. package/src/getSopClassHandlerModule.js +152 -0
  147. package/src/getSopClassHandlerModule.test.js +78 -0
  148. package/src/getToolbarModule.tsx +63 -0
  149. package/src/getViewportModule.tsx +12 -0
  150. package/src/hangingprotocols/hpCompare.ts +189 -0
  151. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  152. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  153. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  154. package/src/hangingprotocols/hpMammo.ts +202 -0
  155. package/src/hangingprotocols/hpScale.ts +132 -0
  156. package/src/hangingprotocols/index.ts +16 -0
  157. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  158. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  159. package/src/hangingprotocols/utils/laterality.ts +9 -0
  160. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  161. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  162. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  163. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  164. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  165. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  166. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  167. package/src/hooks/usePatientInfo.tsx +63 -0
  168. package/src/id.js +5 -0
  169. package/src/index.ts +113 -0
  170. package/src/init.ts +169 -0
  171. package/src/stores/index.ts +7 -0
  172. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  173. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  174. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  175. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  176. package/src/stores/useUIStateStore.ts +87 -0
  177. package/src/stores/useViewportGridStore.ts +89 -0
  178. package/src/stores/useViewportsByPositionStore.ts +100 -0
  179. package/src/types/AppTypes.ts +20 -0
  180. package/src/types/commandModuleTypes.tsx +6 -0
  181. package/src/utils/Toolbox.tsx +123 -0
  182. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  183. package/src/utils/addIcon.ts +6 -0
  184. package/src/utils/appendFrameQueryToImageId.js +9 -0
  185. package/src/utils/callInputDialog.tsx +126 -0
  186. package/src/utils/colorPickerDialog.css +4 -0
  187. package/src/utils/colorPickerDialog.tsx +45 -0
  188. package/src/utils/createRenderedRetrieve.js +32 -0
  189. package/src/utils/createRenderedRetrieve.test.js +46 -0
  190. package/src/utils/dicomWriter.test.ts +228 -0
  191. package/src/utils/dicomWriter.ts +110 -0
  192. package/src/utils/getBulkdataValue.js +45 -0
  193. package/src/utils/getBulkdataValue.test.js +105 -0
  194. package/src/utils/getDirectURL.test.ts +207 -0
  195. package/src/utils/getDirectURL.ts +65 -0
  196. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  197. package/src/utils/index.ts +2 -0
  198. package/src/utils/layerConfigurationUtils.ts +202 -0
  199. package/src/utils/promptLabelAnnotation.js +47 -0
  200. package/src/utils/promptSaveReport.test.ts +106 -0
  201. package/src/utils/promptSaveReport.tsx +117 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  203. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  204. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  205. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  206. package/src/utils/reuseCachedLayouts.ts +92 -0
  207. package/src/utils/secureConfigFetch.js +115 -0
  208. package/src/utils/secureConfigFetch.test.js +163 -0
  209. package/src/utils/seriesDescriptionHistory.ts +83 -0
  210. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  212. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  213. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  214. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  215. package/src/utils/validations/checkMultiframe.ts +25 -0
  216. package/src/utils/validations/checkSingleFrames.ts +36 -0
@@ -0,0 +1,81 @@
1
+ import { chartHandler } from './chartSOPClassHandler';
2
+
3
+ const chartInstance = (overrides = {}) => ({
4
+ Modality: 'CHT',
5
+ SOPClassUID: '1.9.451.13215.7.3.2.7.6.1',
6
+ StudyInstanceUID: '1.2.3',
7
+ SeriesInstanceUID: '1.2.3.4',
8
+ SOPInstanceUID: '1.2.3.4.1',
9
+ SeriesDescription: 'Chart',
10
+ SeriesNumber: 99,
11
+ SeriesDate: '20260817',
12
+ SeriesTime: '133000',
13
+ ...overrides,
14
+ });
15
+
16
+ describe('chartHandler', () => {
17
+ // The series sort compares `SeriesDate SeriesTime` as a single string, so a
18
+ // display set without a time cannot be placed among the other series.
19
+ it('carries the series date and time of its instance', () => {
20
+ const [displaySet] = chartHandler.getDisplaySetsFromSeries([chartInstance()]);
21
+
22
+ expect(displaySet.SeriesDate).toBe('20260817');
23
+ expect(displaySet.SeriesTime).toBe('133000');
24
+ });
25
+
26
+ it('reports an empty date and time rather than undefined', () => {
27
+ const [displaySet] = chartHandler.getDisplaySetsFromSeries([
28
+ chartInstance({ SeriesDate: undefined, SeriesTime: undefined }),
29
+ ]);
30
+
31
+ expect(displaySet.SeriesDate).toBe('');
32
+ expect(displaySet.SeriesTime).toBe('');
33
+ });
34
+
35
+ // The date/time of the display set is the latest one the instance carries,
36
+ // which for an instance added to an existing series is the instance level one
37
+ // rather than the series one.
38
+ it('takes the instance date and time over an older series one', () => {
39
+ const [displaySet] = chartHandler.getDisplaySetsFromSeries([
40
+ chartInstance({ ContentDate: '20260819', ContentTime: '080000' }),
41
+ ]);
42
+
43
+ expect(displaySet.SeriesDate).toBe('20260819');
44
+ expect(displaySet.SeriesTime).toBe('080000');
45
+ });
46
+
47
+ // `addInstances` advances the instance the display set shows, so the date and
48
+ // time shown for it - and summarized from it - have to advance with it rather
49
+ // than staying on those of the instance the series was created with.
50
+ it('moves the date and time on to the newly added instance', () => {
51
+ const [displaySet] = chartHandler.getDisplaySetsFromSeries([chartInstance()]);
52
+
53
+ displaySet.addInstances([
54
+ chartInstance({
55
+ SOPInstanceUID: '1.2.3.4.2',
56
+ ContentDate: '20260819',
57
+ ContentTime: '080000',
58
+ }),
59
+ ]);
60
+
61
+ expect(displaySet.SeriesDate).toBe('20260819');
62
+ expect(displaySet.SeriesTime).toBe('080000');
63
+ });
64
+
65
+ // A split rule groups a revision chain into one display set, with the
66
+ // active revision named by `activeSopInstanceUid`.
67
+ it.each([
68
+ ['the instance that activeSopInstanceUid names', '1.2.3.4.2', '1.2.3.4.2'],
69
+ ['the last instance without activeSopInstanceUid', undefined, '1.2.3.4.3'],
70
+ ])('extendDisplaySet loads %s', (_label, activeSopInstanceUid, expected) => {
71
+ const displaySet: Record<string, any> = {
72
+ instances: ['1.2.3.4.1', '1.2.3.4.2', '1.2.3.4.3'].map(SOPInstanceUID =>
73
+ chartInstance({ SOPInstanceUID })
74
+ ),
75
+ activeSopInstanceUid,
76
+ };
77
+ chartHandler.extendDisplaySet(displaySet);
78
+ expect(displaySet.instance.SOPInstanceUID).toBe(expected);
79
+ expect(displaySet.SOPInstanceUID).toBe(expected);
80
+ });
81
+ });
@@ -0,0 +1,127 @@
1
+ import { Types, DisplaySetService, utils } from '@ohif/core';
2
+
3
+ import { id } from '../id';
4
+
5
+ type InstanceMetadata = Types.InstanceMetadata;
6
+
7
+ const SOPClassHandlerName = 'chart';
8
+
9
+ const CHART_MODALITY = 'CHT';
10
+
11
+ /** The private SOP class UID of chart data. */
12
+ export const ChartDataSOPClassUid = '1.9.451.13215.7.3.2.7.6.1';
13
+
14
+ const sopClassUids = [ChartDataSOPClassUid];
15
+
16
+ /**
17
+ * The chart fields of a display set that shows `instance`. Shared by the
18
+ * legacy builder and {@link extendChartDisplaySet}.
19
+ */
20
+ const getChartFields = (instance, sopClassUids) => {
21
+ const { SOPInstanceUID, SeriesDescription, SeriesNumber, SOPClassUID } = instance;
22
+
23
+ // The date/time of a display set is the date/time of the instance it shows,
24
+ // chosen from all the attributes that instance carries.
25
+ const { SeriesDate, SeriesTime } = utils.getLatestInstanceDateTime(instance);
26
+
27
+ return {
28
+ Modality: CHART_MODALITY,
29
+ loading: false,
30
+ isReconstructable: false,
31
+ SeriesDescription,
32
+ SeriesNumber,
33
+ SeriesDate,
34
+ SeriesTime,
35
+ SOPInstanceUID,
36
+ SOPClassHandlerId: `${id}.sopClassHandlerModule.${SOPClassHandlerName}`,
37
+ SOPClassUID,
38
+ isDerivedDisplaySet: true,
39
+ isLoaded: true,
40
+ sopClassUids,
41
+ instance,
42
+ };
43
+ };
44
+
45
+ const makeChartDataDisplaySet = (instance, sopClassUids) => {
46
+ const { StudyInstanceUID, SeriesInstanceUID } = instance;
47
+
48
+ return {
49
+ ...getChartFields(instance, sopClassUids),
50
+ displaySetInstanceUID: utils.guid(),
51
+ SeriesInstanceUID,
52
+ StudyInstanceUID,
53
+ instances: [instance],
54
+
55
+ /**
56
+ * Adds instances to the chart displaySet, rather than creating a new one
57
+ * when user moves to a different workflow step and gets back to a step that
58
+ * recreates the chart
59
+ */
60
+ addInstances: function (instances: InstanceMetadata[], _displaySetService: DisplaySetService) {
61
+ this.instances.push(...instances);
62
+ this.instance = this.instances[this.instances.length - 1];
63
+ // The date/time shown and sorted by is that of the instance the display
64
+ // set shows, so it moves with that instance rather than staying on the
65
+ // one the chart was first created with.
66
+ const { SeriesDate, SeriesTime } = utils.getLatestInstanceDateTime(this.instance);
67
+ this.SeriesDate = SeriesDate;
68
+ this.SeriesTime = SeriesTime;
69
+
70
+ return this;
71
+ },
72
+ };
73
+ };
74
+
75
+ /**
76
+ * Adds the chart fields to a display set that a split rule with the `chart`
77
+ * handler made. The display set holds a revision chain, and shows the instance
78
+ * `activeSopInstanceUid` names, else the last one, as `addInstances` does for
79
+ * the legacy display set. An update chooses again.
80
+ */
81
+ function extendChartDisplaySet(displaySet) {
82
+ const { instances, activeSopInstanceUid } = displaySet;
83
+ const active =
84
+ instances.find(instance => instance.SOPInstanceUID === activeSopInstanceUid) ??
85
+ instances[instances.length - 1];
86
+ Object.assign(displaySet, getChartFields(active, getSopClassUids(instances)));
87
+ }
88
+
89
+ function getSopClassUids(instances) {
90
+ const uniqueSopClassUidsInSeries = new Set();
91
+ instances.forEach(instance => {
92
+ uniqueSopClassUidsInSeries.add(instance.SOPClassUID);
93
+ });
94
+ const sopClassUids = Array.from(uniqueSopClassUidsInSeries);
95
+
96
+ return sopClassUids;
97
+ }
98
+
99
+ function _getDisplaySetsFromSeries(instances) {
100
+ // If the series has no instances, stop here
101
+ if (!instances || !instances.length) {
102
+ throw new Error('No instances were provided');
103
+ }
104
+
105
+ const sopClassUids = getSopClassUids(instances);
106
+ const displaySets = instances.map(instance => {
107
+ if (instance.Modality === CHART_MODALITY) {
108
+ return makeChartDataDisplaySet(instance, sopClassUids);
109
+ }
110
+
111
+ throw new Error('Unsupported modality');
112
+ });
113
+
114
+ return displaySets;
115
+ }
116
+
117
+ const chartHandler = {
118
+ name: SOPClassHandlerName,
119
+ sopClassUids,
120
+ handlerNames: ['chart'],
121
+ extendDisplaySet: extendChartDisplaySet,
122
+ getDisplaySetsFromSeries: instances => {
123
+ return _getDisplaySetsFromSeries(instances);
124
+ },
125
+ };
126
+
127
+ export { chartHandler };
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import { ToolButton } from '@ohif/ui-next';
4
+ import { useToolbar } from '@ohif/core/src/hooks/useToolbar';
5
+
6
+ /**
7
+ * Wraps the ToolButtonList component to handle the OHIF toolbar button structure
8
+ * @param props - Component props
9
+ * @returns Component
10
+ */
11
+ export function ToolBoxButtonGroupWrapper({ buttonSection, id }) {
12
+ const { onInteraction, toolbarButtons } = useToolbar({
13
+ buttonSection,
14
+ });
15
+
16
+ if (!buttonSection) {
17
+ return null;
18
+ }
19
+
20
+ const items = toolbarButtons.map(button => button.componentProps);
21
+
22
+ return (
23
+ <div className="bg-popover flex flex-row space-x-1 rounded-md px-0 py-0">
24
+ {items.map(item => (
25
+ <ToolButton
26
+ {...item}
27
+ key={item.id}
28
+ size="small"
29
+ className={item.disabled && 'text-foreground/70'}
30
+ onInteraction={event => {
31
+ onInteraction?.({
32
+ event,
33
+ id,
34
+ commands: item.commands,
35
+ itemId: item.id,
36
+ item,
37
+ });
38
+ }}
39
+ />
40
+ ))}
41
+ </div>
42
+ );
43
+ }
44
+
45
+ export function ToolBoxButtonWrapper({ onInteraction, className, options, ...props }) {
46
+ return (
47
+ <div className="bg-popover flex flex-row rounded-md px-0 py-0">
48
+ <ToolButton
49
+ {...props}
50
+ id={props.id}
51
+ size="small"
52
+ className={classNames(props.disabled && 'text-foreground/70', className)}
53
+ onInteraction={event => {
54
+ onInteraction?.({
55
+ event,
56
+ itemId: props.id,
57
+ commands: props.commands,
58
+ options,
59
+ });
60
+ }}
61
+ />
62
+ </div>
63
+ );
64
+ }
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import {
3
+ ToolButtonList,
4
+ ToolButton,
5
+ ToolButtonListDefault,
6
+ ToolButtonListDropDown,
7
+ ToolButtonListItem,
8
+ ToolButtonListDivider,
9
+ } from '@ohif/ui-next';
10
+ import { useToolbar } from '@ohif/core/src';
11
+
12
+ interface ToolButtonListWrapperProps {
13
+ buttonSection: string;
14
+ onInteraction?: (details: { itemId: string; commands?: Record<string, unknown> }) => void;
15
+ id: string;
16
+ }
17
+
18
+ /**
19
+ * Wraps the ToolButtonList component to handle the OHIF toolbar button structure
20
+ * @param props - Component props
21
+ * @returns Component
22
+ * // test
23
+ */
24
+ export default function ToolButtonListWrapper({ buttonSection, id }: ToolButtonListWrapperProps) {
25
+ const { onInteraction, toolbarButtons } = useToolbar({
26
+ buttonSection,
27
+ });
28
+
29
+ if (!toolbarButtons?.length) {
30
+ return null;
31
+ }
32
+
33
+ const primary =
34
+ toolbarButtons.find(button => button.componentProps.isActive)?.componentProps ||
35
+ toolbarButtons[0].componentProps;
36
+
37
+ const items = toolbarButtons.map(button => button.componentProps);
38
+
39
+ return (
40
+ <ToolButtonList>
41
+ <ToolButtonListDefault>
42
+ <div
43
+ data-cy={`${id}-split-button-primary`}
44
+ data-tool={primary.id}
45
+ data-active={primary.isActive}
46
+ >
47
+ <ToolButton
48
+ {...primary}
49
+ onInteraction={({ itemId }) =>
50
+ onInteraction?.({ id, itemId, commands: primary.commands })
51
+ }
52
+ className={primary.className}
53
+ />
54
+ </div>
55
+ </ToolButtonListDefault>
56
+ <ToolButtonListDivider className={primary.isActive ? 'opacity-0' : 'opacity-100'} />
57
+ <div data-cy={`${id}-split-button-secondary`}>
58
+ <ToolButtonListDropDown>
59
+ {items.map(item => {
60
+ return (
61
+ <ToolButtonListItem
62
+ key={item.id}
63
+ {...item}
64
+ data-cy={item.id}
65
+ data-tool={item.id}
66
+ data-active={item.isActive}
67
+ onSelect={() => onInteraction?.({ id, itemId: item.id, commands: item.commands })}
68
+ >
69
+ <span className="pl-1">{item.label || item.tooltip || item.id}</span>
70
+ </ToolButtonListItem>
71
+ );
72
+ })}
73
+ </ToolButtonListDropDown>
74
+ </div>
75
+ </ToolButtonList>
76
+ );
77
+ }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { useIconPresentation, Icons, Button } from '@ohif/ui-next';
3
+
4
+ export default function ToolButtonWrapper(props) {
5
+ const { IconContainer, containerProps } = useIconPresentation();
6
+
7
+ const Icon = <Icons.ByName name={props.icon} />;
8
+
9
+ return (
10
+ <div>
11
+ {IconContainer ? (
12
+ <IconContainer
13
+ disabled={props.disabled}
14
+ {...props}
15
+ {...containerProps}
16
+ >
17
+ {Icon}
18
+ </IconContainer>
19
+ ) : (
20
+ <Button
21
+ variant="ghost"
22
+ size="icon"
23
+ disabled={props.disabled}
24
+ >
25
+ {Icon}
26
+ </Button>
27
+ )}
28
+ </div>
29
+ );
30
+ }
31
+
32
+ export { ToolButtonWrapper };
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { useToolbar, ButtonLocation } from '@ohif/core';
3
+
4
+ interface ToolRowWrapperProps {
5
+ buttonSection: string;
6
+ className?: string;
7
+ show?: boolean;
8
+ }
9
+
10
+ function ToolRowWrapper({ buttonSection, className = '', show = true }: ToolRowWrapperProps) {
11
+ const { onInteraction, toolbarButtons } = useToolbar({
12
+ buttonSection,
13
+ });
14
+
15
+ // No need for debugger statement
16
+ if (!toolbarButtons?.length) {
17
+ return null;
18
+ }
19
+
20
+ return (
21
+ <div className={`space-x-1} flex flex-row items-center ${className}`}>
22
+ {toolbarButtons.map((button, index) => {
23
+ const { id, Component, componentProps } = button;
24
+ return (
25
+ <div
26
+ key={id || index}
27
+ className="flex-shrink-0"
28
+ >
29
+ <Component
30
+ {...componentProps}
31
+ onInteraction={onInteraction}
32
+ location={componentProps.location || buttonSection}
33
+ />
34
+ </div>
35
+ );
36
+ })}
37
+ </div>
38
+ );
39
+ }
40
+
41
+ export default ToolRowWrapper;
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import { useToolbar } from '@ohif/core';
3
+
4
+ /**
5
+ * Props for the Toolbar component that renders a collection of toolbar buttons and/or button sections.
6
+ *
7
+ * @interface ToolbarProps
8
+ */
9
+ interface ToolbarProps {
10
+ /**
11
+ * The section of buttons to display in the toolbar.
12
+ * Common values include 'primary', 'secondary', 'tertiary', etc.
13
+ * Defaults to 'primary' if not specified.
14
+ *
15
+ * @default 'primary'
16
+ */
17
+ buttonSection?: string;
18
+
19
+ /**
20
+ * The unique identifier of the viewport this toolbar is associated with.
21
+ */
22
+ viewportId?: string;
23
+
24
+ /**
25
+ * The numeric position or location of the toolbar.
26
+ * Used for ordering and layout purposes in the UI.
27
+ */
28
+ location?: number;
29
+ }
30
+
31
+ export function Toolbar({ buttonSection = 'primary', viewportId, location }: ToolbarProps) {
32
+ const {
33
+ toolbarButtons,
34
+ onInteraction,
35
+ isItemOpen,
36
+ isItemLocked,
37
+ openItem,
38
+ closeItem,
39
+ toggleLock,
40
+ } = useToolbar({
41
+ buttonSection,
42
+ });
43
+
44
+ if (!toolbarButtons.length) {
45
+ return null;
46
+ }
47
+
48
+ return (
49
+ <>
50
+ {toolbarButtons?.map(toolDef => {
51
+ if (!toolDef) {
52
+ return null;
53
+ }
54
+
55
+ const { id, Component, componentProps } = toolDef;
56
+
57
+ // Enhanced props with state and actions - respecting viewport specificity
58
+ const enhancedProps = {
59
+ ...componentProps,
60
+ isOpen: isItemOpen(id, viewportId),
61
+ isLocked: isItemLocked(id, viewportId),
62
+ onOpen: () => openItem(id, viewportId),
63
+ onClose: () => closeItem(id, viewportId),
64
+ onToggleLock: () => toggleLock(id, viewportId),
65
+ viewportId,
66
+ };
67
+
68
+ const tool = (
69
+ <Component
70
+ key={id}
71
+ id={id}
72
+ location={location}
73
+ onInteraction={args => {
74
+ onInteraction({
75
+ ...args,
76
+ itemId: id,
77
+ viewportId,
78
+ });
79
+ }}
80
+ {...enhancedProps}
81
+ />
82
+ );
83
+
84
+ return (
85
+ <div
86
+ key={id}
87
+ // This wrapper div exists solely for React's key prop requirement during reconciliation.
88
+ // We use display:contents to make it transparent to the layout engine (children appear
89
+ // as direct children of the parent) while keeping it in the DOM for React's virtual DOM.
90
+ className="contents"
91
+ >
92
+ {tool}
93
+ </div>
94
+ );
95
+ })}
96
+ </>
97
+ );
98
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ export default function ToolbarDivider() {
4
+ return <span className="border-common-dark mx-2 h-8 w-4 self-center border-l" />;
5
+ }