|
1 | 1 | /* eslint-disable no-mixed-spaces-and-tabs */ |
2 | | -import React, { useCallback, useEffect, useMemo, useState,createContext, useRef, useImperativeHandle } from "react"; |
| 2 | +import React, { useEffect, useMemo, useState, useImperativeHandle } from "react"; |
3 | 3 | import clsx from "clsx"; |
| 4 | +import { TreeMenuItem,TreeMenuProps,ItemProps,ItemRenderProps,TreeMenuItemType } from "./TreeMenu.types"; |
4 | 5 | import "./TreeMenu.less"; |
5 | | -// import { Icon } from "@blueprintjs/core"; |
6 | | - |
7 | | -type ItemProps = { |
8 | | - level?:number; |
9 | | - title:string; |
10 | | - info?:string; |
11 | | - route?:string; |
12 | | - titleClass?:string; |
13 | | - infoClass?:string; |
14 | | - style?:React.CSSProperties; |
15 | | - infoStyle?:React.CSSProperties; |
16 | | - classes?:Set<string>; |
17 | | - disabled?:boolean; |
18 | | - id:string; |
19 | | - collapsed?:boolean; |
20 | | - unselectable?:boolean; |
21 | | - hasChilds?:boolean; |
22 | | - icon?:React.ReactElement; |
23 | | - onClick?:(item:ItemProps) => void; |
24 | | -} |
25 | | - |
26 | | -type MenuItem = Omit<ItemProps,"level" | "classes" | "hasChilds" | "onClick">; |
27 | | - |
28 | | -export type TreeMenuItem = { |
29 | | - childs?:TreeMenuItem[]; |
30 | | -} & MenuItem; |
31 | | - |
32 | | -type TreeMenuItemType = { |
33 | | - parent?:TreeMenuItemType; |
34 | | - childs?:TreeMenuItemType[]; |
35 | | -} & ItemProps; |
36 | | - |
37 | | -type RenderType = (id:string) => React.ReactElement | undefined | null; |
38 | | - |
39 | | -type TreeMenuProps = { |
40 | | - items:TreeMenuItem[]; |
41 | | - initialCollapsed?:boolean; |
42 | | - initialSelected?:string; |
43 | | - renderBadge?:RenderType; |
44 | | - renderGroupIcon?:RenderType | React.ReactElement | null; |
45 | | - onClick?:(id:string) => void; |
46 | | - onToggle?:(id?:string,collapsed?:boolean) => void; |
47 | | - // renderItem?:(item:TreeMenuItem) => React.ReactElement; |
48 | | -} |
49 | | - |
50 | | -type ItemRenderProps = { |
51 | | - renderBadge?:TreeMenuProps["renderBadge"]; |
52 | | - renderGroup?:TreeMenuProps["renderGroupIcon"]; |
53 | | -} & ItemProps; |
54 | 6 |
|
| 7 | +export { TreeMenuItem }; |
55 | 8 |
|
56 | 9 | const Item : React.FC<ItemRenderProps> = (props) => { |
57 | 10 | const { |
|
0 commit comments