diff --git a/package-lock.json b/package-lock.json index a0b8bbff..6bcb9400 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "react-copy-to-clipboard": "^5.0.4", "react-datepicker": "^4.7.0", "react-dom": "^18.1.0", - "react-external-link": "^1.2.2", + "react-external-link": "^2.0.0", "react-leaflet": "^4.0.0", "react-redux": "^8.0.0", "react-router-dom": "^6.3.0", @@ -19960,12 +19960,12 @@ "dev": true }, "node_modules/react-external-link": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/react-external-link/-/react-external-link-1.2.2.tgz", - "integrity": "sha512-CbJidnDmhcKlH5gVyt2dbmylcwayMY1wuRW8J1V1o7ZPMHdoUrDDmh/GvAMe847eI3sQBg7PLwSLAl5GiyuI+g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/react-external-link/-/react-external-link-2.0.0.tgz", + "integrity": "sha512-Q/Lso75l6OHOTvmhJ2YhnfN2f/0RJw76C4rEFkiiivNApNvCtyAFythdW4SpXHMPK6bbE8kk4j23+Zx+r1ImbA==", "peerDependencies": { - "react": "^17.0", - "react-dom": "^17.0" + "react": "^17.0 || ^18.0", + "react-dom": "^17.0 || ^18.0" } }, "node_modules/react-fast-compare": { @@ -41730,9 +41730,9 @@ "dev": true }, "react-external-link": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/react-external-link/-/react-external-link-1.2.2.tgz", - "integrity": "sha512-CbJidnDmhcKlH5gVyt2dbmylcwayMY1wuRW8J1V1o7ZPMHdoUrDDmh/GvAMe847eI3sQBg7PLwSLAl5GiyuI+g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/react-external-link/-/react-external-link-2.0.0.tgz", + "integrity": "sha512-Q/Lso75l6OHOTvmhJ2YhnfN2f/0RJw76C4rEFkiiivNApNvCtyAFythdW4SpXHMPK6bbE8kk4j23+Zx+r1ImbA==", "requires": {} }, "react-fast-compare": { diff --git a/package.json b/package.json index 7b2c39c8..93dcb97d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "react-copy-to-clipboard": "^5.0.4", "react-datepicker": "^4.7.0", "react-dom": "^18.1.0", - "react-external-link": "^1.2.2", + "react-external-link": "^2.0.0", "react-leaflet": "^4.0.0", "react-redux": "^8.0.0", "react-router-dom": "^6.3.0", diff --git a/src/utils/TooltipToggleSwitch.tsx b/src/utils/TooltipToggleSwitch.tsx deleted file mode 100644 index 35d2889b..00000000 --- a/src/utils/TooltipToggleSwitch.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { FC, PropsWithChildren, useRef } from 'react'; -import { UncontrolledTooltip, UncontrolledTooltipProps } from 'reactstrap'; -import { BooleanControlProps } from './BooleanControl'; -import ToggleSwitch from './ToggleSwitch'; - -export type TooltipToggleSwitchProps = BooleanControlProps & PropsWithChildren<{ - tooltip?: Omit; -}>; - -export const TooltipToggleSwitch: FC = ({ children, tooltip = {}, ...rest }) => { - const ref = useRef(); - - return ( - <> - { - ref.current = el ?? undefined; - }} - > - - - ref.current) as any} {...tooltip}>{children} - - ); -}; diff --git a/test/utils/TooltipToggleSwitch.test.tsx b/test/utils/TooltipToggleSwitch.test.tsx deleted file mode 100644 index 6d619fb3..00000000 --- a/test/utils/TooltipToggleSwitch.test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { shallow, ShallowWrapper } from 'enzyme'; -import { PropsWithChildren } from 'react'; -import { UncontrolledTooltip } from 'reactstrap'; -import { TooltipToggleSwitch, TooltipToggleSwitchProps } from '../../src/utils/TooltipToggleSwitch'; -import ToggleSwitch from '../../src/utils/ToggleSwitch'; - -describe('', () => { - let wrapper: ShallowWrapper; - const createWrapper = (props: PropsWithChildren = {}) => { - wrapper = shallow(); - - return wrapper; - }; - - afterEach(() => wrapper?.unmount()); - - it.each([ - ['foo'], - ['bar'], - ['baz'], - ])('shows children inside tooltip', (children) => { - const wrapper = createWrapper({ children }); - const tooltip = wrapper.find(UncontrolledTooltip); - - expect(tooltip.prop('children')).toEqual(children); - }); - - it('properly propagates corresponding props to every component', () => { - const expectedTooltipProps = { placement: 'left', delay: 30 }; - const expectedToggleProps = { checked: true, className: 'foo' }; - const wrapper = createWrapper({ tooltip: expectedTooltipProps, ...expectedToggleProps }); - const tooltip = wrapper.find(UncontrolledTooltip); - const toggle = wrapper.find(ToggleSwitch); - - expect(tooltip.props()).toEqual(expect.objectContaining(expectedTooltipProps)); - expect(toggle.props()).toEqual(expect.objectContaining(expectedToggleProps)); - }); -});