import React from 'react'; import { AllTreeRenderProps } from '../types'; const cx = (...classNames: Array) => classNames.filter(cn => !!cn).join(' '); export const createDefaultRenderers = ( renderDepthOffset: number, rtl?: boolean ): AllTreeRenderProps => ({ renderItemTitle: ({ title, context, info }) => { if (!info.isSearching || !context.isSearchMatching) { return title; } const startIndex = title.toLowerCase().indexOf(info.search!.toLowerCase()); return ( <> {startIndex > 0 && {title.slice(0, startIndex)}} {title.slice(startIndex, startIndex + info.search!.length)} {startIndex + info.search!.length < title.length && ( {title.slice(startIndex + info.search!.length, title.length)} )} ); }, renderItemArrow: ({ item, context }) => ( // Icons from https://blueprintjs.com/docs/#icons
{item.isFolder && (context.isExpanded ? ( ) : ( ))}
), renderItem: ({ item, depth, children, title, context, arrow }) => { const InteractiveComponent = context.isRenaming ? 'div' : 'button'; const type = context.isRenaming ? undefined : 'button'; // TODO have only root li component create all the classes return (
  • {arrow} {title}
    {children}
  • ); }, renderRenameInput: ({ inputProps, inputRef, submitButtonProps, submitButtonRef, formProps, }) => (
    ), renderTreeContainer: ({ children, containerProps, info }) => (
    {children}
    ), renderItemsContainer: ({ children, containerProps }) => ( ), renderDragBetweenLine: ({ draggingPosition, lineProps }) => (
    ), renderSearchInput: ({ inputProps }) => (
    ), renderLiveDescriptorContainer: ({ tree, children }) => (
    {children}
    ), renderDepthOffset, });