import React from "react"; import { AllTreeRenderProps } from "../types"; const cx = (...classNames: Array) => classNames.filter((cn) => !!cn).join(" "); export const createDefaultRenderers = (renderDepthOffset: number): 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)} )} ); }, renderItem: ({ item, depth, children, title, context }) => { const InteractiveComponent = context.isRenaming ? "div" : "button"; const type = context.isRenaming ? undefined : "button"; // TODO have only root li component create all the classes return (
  • {title}
    {children}
  • ); }, renderRenameInput: ({ inputProps, inputRef, submitButtonProps, submitButtonRef, formProps }) => (
    ), renderDraggingItem: () =>
    , renderDraggingItemTitle: () =>
    , renderTreeContainer: ({ children, containerProps, info }) => (
    {children}
    ), renderItemsContainer: ({ children, containerProps }) => (
      {children}
    ), renderSearchInput: ({ inputProps }) => (
    ), renderLiveDescriptorContainer: ({ tree, children }) => (
    {children}
    ), renderDepthOffset, });