linting fixed

pull/5370/head
iamsethsamuel 2 years ago
parent 874a7fef3c
commit 21bc7e6e7e
  1. 92
      libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
  2. 2
      libs/remix-ui/tree-view/src/types/index.ts
  3. 4
      libs/remix-ui/workspace/src/lib/components/file-render.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<HTMLLIElement>();
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<HTMLLIElement>, isDirectory: boolean,path: string) => {
event.preventDefault()
if (isDirectory) {
moveContext.moveFile( path);
}
};
const handleDragover = (
event: React.DragEvent<HTMLLIElement>,
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<HTMLLIElement>, path: string) => {
if (moveContext.dragged !== path) {
moveContext.currentlyMoved(path);
}
};
return (
<li draggable ref={dragRef} key={`treeViewLi${id}`} data-id={`treeViewLi${id}`} className="li_tv" {...otherProps} id={file ? file.path : ""}
onDragOver={event => {
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);
}
}}
>
<div
key={`treeViewDiv${id}`}
data-id={`treeViewDiv${id}`}
className={`d-flex flex-row align-items-center ${labelClass}`}
onClick={() => !controlBehaviour && setIsExpanded(!isExpanded)}
>
{children && showIcon ? (
<div
className={
isExpanded
? `px-1 ${iconY} caret caret_tv`
: `px-1 ${iconX} caret caret_tv`
}
style={{ visibility: children ? 'visible' : 'hidden' }}
></div>
) : icon ? (
<div className={`pr-3 pl-1 ${icon} caret caret_tv`}></div>
) : null}
<span className="w-100 pl-1">{label}</span>
<li ref={innerRef} key={`treeViewLi${id}`} data-id={`treeViewLi${id}`} className='li_tv' {...otherProps}>
<div key={`treeViewDiv${id}`} data-id={`treeViewDiv${id}`} className={`d-flex flex-row align-items-center ${labelClass}`} onClick={() => !controlBehaviour && setIsExpanded(!isExpanded)}>
{ children && showIcon ? <div className={isExpanded ? `px-1 ${iconY} caret caret_tv` : `px-1 ${iconX} caret caret_tv`} style={{ visibility: children ? 'visible' : 'hidden' }}></div> : icon ? <div className={`pr-3 pl-1 ${icon} caret caret_tv`}></div> : null }
<span className='w-100 pl-1'>
{ label }
</span>
</div>
{isExpanded ? children : null}
{ isExpanded ? children : null }
</li>
);
};
)
}
export default TreeViewItem;
export default TreeViewItem

@ -24,6 +24,4 @@ export interface TreeViewItemProps {
onBlur?: (...args: any) => void,
showIcon?: boolean
expandedPaths?: string[];
handleClickFolder?: (path: string, type: string) => void;
file?: any
}

@ -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}
/>
)

Loading…
Cancel
Save