|
1 | | -### TreeMenu / PropertyGrid |
| 1 | +### Cascade Forms |
2 | 2 |
|
3 | | -  |
| 3 | +  |
4 | 4 |
|
5 | | -### System default / Custom theme |
6 | | - |
7 | | - |
8 | | - |
9 | | -|feature|sample| |
10 | | -|-------|------| |
11 | | -|| | |
12 | | -|| |
13 | 5 |
|
14 | 6 | clone, samples available via `yarn storybook` |
15 | 7 |
|
16 | 8 | #### Brief |
17 | 9 |
|
18 | | -yarn add `@code4bones/react-tree-menu-property-grid` |
19 | | - |
20 | | -```tsx |
21 | | - |
22 | | -import {TreeMenu, TreeMenuActions,TreeMenuItem } from "@code4bones/react-tree-menu-property-grid"; |
23 | | -import "@code4bones/react-tree-menu-property-grid/build/styles.css"; |
24 | | - |
25 | | -const ITEMS : TreeMenuItem[] = [{ |
26 | | - id:"item1", |
27 | | - title:"Item 1", |
28 | | - // other TreeMenuItem's props |
29 | | - childs:[{ |
30 | | - id:"sub", |
31 | | - title:"Subitem 1", |
32 | | - }] |
33 | | -}]; |
34 | | - |
35 | | -// if your need to use exponsed actions |
36 | | -const ref = createRef<TreeMenuActions>(); |
37 | | - |
38 | | -<TreeMenu |
39 | | - ref={ref} |
40 | | - items={ITEMS} |
41 | | - onClick={onClick} |
42 | | -/> |
43 | | - |
44 | | -``` |
45 | | - |
46 | | -### Properties |
47 | | - |
48 | | -type `RenderFn` = (item:MenuItem) => React.ReactElement | undefined | null; |
49 | | -type `RenderType` = `RenderFn` | React.ReactElement; |
50 | | - |
51 | | - |
52 | | -| Propery name | Description | Signature |
53 | | -| ------------- | ------------------------------ | ---- | |
54 | | -| `treeID` | tree id | string | |
55 | | -| `propertyGrid` | property grid mode | boolean | |
56 | | -| `items[]` | tree menu items array | `TreeMenuItem`[] | |
57 | | -| `ref` | handle to TreeMenu methods | `TreeMenuActions` | |
58 | | -| `initialCollapsed` | initial tree state | boolean | |
59 | | -| `initialSelected` | initial selected item | item's `id` : string| |
60 | | -| `theme` | theme override class name | `dark`, `light`, custom name | |
61 | | -| `classPrefix` | container global prefix | string | |
62 | | -| `enableRotate` | Rotate collapse / expand icon| boolean | |
63 | | -| `infoStyle` | global custom style | boolean | |
64 | | -| `titleStyle` | global custom style | boolean | |
65 | | -| `infoReveal` | global info display modes | "always" | "vertical" | "horizontal" | |
66 | | -| `badgeVisible` | display badge | boolean | |
67 | | -| `groupIconLeft` | group icon position | boolean | |
68 | | -| `onClick` | item click handler | onClick?:(item:TreeMenuItem) => void| |
69 | | -| `onToggle` | collapse / expand | onToggle?:(id?:string,collapsed?:boolean) => void;| |
70 | | -| `renderBadge` | item click handler | `RenderType` | |
71 | | -| `renderIcon` | Left side element of item | `RenderType` | |
72 | | -| `renderGroupState` | Group indicator | `RenderType` | |
73 | | - |
74 | | - |
75 | | -`TreeMenuItem` |
76 | | - |
77 | | -```tsx |
78 | | - id:string; |
79 | | - title:string | React.ReactElement; |
80 | | - info?:string | React.ReactElement; |
81 | | - badge?:string | React.ReactElement; |
82 | | - control?:string | JSX.Element; |
83 | | - infoReveal?:InfoReveal; |
84 | | - icon?:React.ReactElement; |
85 | | - badge?:string | React.ReactElement; |
86 | | - disabled?:boolean; |
87 | | - unselectable?:boolean; |
88 | | - titleClass?:string; |
89 | | - infoClass?:string; |
90 | | - style?:React.CSSProperties; |
91 | | - titleStyle?:React.CSSProperties; |
92 | | - infoStyle?:React.CSSProperties; |
93 | | -``` |
| 10 | +yarn add `@code4bones/react-cascade-forms` |
94 | 11 |
|
95 | | -`TreeMenuActions` ( use `ref` ) |
96 | | -``` |
97 | | - enable:(id:string,disable?:boolean) => void; |
98 | | - getItem:(id:string) => TreeMenuItem | null; |
99 | | - collapse:(id:string,collapsed?:boolean) => void; |
100 | | - select:(id:string) => void; |
101 | | - invalidate:() => void; |
102 | | - rebuild:(items:TreeMenuItem[]) => void; |
103 | | -``` |
104 | 12 |
|
105 | 13 | ### Sample |
106 | 14 |
|
|
0 commit comments