flattentree
filip mertens 11 months ago
parent d5313f76da
commit 5df3567529
  1. 4
      libs/remix-ui/workspace/src/lib/components/file-recursive-tree-item.tsx
  2. 4
      libs/remix-ui/workspace/src/lib/components/flat-tree-item-input.tsx
  3. 4
      libs/remix-ui/workspace/src/lib/components/flat-tree.tsx

@ -1,7 +1,7 @@
import { getPathIcon } from "@remix-ui/helper";
import React, { useEffect, useState } from "react";
import { FileType, WorkspaceElement } from "../types";
import { RecursiveItemInput } from "./file-recursive-item-input";
import { FlatTreeItemInput } from "./flat-tree-item-input";
interface RecursiveTreeItemProps {
file: FileType
@ -44,7 +44,7 @@ export const RecursiveTreeItem = (props: RecursiveTreeItemProps) => {
>
<div className={`pr-2 pl-2 ${file.isDirectory ? expandPath && expandPath.includes(file.path) ? 'fa fa-folder-open' : 'fa fa-folder' : getPathIcon(file.path)} caret caret_tv`}></div>
{focusEdit && file.path && focusEdit.element === file.path ?
<RecursiveItemInput editModeOff={editModeOff} file={file}/>:
<FlatTreeItemInput editModeOff={editModeOff} file={file}/>:
<span draggable="true" className="ml-1 pl-2" data-label-type={file.isDirectory ? 'folder' : 'file'} data-label-path={`${file.path}`}>{file.name}</span>}
</div>
<ul className="ul_tv ml-0 pl-1" >

@ -1,12 +1,12 @@
import React, { useState, useRef, useEffect } from "react"
import { FileType } from "../types"
interface RecursiveItemInputProps {
interface FlatTreeItemInputProps {
file: FileType
editModeOff: (content: string) => void
}
export const RecursiveItemInput = (props: RecursiveItemInputProps) => {
export const FlatTreeItemInput = (props: FlatTreeItemInputProps) => {
const { file, editModeOff } = props
const [value, setValue] = useState<string>(file.name)
const ref = useRef(null)

@ -4,7 +4,7 @@ import { FileType, WorkspaceElement } from '../types'
import { ROOT_PATH } from '../utils/constants'
import { getPathIcon } from '@remix-ui/helper';
import { Virtuoso } from 'react-virtuoso'
import { RecursiveItemInput } from './file-recursive-item-input';
import { FlatTreeItemInput } from './flat-tree-item-input';
import { FlatTreeDrop } from './flat-tree-drop';
import { getEventTarget } from '../utils/getEventTarget';
import { fileDecoration } from '@remix-ui/file-decorators';
@ -185,7 +185,7 @@ export const FlatTree = (props: FlatTreeProps) => {
<div className={`pr-2 pl-2 ${file.isDirectory ? expandPath && expandPath.includes(file.path) ? 'fa fa-folder-open' : 'fa fa-folder' : getPathIcon(file.path)} caret caret_tv`}></div>
{focusEdit && file.path && focusEdit.element === file.path ?
<RecursiveItemInput editModeOff={editModeOff} file={file}/>:
<FlatTreeItemInput editModeOff={editModeOff} file={file}/>:
<div draggable={true} onDragStart={onDragStart} onDragEnd={onDragEnd} className={`ml-1 pl-2 text-nowrap remixui_leaf ${getFileStateClasses(file)}`} data-label-type={file.isDirectory ? 'folder' : 'file'} data-label-path={`${file.path}`} key={index}>{file.name}
</div>}
</li>)

Loading…
Cancel
Save