feat(ui): move to React 18 and base for using shadcn/ui (#4174)
Co-authored-by: IbrahimCSAE <ibrahim.mdev@gmail.com>
This commit is contained in:
1 parent
72b63dcd6a
commit
70f2c797f4
153 files changed
+2973
-2043
No files matched your search
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: ['inline-react-svg', '@babel/plugin-proposal-class-properties'],
|
||||
plugins: ['@babel/plugin-proposal-class-properties'],
|
||||
env: {
|
||||
test: {
|
||||
presets: [
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
"@ohif/extension-default": "3.9.0-beta.21",
|
||||
"@ohif/i18n": "3.9.0-beta.21",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^10.11.0",
|
||||
"react-router": "^6.3.0",
|
||||
"react-router-dom": "^6.3.0"
|
||||
|
||||
@@ -358,11 +358,6 @@ OHIFCornerstoneRTViewport.propTypes = {
|
||||
viewportId: PropTypes.string.isRequired,
|
||||
dataSource: PropTypes.object,
|
||||
children: PropTypes.node,
|
||||
customProps: PropTypes.object,
|
||||
};
|
||||
|
||||
OHIFCornerstoneRTViewport.defaultProps = {
|
||||
customProps: {},
|
||||
};
|
||||
|
||||
function _getReferencedDisplaySetMetadata(referencedDisplaySet) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: ['inline-react-svg', '@babel/plugin-proposal-class-properties'],
|
||||
plugins: ['@babel/plugin-proposal-class-properties'],
|
||||
env: {
|
||||
test: {
|
||||
presets: [
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
"@ohif/extension-default": "3.9.0-beta.21",
|
||||
"@ohif/i18n": "3.9.0-beta.21",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^12.2.2",
|
||||
"react-router": "^6.8.1",
|
||||
"react-router-dom": "^6.8.1"
|
||||
|
||||
@@ -367,11 +367,6 @@ OHIFCornerstoneSEGViewport.propTypes = {
|
||||
viewportId: PropTypes.string.isRequired,
|
||||
dataSource: PropTypes.object,
|
||||
children: PropTypes.node,
|
||||
customProps: PropTypes.object,
|
||||
};
|
||||
|
||||
OHIFCornerstoneSEGViewport.defaultProps = {
|
||||
customProps: {},
|
||||
};
|
||||
|
||||
function _getReferencedDisplaySetMetadata(referencedDisplaySet, segDisplaySet) {
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"dicom-parser": "^1.8.9",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
|
||||
@@ -367,16 +367,11 @@ OHIFCornerstoneSRViewport.propTypes = {
|
||||
dataSource: PropTypes.object,
|
||||
children: PropTypes.node,
|
||||
viewportLabel: PropTypes.string,
|
||||
customProps: PropTypes.object,
|
||||
viewportOptions: PropTypes.object,
|
||||
servicesManager: PropTypes.object.isRequired,
|
||||
extensionManager: PropTypes.instanceOf(ExtensionManager).isRequired,
|
||||
};
|
||||
|
||||
OHIFCornerstoneSRViewport.defaultProps = {
|
||||
customProps: {},
|
||||
};
|
||||
|
||||
async function _getViewportReferencedDisplaySetData(
|
||||
displaySet,
|
||||
measurementSelected,
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"dicom-parser": "^1.8.21",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
"dicom-parser": "^1.8.21",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-resize-detector": "^6.7.6"
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-resize-detector": "^10.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"lodash": "^4.17.21"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useCallback, useState } from 'react';
|
||||
import ReactResizeDetector from 'react-resize-detector';
|
||||
import { useResizeDetector } from 'react-resize-detector';
|
||||
import PropTypes from 'prop-types';
|
||||
import * as cs3DTools from '@cornerstonejs/tools';
|
||||
import {
|
||||
@@ -109,7 +109,7 @@ const OHIFCornerstoneViewport = React.memo((props: withAppTypes) => {
|
||||
onElementEnabled,
|
||||
// eslint-disable-next-line react/prop-types
|
||||
onElementDisabled,
|
||||
isJumpToMeasurementDisabled,
|
||||
isJumpToMeasurementDisabled = false,
|
||||
// Note: you SHOULD NOT use the initialImageIdOrIndex for manipulation
|
||||
// of the imageData in the OHIFCornerstoneViewport. This prop is used
|
||||
// to set the initial state of the viewport's first image to render
|
||||
@@ -140,7 +140,7 @@ const OHIFCornerstoneViewport = React.memo((props: withAppTypes) => {
|
||||
|
||||
const [scrollbarHeight, setScrollbarHeight] = useState('100px');
|
||||
const [enabledVPElement, setEnabledVPElement] = useState(null);
|
||||
const elementRef = useRef();
|
||||
const elementRef = useRef() as React.MutableRefObject<HTMLDivElement>;
|
||||
const [appConfig] = useAppConfig();
|
||||
|
||||
const {
|
||||
@@ -417,19 +417,21 @@ const OHIFCornerstoneViewport = React.memo((props: withAppTypes) => {
|
||||
});
|
||||
}, [displaySets, viewportId, viewportActionCornersService, servicesManager, commandsManager]);
|
||||
|
||||
const { ref: resizeRef } = useResizeDetector({
|
||||
onResize,
|
||||
});
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="viewport-wrapper">
|
||||
<ReactResizeDetector
|
||||
onResize={onResize}
|
||||
targetRef={elementRef.current}
|
||||
/>
|
||||
<div
|
||||
className="cornerstone-viewport-element"
|
||||
style={{ height: '100%', width: '100%' }}
|
||||
onContextMenu={e => e.preventDefault()}
|
||||
onMouseDown={e => e.preventDefault()}
|
||||
ref={elementRef}
|
||||
ref={el => {
|
||||
resizeRef.current = el;
|
||||
elementRef.current = el;
|
||||
}}
|
||||
></div>
|
||||
<CornerstoneOverlays
|
||||
viewportId={viewportId}
|
||||
@@ -683,10 +685,6 @@ function _rehydrateSynchronizers(
|
||||
// Component displayName
|
||||
OHIFCornerstoneViewport.displayName = 'OHIFCornerstoneViewport';
|
||||
|
||||
OHIFCornerstoneViewport.defaultProps = {
|
||||
isJumpToMeasurementDisabled: false,
|
||||
};
|
||||
|
||||
OHIFCornerstoneViewport.propTypes = {
|
||||
displaySets: PropTypes.array.isRequired,
|
||||
dataSource: PropTypes.object.isRequired,
|
||||
|
||||
@@ -78,14 +78,8 @@ function ViewportImageSliceLoadingIndicator({ viewportData, element }) {
|
||||
}
|
||||
|
||||
ViewportImageSliceLoadingIndicator.propTypes = {
|
||||
percentComplete: PropTypes.number,
|
||||
error: PropTypes.object,
|
||||
element: PropTypes.object,
|
||||
};
|
||||
|
||||
ViewportImageSliceLoadingIndicator.defaultProps = {
|
||||
percentComplete: 0,
|
||||
error: null,
|
||||
};
|
||||
|
||||
export default ViewportImageSliceLoadingIndicator;
|
||||
@@ -136,16 +136,6 @@ function ViewportOrientationMarkers({
|
||||
return <div className="ViewportOrientationMarkers select-none">{markers}</div>;
|
||||
}
|
||||
|
||||
ViewportOrientationMarkers.propTypes = {
|
||||
percentComplete: PropTypes.number,
|
||||
error: PropTypes.object,
|
||||
};
|
||||
|
||||
ViewportOrientationMarkers.defaultProps = {
|
||||
percentComplete: 0,
|
||||
error: null,
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Computes the orientation labels on a Cornerstone-enabled Viewport element
|
||||
|
||||
@@ -6,7 +6,7 @@ function _getVolumesFromViewport(viewport) {
|
||||
}
|
||||
|
||||
function _getVolumeFromViewport(viewport) {
|
||||
const volumes = _getVolumesFromViewport(viewport);
|
||||
const volumes = _getVolumesFromViewport(viewport).filter(volume => volume);
|
||||
const dynamicVolume = volumes.find(volume => volume.isDynamicVolume());
|
||||
|
||||
return dynamicVolume ?? volumes[0];
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
"dcmjs": "^0.29.12",
|
||||
"dicomweb-client": "^0.10.4",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^12.2.2",
|
||||
"react-window": "^1.8.9",
|
||||
"webpack": "^5.50.0",
|
||||
|
||||
@@ -2,7 +2,13 @@ import React, { useEffect, useState, useCallback } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { LayoutSelector as OHIFLayoutSelector, ToolbarButton } from '@ohif/ui';
|
||||
|
||||
function LegacyLayoutSelectorWithServices({ servicesManager, ...props }: withAppTypes) {
|
||||
function LegacyLayoutSelectorWithServices({
|
||||
servicesManager,
|
||||
rows = 3,
|
||||
columns = 3,
|
||||
onLayoutChange = () => {},
|
||||
...props
|
||||
}) {
|
||||
const { toolbarService } = servicesManager.services;
|
||||
|
||||
const onSelection = useCallback(
|
||||
@@ -78,10 +84,4 @@ LayoutSelector.propTypes = {
|
||||
servicesManager: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
LayoutSelector.defaultProps = {
|
||||
rows: 3,
|
||||
columns: 3,
|
||||
onLayoutChange: () => {},
|
||||
};
|
||||
|
||||
export default LegacyLayoutSelectorWithServices;
|
||||
@@ -124,8 +124,9 @@ function ToolbarLayoutSelectorWithServices({
|
||||
}
|
||||
|
||||
function LayoutSelector({
|
||||
rows,
|
||||
columns,
|
||||
rows = 3,
|
||||
columns = 4,
|
||||
onLayoutChange = () => {},
|
||||
className,
|
||||
onSelection,
|
||||
onSelectionPreset,
|
||||
@@ -242,10 +243,4 @@ LayoutSelector.propTypes = {
|
||||
servicesManager: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
LayoutSelector.defaultProps = {
|
||||
columns: 4,
|
||||
rows: 3,
|
||||
onLayoutChange: () => {},
|
||||
};
|
||||
|
||||
export default ToolbarLayoutSelectorWithServices;
|
||||
@@ -54,7 +54,6 @@ function ToolbarSplitButtonWithServices({
|
||||
}
|
||||
|
||||
ToolbarSplitButtonWithServices.propTypes = {
|
||||
isRadio: PropTypes.bool,
|
||||
groupId: PropTypes.string,
|
||||
primary: PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
@@ -87,9 +86,4 @@ ToolbarSplitButtonWithServices.propTypes = {
|
||||
}),
|
||||
};
|
||||
|
||||
ToolbarSplitButtonWithServices.defaultProps = {
|
||||
isRadio: false,
|
||||
isAction: false,
|
||||
};
|
||||
|
||||
export default ToolbarSplitButtonWithServices;
|
||||
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ToolbarButton } from '@ohif/ui';
|
||||
|
||||
function NestedMenu({ children, label, icon, isActive }) {
|
||||
function NestedMenu({ children, label = 'More', icon = 'tool-more-menu', isActive }) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const toggleNestedMenu = () => setIsOpen(!isOpen);
|
||||
@@ -39,9 +39,4 @@ NestedMenu.propTypes = {
|
||||
label: PropTypes.string,
|
||||
};
|
||||
|
||||
NestedMenu.defaultProps = {
|
||||
icon: 'tool-more-menu',
|
||||
label: 'More',
|
||||
};
|
||||
|
||||
export default NestedMenu;
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: ['inline-react-svg', '@babel/plugin-proposal-class-properties'],
|
||||
plugins: ['@babel/plugin-proposal-class-properties'],
|
||||
env: {
|
||||
test: {
|
||||
presets: [
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
"@ohif/i18n": "3.9.0-beta.21",
|
||||
"@ohif/ui": "3.9.0-beta.21",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^10.11.0",
|
||||
"react-router": "^6.8.1",
|
||||
"react-router-dom": "^6.8.1"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import React, { Component } from 'react';
|
||||
import ReactResizeDetector from 'react-resize-detector';
|
||||
import PropTypes from 'prop-types';
|
||||
import debounce from 'lodash.debounce';
|
||||
import { LoadingIndicatorProgress } from '@ohif/ui';
|
||||
|
||||
import './DicomMicroscopyViewport.css';
|
||||
@@ -23,18 +21,12 @@ class DicomMicroscopyViewport extends Component {
|
||||
|
||||
container = React.createRef();
|
||||
overlayElement = React.createRef();
|
||||
debouncedResize: () => any;
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
|
||||
const { microscopyService } = this.props.servicesManager.services;
|
||||
this.microscopyService = microscopyService;
|
||||
this.debouncedResize = debounce(() => {
|
||||
if (this.viewer) {
|
||||
this.viewer.resize();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
@@ -54,6 +46,7 @@ class DicomMicroscopyViewport extends Component {
|
||||
servicesManager: PropTypes.object,
|
||||
extensionManager: PropTypes.object,
|
||||
commandsManager: PropTypes.object,
|
||||
resizeRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -298,13 +291,16 @@ class DicomMicroscopyViewport extends Component {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{ReactResizeDetector && (
|
||||
<ReactResizeDetector handleWidth handleHeight onResize={this.onWindowResize} />
|
||||
)}
|
||||
{this.state.error ? (
|
||||
<h2>{JSON.stringify(this.state.error)}</h2>
|
||||
) : (
|
||||
<div style={style} ref={this.container} />
|
||||
<div
|
||||
style={style}
|
||||
ref={(ref: any) => {
|
||||
this.container.current = ref;
|
||||
this.props.resizeRef.current = ref;
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{this.state.isLoaded ? null : (
|
||||
<LoadingIndicatorProgress className={'h-full w-full bg-black'} />
|
||||
@@ -312,10 +308,6 @@ class DicomMicroscopyViewport extends Component {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onWindowResize = () => {
|
||||
this.debouncedResize();
|
||||
};
|
||||
}
|
||||
|
||||
export default DicomMicroscopyViewport;
|
||||
@@ -8,6 +8,8 @@ import { useViewportGrid } from '@ohif/ui';
|
||||
import getDicomMicroscopySopClassHandler from './DicomMicroscopySopClassHandler';
|
||||
import getDicomMicroscopySRSopClassHandler from './DicomMicroscopySRSopClassHandler';
|
||||
import MicroscopyService from './services/MicroscopyService';
|
||||
import { useResizeDetector } from 'react-resize-detector';
|
||||
import debounce from 'lodash.debounce';
|
||||
|
||||
const Component = React.lazy(() => {
|
||||
return import('./DicomMicroscopyViewport');
|
||||
@@ -59,14 +61,25 @@ const extension: Types.Extensions.Extension = {
|
||||
const [viewportGrid, viewportGridService] = useViewportGrid();
|
||||
const { activeViewportId } = viewportGrid;
|
||||
|
||||
// a unique identifier based on the contents of displaySets.
|
||||
// since we changed our rendering pipeline and if there is no
|
||||
// element size change nor viewportId change we won't re-render
|
||||
// we need a way to force re-rendering when displaySets change.
|
||||
const displaySetsKey = useMemo(() => {
|
||||
return props.displaySets.map(ds => ds.displaySetInstanceUID).join('-');
|
||||
}, [props.displaySets]);
|
||||
|
||||
const onResize = debounce(() => {
|
||||
const { microscopyService } = servicesManager.services;
|
||||
const managedViewer = microscopyService.getAllManagedViewers();
|
||||
|
||||
if (managedViewer && managedViewer.length > 0) {
|
||||
managedViewer[0].viewer.resize();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
const { ref: resizeRef } = useResizeDetector({
|
||||
onResize,
|
||||
handleHeight: true,
|
||||
handleWidth: true,
|
||||
});
|
||||
|
||||
return (
|
||||
<MicroscopyViewport
|
||||
key={displaySetsKey}
|
||||
@@ -78,6 +91,7 @@ const extension: Types.Extensions.Extension = {
|
||||
viewportGridService.setActiveViewportId(viewportId);
|
||||
}}
|
||||
viewportData={viewportOptions}
|
||||
resizeRef={resizeRef}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -628,6 +628,15 @@ export default class MicroscopyService extends PubSubService {
|
||||
setROIStyle(uid, styleOptions) {
|
||||
this.managedViewers.forEach(mv => mv.setROIStyle(uid, styleOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all managed viewers
|
||||
*
|
||||
* @returns {Array} managedViewers
|
||||
*/
|
||||
getAllManagedViewers() {
|
||||
return Array.from(this.managedViewers);
|
||||
}
|
||||
}
|
||||
|
||||
export { EVENTS };
|
||||
@@ -36,7 +36,7 @@
|
||||
"dicom-parser": "^1.8.9",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"dicom-parser": "^1.8.9",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
"dcmjs": "^0.29.12",
|
||||
"lodash.debounce": "^4.17.21",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"webpack": "^5.50.0",
|
||||
"webpack-merge": "^5.7.3"
|
||||
},
|
||||
|
||||
@@ -242,11 +242,6 @@ TrackedCornerstoneViewport.propTypes = {
|
||||
viewportId: PropTypes.string.isRequired,
|
||||
dataSource: PropTypes.object,
|
||||
children: PropTypes.node,
|
||||
customProps: PropTypes.object,
|
||||
};
|
||||
|
||||
TrackedCornerstoneViewport.defaultProps = {
|
||||
customProps: {},
|
||||
};
|
||||
|
||||
function _getNextMeasurementUID(
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"dicom-parser": "^1.8.9",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"dicom-parser": "^1.8.9",
|
||||
"hammerjs": "^2.0.8",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^17.0.2"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
|
||||
Reference in new issue
Block a user