1.0.7 • Published 1 year ago

@illa-design/tree v1.0.7

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

Tree

Tree is used to show the hierarchy of content with more levels.

Installation

yarn add @illa-design/tree

Import component

import { Tree } from "@illa-design/tree"

API

Tree Basic Properties

PropsDescTypeDefault
treeDataGenerate tree structure by structured dataTreeDataType[]-
sizeSet size"small" | "medium" | "large""medium"
blockNodeWhether treeNode fill the remaining horizontal spaceboolean-
autoExpandParentWhether to automatically expand a parent treeNodebooleantrue
multipleWhether to allow selecting multiple treeNodesboolean-
checkableWhether to add a Checkbox before the treeNodesboolean-
selectableWhether treeNode can be selectedbooleantrue
draggableWhether treeNode can be dragedboolean-
showLineWhether show a connecting line between treeNodesboolean-
loadingIconCustomize a icon before treeNodes titleReactNode-
switcherIconCustomize the switcher iconReactNode-
dragIconCustomize the drag icon after treeNode titleReactNode-
checkStrictlywhether associate parent treeNode and children treeNode when they are checkableboolean-
defaultSelectedKeysSet default selected treeNodesstring[]-
selectedKeysSet selected treeNodes by treeNodes' keystring[]-
defaultCheckedKeysSet default checked treeNodes by treeNodes' keystring[]-
checkedKeysSet checked treeNodes by treeNodes' keystring[]-
defaultExpandedKeysSet default expanded treeNodes by treeNodes' keystring[]-
expandedKeysSet default treeNodes by treeNodes' keystring[]-
loadMoreCallback when loaded data asynchronously, returning a Promise.(node: NodeInstance) => Promise<void>-

Tree Events

PropsDescTypeDefault
onSelectCallback when treeNode is selected(selectedKeys: string[],extra: {selected: boolean;selectedNodes: NodeInstance[];node: NodeInstance;e: Event;}) => void-
onCheckCallback when treeNode is checked(checkedKeys: string[],extra: {node: NodeInstance;checkedNodes: NodeInstance[];checked: boolean;halfCheckedKeys: string[];halfCheckedNodes: NodeInstance[];e: Event;}) => void-
onExpandCallback when treeNode is expanded(expandedKeys: string[],exra?: { expanded: boolean; node: NodeInstance; expandedNodes: NodeInstance[] }) => void-
onDropCallback when treeNode is dropped(info: {e: DragEvent<HTMLSpanElement>;dragNode: NodeInstance \| null;dropNode: NodeInstance \| null;dropPosition: number;}) => void-
onDragStartCallback when the treeNode starts dragged(e: DragEvent<HTMLSpanElement>, node: NodeInstance) => void-
onDragEndCallback when the treeNode ends dragged(e: DragEvent<HTMLSpanElement>, node: NodeInstance) => void-
onDragOverCallback when the treeNode is dragged onto a valid target(e: DragEvent<HTMLSpanElement>, node: NodeInstance) => void-
onDragLeaveCallback when the treeNode leaves a valid target(e: DragEvent<HTMLSpanElement>, node: NodeInstance) => void-

TreeNode Basic Properties

PropsDescTypeDefault
titleTitle of treeNodestring | ReactNode-
selectablewhether the treeNode can be selectedbooleantrue
disabledwhether the treeNode is disabledboolean-
disableCheckboxwhether disable the treeNode is checkableboolean-
iconset treeNode’s icon before titleReactNode-
checkablewhether to show checkbox before treeNodeboolean-
isLeafwhether the treeNode is a leafboolean-
draggablewhether the treeNode is draggableboolean-

TreeDataType

key?: string
title?: string
children?: TreeDataType[]
selectable?: boolean
disabled?: boolean
disableCheckbox?: boolean
icon?: boolean
checkable?: boolean
isLeaf?: boolean
draggable?: boolean

Example

Basic usage

const TreeData = [
  {
    title: 'Trunk 0-0',
    key: '0-0',
    children: [
      {
        title: 'Leaf',
        key: '0-0-1',
      },
      {
        title: 'Branch 0-0-2',
        key: '0-0-2',
        disableCheckbox: true,
        children: [
          {
            title: 'Leaf',
            key: '0-0-2-1'
          }
        ]
      },
    ],
  },
  {
    title: 'Trunk 0-1',
    key: '0-1',
    children: [
      {
        title: 'Branch 0-1-1',
        key: '0-1-1',
        checkable: false,
        children: [
          {
            title: 'Leaf',
            key: '0-1-1-1',
          },
          {
            title: 'Leaf',
            key: '0-1-1-2',
          },
        ]
      },
      {
        title: 'Leaf',
        key: '0-1-2',
      },
    ],
  },
];
<Tree
  multiple
  treeData={TreeData}
/>
1.0.7

1 year ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.9

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago