drag and drop working

pull/2620/head
Seth Samuel 2 years ago
parent dfa83f8822
commit 1e875da4c2
  1. 6
      libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
  2. 4
      libs/remix-ui/tree-view/src/types/index.ts
  3. 13
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  4. 13
      libs/remix-ui/workspace/src/lib/contexts/index.ts

@ -1,11 +1,11 @@
import React, { useState, useEffect, useRef, useMemo, useContext } from 'react'; // eslint-disable-line
import React, { useState, useEffect, useRef, useContext } from 'react'; // eslint-disable-line
import { TreeViewItemProps } from '../../types';
import './tree-view-item.css';
import { MoveContext } from '../../../../workspace/src/lib/components/file-explorer'
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, innerRef, file, showIcon = true, ...otherProps } = props;
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)

@ -1,6 +1,4 @@
/* eslint-disable no-undef */
import { FileType } from 'libs/remix-ui/workspace/src/lib/types/index'
export interface TreeViewProps {
children?: React.ReactNode,
id?: string
@ -27,5 +25,5 @@ export interface TreeViewItemProps {
showIcon?: boolean
expandedPaths?: string[];
handleClickFolder?: (path: string, type: string) => void;
file?: FileType
file?: any
}

@ -10,18 +10,7 @@ import '../css/file-explorer.css'
import { checkSpecialChars, extractNameFromKey, extractParentFromKey, joinPath } from '@remix-ui/helper'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { FileRender } from './file-render'
interface MoveContextType{
dragged: string,
moveFile: (dest: string) => void
currentlyMoved: (path: string) => void
}
export const MoveContext = React.createContext<MoveContextType>({
dragged:"",
moveFile:( )=> {},
currentlyMoved: () => {}
})
import { MoveContext } from '../contexts'
export const FileExplorer = (props: FileExplorerProps) => {
const { name, contextMenuItems, removedContextMenuItems, files, fileState } = props

@ -33,3 +33,16 @@ export const FileSystemContext = createContext<{
dispatchMoveFile: (src: string, dest: string) => Promise<void>,
dispatchCloneRepository: (url: string) => Promise<void>
}>(null)
interface MoveContextType{
dragged: string,
moveFile: (dest: string) => void
currentlyMoved: (path: string) => void
}
export const MoveContext = createContext<MoveContextType>({
dragged:"",
moveFile:( )=> {},
currentlyMoved: () => {}
})
Loading…
Cancel
Save