From 5eed756272c55f67aa0227bee6926fff7941ba21 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 21 Aug 2024 10:14:45 +0530 Subject: [PATCH] Remove unused components and packages (#8339) * Remove unused `Transition` block and other unused packages * remove unused tooltip component --- package-lock.json | 72 ------------- package.json | 5 - src/Components/Common/Transition.tsx | 134 ------------------------ src/Components/Common/utils/Tooltip.tsx | 50 --------- 4 files changed, 261 deletions(-) delete mode 100644 src/Components/Common/Transition.tsx delete mode 100644 src/Components/Common/utils/Tooltip.tsx diff --git a/package-lock.json b/package-lock.json index 0c59edd073e..ba448d666e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,6 @@ "react-pdf": "^9.0.0", "react-player": "^2.16.0", "react-redux": "^8.1.1", - "react-transition-group": "^4.4.5", "react-webcam": "^7.2.0", "redux": "^4.2.1", "redux-thunk": "^2.4.2", @@ -62,8 +61,6 @@ "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", - "@types/cypress": "^1.1.3", - "@types/echarts": "^4.9.22", "@types/google.maps": "^3.55.8", "@types/lodash-es": "^4.17.12", "@types/qrcode.react": "^1.0.5", @@ -72,8 +69,6 @@ "@types/react-csv": "^1.1.10", "@types/react-dom": "^18.3.0", "@types/react-google-recaptcha": "^2.1.9", - "@types/react-qr-reader": "^2.1.7", - "@types/react-transition-group": "^4.4.10", "@typescript-eslint/eslint-plugin": "^7.18.0", "@vitejs/plugin-react-swc": "^3.6.0", "autoprefixer": "^10.4.19", @@ -6546,16 +6541,6 @@ "@types/node": "*" } }, - "node_modules/@types/cypress": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@types/cypress/-/cypress-1.1.3.tgz", - "integrity": "sha512-OXe0Gw8LeCflkG1oPgFpyrYWJmEKqYncBsD/J0r17r0ETx/TnIGDNLwXt/pFYSYuYTpzcq1q3g62M9DrfsBL4g==", - "deprecated": "This is a stub types definition for cypress (https://cypress.io). cypress provides its own type definitions, so you don't need @types/cypress installed!", - "dev": true, - "dependencies": { - "cypress": "*" - } - }, "node_modules/@types/debug": { "version": "4.1.12", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", @@ -6582,15 +6567,6 @@ "integrity": "sha512-w5jZ0ee+HaPOaX25X2/2oGR/7rgAQSYII7X7pp0m9KgBfMP7uKfMfTvcpl5Dj+eDBbpxKGiqE+flqDr6XTd2RA==", "dev": true }, - "node_modules/@types/echarts": { - "version": "4.9.22", - "resolved": "https://registry.npmjs.org/@types/echarts/-/echarts-4.9.22.tgz", - "integrity": "sha512-7Fo6XdWpoi8jxkwP7BARUOM7riq8bMhmsCtSG8gzUcJmFhLo387tihoBYS/y5j7jl3PENT5RxeWZdN9RiwO7HQ==", - "dev": true, - "dependencies": { - "@types/zrender": "*" - } - }, "node_modules/@types/ejs": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.5.tgz", @@ -6875,24 +6851,6 @@ "@types/react": "*" } }, - "node_modules/@types/react-qr-reader": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/@types/react-qr-reader/-/react-qr-reader-2.1.7.tgz", - "integrity": "sha512-6K6DQeqP7c2oohcfvBpExlOawVsB2/C+7ZZL/fkCkNzYYAKDJnNHnuP3F5ChMl0mpoYEdqkqkllxqfM0VslEiw==", - "dev": true, - "dependencies": { - "@types/react": "*" - } - }, - "node_modules/@types/react-transition-group": { - "version": "4.4.10", - "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.10.tgz", - "integrity": "sha512-hT/+s0VQs2ojCX823m60m5f0sL5idt9SO6Tj6Dg+rdphGPIeJbJ6CxvBYkgkGKrYeDjvIpKTR38UzmtHJOGW3Q==", - "dev": true, - "dependencies": { - "@types/react": "*" - } - }, "node_modules/@types/resolve": { "version": "1.20.6", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.6.tgz", @@ -6977,12 +6935,6 @@ "@types/node": "*" } }, - "node_modules/@types/zrender": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@types/zrender/-/zrender-4.0.6.tgz", - "integrity": "sha512-1jZ9bJn2BsfmYFPBHtl5o3uV+ILejAtGrDcYSpT4qaVKEI/0YY+arw3XHU04Ebd8Nca3SQ7uNcLaqiL+tTFVMg==", - "dev": true - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.18.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz", @@ -10330,15 +10282,6 @@ "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "dev": true }, - "node_modules/dom-helpers": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", - "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", - "dependencies": { - "@babel/runtime": "^7.8.7", - "csstype": "^3.0.2" - } - }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -19805,21 +19748,6 @@ } } }, - "node_modules/react-transition-group": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", - "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==", - "dependencies": { - "@babel/runtime": "^7.5.5", - "dom-helpers": "^5.0.1", - "loose-envify": "^1.4.0", - "prop-types": "^15.6.2" - }, - "peerDependencies": { - "react": ">=16.6.0", - "react-dom": ">=16.6.0" - } - }, "node_modules/react-webcam": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/react-webcam/-/react-webcam-7.2.0.tgz", diff --git a/package.json b/package.json index e9f22f98b16..ccb91dfcbae 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,6 @@ "react-pdf": "^9.0.0", "react-player": "^2.16.0", "react-redux": "^8.1.1", - "react-transition-group": "^4.4.5", "react-webcam": "^7.2.0", "redux": "^4.2.1", "redux-thunk": "^2.4.2", @@ -98,8 +97,6 @@ "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", - "@types/cypress": "^1.1.3", - "@types/echarts": "^4.9.22", "@types/google.maps": "^3.55.8", "@types/lodash-es": "^4.17.12", "@types/qrcode.react": "^1.0.5", @@ -108,8 +105,6 @@ "@types/react-csv": "^1.1.10", "@types/react-dom": "^18.3.0", "@types/react-google-recaptcha": "^2.1.9", - "@types/react-qr-reader": "^2.1.7", - "@types/react-transition-group": "^4.4.10", "@typescript-eslint/eslint-plugin": "^7.18.0", "@vitejs/plugin-react-swc": "^3.6.0", "autoprefixer": "^10.4.19", diff --git a/src/Components/Common/Transition.tsx b/src/Components/Common/Transition.tsx deleted file mode 100644 index 7f5830d47db..00000000000 --- a/src/Components/Common/Transition.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import { CSSTransition as ReactCSSTransition } from "react-transition-group"; -import { createContext, useContext, useEffect, useRef } from "react"; - -type TransitionContextProps = { - parent: { - show: boolean; - isInitialRender: boolean; - appear?: boolean; - }; -}; - -const TransitionContext = createContext>({ - parent: { - show: false, - isInitialRender: true, - }, -}); - -function useIsInitialRender() { - const isInitialRender = useRef(true); - useEffect(() => { - isInitialRender.current = false; - }, []); - return isInitialRender.current; -} - -interface TransitionProps { - show?: boolean; - enter?: string; - enterFrom?: string; - enterTo?: string; - leave?: string; - leaveFrom?: string; - leaveTo?: string; - appear?: boolean; - children: React.ReactNode; -} - -function CSSTransition({ - show, - enter = "", - enterFrom = "", - enterTo = "", - leave = "", - leaveFrom = "", - leaveTo = "", - appear, - children, -}: TransitionProps) { - const enterClasses = enter.split(" ").filter((s) => s.length); - const enterFromClasses = enterFrom.split(" ").filter((s) => s.length); - const enterToClasses = enterTo.split(" ").filter((s) => s.length); - const leaveClasses = leave.split(" ").filter((s) => s.length); - const leaveFromClasses = leaveFrom.split(" ").filter((s) => s.length); - const leaveToClasses = leaveTo.split(" ").filter((s) => s.length); - - function addClasses(node: HTMLElement, classes: string[]): void { - if (classes.length) { - node.classList.add(...classes); - } - } - - function removeClasses(node: HTMLElement, classes: string[]): void { - if (classes.length) { - node.classList.remove(...classes); - } - } - - return ( - { - node.addEventListener("transitionend", done, false); - }} - onEnter={(node: any) => { - addClasses(node, [...enterClasses, ...enterFromClasses]); - }} - onEntering={(node: any) => { - removeClasses(node, enterFromClasses); - addClasses(node, enterToClasses); - }} - onEntered={(node: any) => { - removeClasses(node, [...enterToClasses, ...enterClasses]); - }} - onExit={(node: any) => { - addClasses(node, [...leaveClasses, ...leaveFromClasses]); - }} - onExiting={(node: any) => { - removeClasses(node, leaveFromClasses); - addClasses(node, leaveToClasses); - }} - onExited={(node: any) => { - removeClasses(node, [...leaveToClasses, ...leaveClasses]); - }} - > - {children} - - ); -} - -function Transition({ show, appear, ...rest }: TransitionProps) { - const { parent } = useContext(TransitionContext); - const isInitialRender = useIsInitialRender(); - const isChild = show === undefined; - - if (isChild) { - return ( - - ); - } - - return ( - - - - ); -} - -export default Transition; diff --git a/src/Components/Common/utils/Tooltip.tsx b/src/Components/Common/utils/Tooltip.tsx deleted file mode 100644 index 2257b9b28b6..00000000000 --- a/src/Components/Common/utils/Tooltip.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { ReactNode, useState } from "react"; -import { classNames } from "../../../Utils/utils"; - -interface TooltipProps { - children: ReactNode; - text: ReactNode; - position?: "TOP" | "BOTTOM" | "LEFT" | "RIGHT" | "CUSTOM"; - className?: string; -} - -/** - * Deprecated. Use `tooltip` and `tooltip-text` with `tooltip-{left/right/top/bottom}` classes on elements. - * - * **Example:** - * ```html - * - * ``` - */ -export default function ToolTip(props: TooltipProps) { - const position = props.position || "TOP"; - - const [status, show] = useState(false); - - const style = classNames( - "absolute z-50 block w-[150px] rounded bg-black/50 px-2 py-1 text-center text-white backdrop-blur transition", - position === "TOP" && "bottom-[calc(100%+5px)] left-[calc(50%-75px)]", - position === "BOTTOM" && "left-[calc(50%-75px)] top-[calc(100%+5px)]", - position === "LEFT" && "right-[calc(100%+5px)] top-[calc(50%-75px)]", - position === "RIGHT" && "left-[calc(100%+5px)] top-[calc(50%-75px)]", - status === true - ? "visible -translate-y-1 opacity-100" - : "invisible translate-y-0 opacity-0", - props.className && props.className, - ); - - return ( -
show(true)} - onMouseLeave={() => show(false)} - > -
{props.text}
- {props.children} -
- ); -}