diff --git a/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx b/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx index ead7268c0a..bf60d4cd4f 100644 --- a/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx +++ b/libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx @@ -1,83 +1,27 @@ -import React, { useState, useEffect, useRef, useContext } from 'react'; // eslint-disable-line -import { TreeViewItemProps } from '../../types'; +import React, { useState, useEffect } from 'react' // eslint-disable-line +import { TreeViewItemProps } from '../../types' + +import './tree-view-item.css' -import './tree-view-item.css'; -import { MoveContext } from '@remix-ui/workspace' - export const TreeViewItem = (props: TreeViewItemProps) => { - const { id, children, label, labelClass, expand, iconX = 'fas fa-caret-right', iconY = 'fas fa-caret-down', icon, controlBehaviour = false, file, showIcon = true, ...otherProps } = props; - const [isExpanded, setIsExpanded] = useState(false); - const dragRef = useRef(); - const moveContext = useContext(MoveContext) + const { id, children, label, labelClass, expand, iconX = 'fas fa-caret-right', iconY = 'fas fa-caret-down', icon, controlBehaviour = false, innerRef, showIcon = true, ...otherProps } = props + const [isExpanded, setIsExpanded] = useState(false) useEffect(() => { - setIsExpanded(expand); - }, [expand]); - - const handleDrop = (event: React.DragEvent, isDirectory: boolean,path: string) => { - event.preventDefault() - - if (isDirectory) { - moveContext.moveFile( path); - } - }; - - const handleDragover = ( - event: React.DragEvent, - isDirectory: boolean, - path: string, - type: string - ) => { - //Checks if the folder is opened - event.preventDefault(); - if (isDirectory !== null && !props.expandedPaths.includes(path)) { - props.handleClickFolder(path, type); - } - }; - + setIsExpanded(expand) + }, [expand]) - const handleDrag = (event: React.DragEvent, path: string) => { - if (moveContext.dragged !== path) { - moveContext.currentlyMoved(path); - } - }; - return ( -
  • { - if (file && file.isDirectory) { - handleDragover(event, file.isDirectory, file.path, file.type); - }}} - onDrop={(event) => {handleDrop(event, file ? file.isDirectory : false ,file ? file.path : null)}} - onDragStart={event => { - if (file) { - handleDrag(event, file.path); - } - }} - > -
    !controlBehaviour && setIsExpanded(!isExpanded)} - > - {children && showIcon ? ( -
    - ) : icon ? ( -
    - ) : null} - {label} +
  • +
    !controlBehaviour && setIsExpanded(!isExpanded)}> + { children && showIcon ?
    : icon ?
    : null } + + { label } +
    - {isExpanded ? children : null} + { isExpanded ? children : null }
  • - ); -}; + ) +} -export default TreeViewItem; +export default TreeViewItem \ No newline at end of file diff --git a/libs/remix-ui/tree-view/src/types/index.ts b/libs/remix-ui/tree-view/src/types/index.ts index 1248e7ad5a..9827b7f2d4 100644 --- a/libs/remix-ui/tree-view/src/types/index.ts +++ b/libs/remix-ui/tree-view/src/types/index.ts @@ -24,6 +24,4 @@ export interface TreeViewItemProps { onBlur?: (...args: any) => void, showIcon?: boolean expandedPaths?: string[]; - handleClickFolder?: (path: string, type: string) => void; - file?: any } diff --git a/libs/remix-ui/workspace/src/lib/components/file-render.tsx b/libs/remix-ui/workspace/src/lib/components/file-render.tsx index 5a9f3652b7..ef1e2329fa 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-render.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-render.tsx @@ -90,8 +90,6 @@ export const FileRender = (props: RenderFileProps) => { expand={props.expandPath.includes(file.path)} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut} - file={file} - handleClickFolder={props.handleClickFolder} expandedPaths={props.expandPath} > { @@ -135,8 +133,6 @@ export const FileRender = (props: RenderFileProps) => { labelClass={labelClass} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut} - file={file} - handleClickFolder={props.handleClickFolder} expandedPaths={props.expandPath} /> )