From 7d6ce909ec6e347e628d8467501ad746d8c22d74 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 25 May 2023 11:32:19 +0200 Subject: [PATCH] remove uneeded --- .../src/lib/components/dropdown-submenu.tsx | 92 ------------------- 1 file changed, 92 deletions(-) delete mode 100644 libs/remix-ui/helper/src/lib/components/dropdown-submenu.tsx diff --git a/libs/remix-ui/helper/src/lib/components/dropdown-submenu.tsx b/libs/remix-ui/helper/src/lib/components/dropdown-submenu.tsx deleted file mode 100644 index 2647c0a7c9..0000000000 --- a/libs/remix-ui/helper/src/lib/components/dropdown-submenu.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import * as React from 'react'; -import {DropdownProps} from 'react-bootstrap/Dropdown'; -import {useRef} from "react"; - -interface Props extends DropdownProps { - id?: string; - className?: string; - href?: string; - title: string -} - -export const DropdownSubmenu: React.FC = (props:Props) => { - let refSubMenuContent = useRef(null as HTMLDivElement | null); - - let className = 'dropdown-submenu-container'; - className = props.className - ? className + ' ' + props.className - : className; - - const onClick = (event: React.SyntheticEvent) => { - event.preventDefault(); - event.stopPropagation(); - - if (refSubMenuContent.current) { - let show = false; - if (refSubMenuContent.current.classList.contains('show')) { - hideChildren(refSubMenuContent.current); - } else { - show = true; - hideSiblings(); - } - refSubMenuContent.current.classList.toggle('show'); - if (typeof props.onToggle === 'function') { - props.onToggle(show, event, { source: 'select'}); - } - } - }; - - const hideSiblings = () => { - if (refSubMenuContent.current) { - const parents = getParents( - refSubMenuContent.current, - '.dropdown-menu.show' - ); - if (parents.length > 1) { - hideChildren(parents[1]); - } - } - }; - - const hideChildren = (parent: any) => { - const children = parent.querySelectorAll('.dropdown-menu.show') as any; - for (const child of children) { - child.classList.remove('show'); - } - } - - const getParents = (elem: any, selector: string) => { - const nodes = []; - let element = elem; - nodes.push(element); - while (element.parentNode) { - if ( - typeof element.parentNode.matches === 'function' && - element.parentNode.matches(selector) - ) { - nodes.push(element.parentNode); - } - element = element.parentNode; - } - return nodes; - } - - return ( -
- - {props.title} - -
- {props.children} -
-
- ); - -} \ No newline at end of file