feat(typings): Enhance typing support with withAppTypes and custom services throughout OHIF (#4090)

This commit is contained in:
Ibrahim authored and GitHub committed 2024-05-08 12:12:49 -04:00
1 parent b2cd0172d6
commit 374065bc3b
153 files changed
+842 -657

No files matched your search

@@ -1,9 +1,8 @@
import React, { useEffect, useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import { LayoutSelector as OHIFLayoutSelector, ToolbarButton } from '@ohif/ui';
import { ServicesManager } from '@ohif/core';
function LegacyLayoutSelectorWithServices({ servicesManager, ...props }) {
function LegacyLayoutSelectorWithServices({ servicesManager, ...props }: withAppTypes) {
const { toolbarService } = servicesManager.services;
const onSelection = useCallback(
@@ -76,7 +75,7 @@ LayoutSelector.propTypes = {
rows: PropTypes.number,
columns: PropTypes.number,
onLayoutChange: PropTypes.func,
servicesManager: PropTypes.instanceOf(ServicesManager),
servicesManager: PropTypes.object.isRequired,
};
LayoutSelector.defaultProps = {
@@ -1,7 +1,6 @@
import React, { useEffect, useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import { LayoutSelector as OHIFLayoutSelector, ToolbarButton, LayoutPreset } from '@ohif/ui';
import { ServicesManager } from '@ohif/core';
const defaultCommonPresets = [
{
@@ -45,7 +44,7 @@ const _areSelectorsValid = (hp, displaySets, hangingProtocolService) => {
);
};
const generateAdvancedPresets = ({ servicesManager }) => {
const generateAdvancedPresets = ({ servicesManager }: withAppTypes) => {
const { hangingProtocolService, viewportGridService, displaySetService } =
servicesManager.services;
@@ -84,7 +83,11 @@ const generateAdvancedPresets = ({ servicesManager }) => {
.filter(preset => preset !== null);
};
function ToolbarLayoutSelectorWithServices({ commandsManager, servicesManager, ...props }) {
function ToolbarLayoutSelectorWithServices({
commandsManager,
servicesManager,
...props
}: withAppTypes) {
const [isDisabled, setIsDisabled] = useState(false);
const handleMouseEnter = () => {
@@ -129,7 +132,7 @@ function LayoutSelector({
servicesManager,
tooltipDisabled,
...rest
}) {
}: withAppTypes) {
const [isOpen, setIsOpen] = useState(false);
const { customizationService } = servicesManager.services;
@@ -225,7 +228,7 @@ LayoutSelector.propTypes = {
rows: PropTypes.number,
columns: PropTypes.number,
onLayoutChange: PropTypes.func,
servicesManager: PropTypes.instanceOf(ServicesManager),
servicesManager: PropTypes.object.isRequired,
};
LayoutSelector.defaultProps = {
@@ -10,7 +10,7 @@ function ToolbarSplitButtonWithServices({
renderer,
onInteraction,
servicesManager,
}) {
}: withAppTypes) {
const { toolbarService } = servicesManager?.services;
/* Bubbles up individual item clicks */