1.0.8 • Published 2 years ago

@code4bones/react-c4b-ui v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Component Library - code4bones react UI

Components

ComponentDescription
TreeMenuNavigation Menu Tree

react-c4b-ui

npm npm

npm.io npm.io npm.io npm.io npm.io

Links

Change log

System default / custom theme

sample

featuresample
cap
capcap

Install

$ yarn add @code4bones/react-c4b-ui

TreeMenu

Brief

import  {TreeMenu, TreeMenuActions,TreeMenuItem }  from "@code4bones/react-c4b-ui";
import "@code4bones/react-c4b-ui/build/styles.css";

const ITEMS : TreeMenuItem[] = [{
  id:"item1",
  title:"Item 1",
  // other TreeMenuItem's props
    childs:[{
     id:"sub",
     title:"Subitem 1",
   }]
}];

// if your need to use exponsed actions
const ref = createRef<TreeMenuActions>();

<TreeMenu
  ref={ref}
  items={ITEMS}
  onClick={onClick} 
/>

Properties

type RenderFn = (item:MenuItem) => React.ReactElement | undefined | null; type RenderType = RenderFn | React.ReactElement;

Propery nameDescriptionSignature
items[]tree menu items arrayTreeMenuItem[]
refhandle to TreeMenu methodsTreeMenuActions
onClickitem click handleronClick?:(item:TreeMenuItem) => void
onTogglecollapse / expandonToggle?:(id?:string,collapsed?:boolean) => void;
initialCollapsedinitial tree stateboolean
initialSelectedinitial selected itemitem's id : string
renderBadgeitem click handlerRenderType
renderIconLeft side element of itemRenderType
renderGroupStateGroup indicatorRenderType
themetheme override class namedark, light, custom name
classPrefixcontainer global prefixstring
enableRotateRotate collapse / expandboolean

TreeMenuItem

    id:string;
    title:string | React.ReactElement;
    info?:string | React.ReactElement;
    infoReveal?:InfoReveal;
    icon?:React.ReactElement;
    badge?:string | React.ReactElement;
    disabled?:boolean;
    unselectable?:boolean;
    titleClass?:string;
    infoClass?:string;
    style?:React.CSSProperties;
    titleStyle?:React.CSSProperties;
    infoStyle?:React.CSSProperties;

TreeMenuActions ( use ref )

    enable:(id:string,disable?:boolean) => void;
    getItem:(id:string) => TreeMenuItem | null;
    collapse:(id:string,collapsed?:boolean) => void;
    select:(id:string) => void;

Sample

Sample available via storybook yarn storybook