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
@@ -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}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user