@hi-ui/menu 4.3.2 → 5.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { HiBaseHTMLProps } from '@hi-ui/core';
3
+ import { MenuDataItem } from './types';
4
+ export declare const MenuSearch: React.ForwardRefExoticComponent<MenuSearchProps & React.RefAttributes<HTMLDivElement | null>>;
5
+ export interface MenuSearchHelper {
6
+ show: () => void;
7
+ hide: () => void;
8
+ focus: () => void;
9
+ }
10
+ export interface MenuSearchProps extends HiBaseHTMLProps<'div'> {
11
+ innerRef?: React.RefObject<MenuSearchHelper>;
12
+ clearText?: React.ReactNode;
13
+ placeholder?: string;
14
+ notFoundContent?: React.ReactNode;
15
+ width?: React.CSSProperties['width'];
16
+ visible?: boolean;
17
+ data?: MenuDataItem[];
18
+ defaultValue?: string;
19
+ value?: string;
20
+ onChange?: (value: string) => void;
21
+ onSearch?: (value: string) => void;
22
+ onSelect?: (id: React.ReactText, item: MenuDataItem) => void;
23
+ onClear?: () => void;
24
+ onClose?: () => void;
25
+ onEsc?: () => void;
26
+ }
27
+ export declare const MenuSearchInput: React.ForwardRefExoticComponent<{
28
+ prefixCls: string;
29
+ placeholder?: string | undefined;
30
+ inputRef?: React.Dispatch<React.SetStateAction<HTMLInputElement | null>> | undefined;
31
+ width?: React.CSSProperties['width'];
32
+ value?: string | undefined;
33
+ onChange?: ((value: string) => void) | undefined;
34
+ onClear?: (() => void) | undefined;
35
+ onClose?: (() => void) | undefined;
36
+ onKeyDown?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
37
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import { HiBaseHTMLProps } from '@hi-ui/core';
3
+ import { MenuDataItem } from './types';
4
+ /**
5
+ * 侧边菜单组件
6
+ */
7
+ export declare const SideMenu: React.ForwardRefExoticComponent<SideMenuProps & React.RefAttributes<HTMLDivElement | null>>;
8
+ export interface SideMenuProps extends Omit<HiBaseHTMLProps<'div'>, 'onClick' | 'onMouseEnter' | 'onMouseLeave'> {
9
+ /**
10
+ * 侧边菜单宽度
11
+ */
12
+ width?: number;
13
+ /**
14
+ * 是否为迷你模式
15
+ */
16
+ mini?: boolean;
17
+ /**
18
+ * 默认激活的菜单项
19
+ */
20
+ defaultActiveId?: React.ReactText | null;
21
+ /**
22
+ * 激活的菜单项
23
+ */
24
+ activeId?: React.ReactText | null;
25
+ /**
26
+ * 选中的菜单项
27
+ */
28
+ selectedId?: React.ReactText | null;
29
+ /**
30
+ * 侧边菜单数据
31
+ */
32
+ data: MenuDataItem[];
33
+ /**
34
+ * 子菜单容器引用
35
+ */
36
+ childrenContainerRef?: React.RefObject<HTMLDivElement>;
37
+ /**
38
+ * 点击侧边菜单项
39
+ */
40
+ onClick?: (event: React.MouseEvent<HTMLDivElement>, id: React.ReactText, item: MenuDataItem) => void;
41
+ /**
42
+ * 鼠标移入侧边菜单项
43
+ */
44
+ onMouseEnter?: (event: React.MouseEvent<HTMLDivElement>, id: React.ReactText, item: MenuDataItem) => void;
45
+ /**
46
+ * 鼠标移出侧边菜单项
47
+ */
48
+ onMouseLeave?: (event: React.MouseEvent<HTMLDivElement>, id: React.ReactText, item: MenuDataItem) => void;
49
+ }
50
+ export declare const useSideMenuCascade: ({ data, selectId, activeId, }: {
51
+ data: MenuDataItem[];
52
+ selectId: React.ReactText;
53
+ activeId: React.ReactText;
54
+ }) => {
55
+ submenuData: MenuDataItem[];
56
+ selectParentId: string | number;
57
+ activeParentId: string | number;
58
+ };
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { MenuDataItem } from './types';
3
3
  declare const MenuContext: React.Context<{
4
- placement?: "vertical" | "horizontal" | undefined;
4
+ placement?: "horizontal" | "vertical" | undefined;
5
5
  expandedType?: "collapse" | "pop" | undefined;
6
6
  showAllSubMenus?: boolean | undefined;
7
7
  mini?: boolean | undefined;
8
+ showTitleOnMini?: boolean | undefined;
8
9
  expandedIds?: React.ReactText[] | undefined;
9
10
  activeId?: React.ReactText | undefined;
10
11
  activeParents?: React.ReactText[] | undefined;
@@ -2,5 +2,8 @@ import './styles/index.scss';
2
2
  export * from './Menu';
3
3
  export { Menu as default } from './Menu';
4
4
  export * from './Sidebar';
5
+ export * from './MenuSearch';
6
+ export * from './GroupMenu';
7
+ export * from './SideMenu';
5
8
  export { filterTreeData, getParentId, getAncestorIds } from './util';
6
9
  export * from './types';
@@ -6,3 +6,19 @@ export declare const getAncestorIds: (id: string | number, data: Record<string,
6
6
  export declare const getIdsWithChildren: (treeData: MenuDataItem[]) => React.ReactText[];
7
7
  export declare const filterTreeData: (treeData: MenuDataItem[], searchKey: string, activeId: string | number) => MenuDataItem[];
8
8
  export declare const transformTreeData: (data: MenuDataItem[], fieldNames?: HiBaseFieldNames | undefined) => MenuDataItem[];
9
+ /**
10
+ * 根据关键字匹配菜单数据的算法
11
+ * @param data 菜单数据数组
12
+ * @param keyword 搜索关键字
13
+ * @returns 匹配结果数组
14
+ */
15
+ export declare function searchMenuByKeyword(data: MenuDataItem[], keyword: string): MenuDataItem[];
16
+ export interface MenuSearchResult {
17
+ node: MenuDataItem;
18
+ path: MenuDataItem[];
19
+ level: number;
20
+ }
21
+ /**
22
+ * 增强版搜索函数,返回包含路径信息的结果
23
+ */
24
+ export declare function searchMenuWithPath(data: MenuDataItem[], keyword: string): MenuSearchResult[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/menu",
3
- "version": "4.3.2",
3
+ "version": "5.0.0-alpha.0",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -19,6 +19,7 @@
19
19
  "typings": "lib/types/index.d.ts",
20
20
  "exports": {
21
21
  ".": {
22
+ "types": "./lib/types/index.d.ts",
22
23
  "require": "./lib/cjs/index.js",
23
24
  "default": "./lib/esm/index.js"
24
25
  }
@@ -43,31 +44,38 @@
43
44
  "url": "https://github.com/XiaoMi/hiui/issues"
44
45
  },
45
46
  "dependencies": {
46
- "@hi-ui/array-utils": "^4.0.5",
47
- "@hi-ui/classname": "^4.0.5",
48
- "@hi-ui/env": "^4.0.5",
49
- "@hi-ui/icons": "^4.0.19",
50
- "@hi-ui/popper": "^4.1.5",
51
- "@hi-ui/scrollbar": "^4.1.1",
52
- "@hi-ui/times": "^4.0.4",
53
- "@hi-ui/tooltip": "^4.0.11",
54
- "@hi-ui/tree-utils": "^4.1.5",
55
- "@hi-ui/type-assertion": "^4.0.4",
56
- "@hi-ui/use-id": "^4.0.4",
57
- "@hi-ui/use-merge-refs": "^4.0.4",
58
- "@hi-ui/use-resize-observer": "^4.0.4",
59
- "@hi-ui/use-toggle": "^4.0.4",
60
- "@hi-ui/use-uncontrolled-state": "^4.0.4",
47
+ "@hi-ui/array-utils": "^5.0.0-alpha.0",
48
+ "@hi-ui/classname": "^5.0.0-alpha.0",
49
+ "@hi-ui/ellipsis-tooltip": "^5.0.0-alpha.0",
50
+ "@hi-ui/env": "^5.0.0-alpha.0",
51
+ "@hi-ui/highlighter": "^5.0.0-alpha.0",
52
+ "@hi-ui/icon-button": "^5.0.0-alpha.0",
53
+ "@hi-ui/icons": "^5.0.0-alpha.0",
54
+ "@hi-ui/input": "^5.0.0-alpha.0",
55
+ "@hi-ui/picker": "^5.0.0-alpha.0",
56
+ "@hi-ui/popper": "^5.0.0-alpha.0",
57
+ "@hi-ui/scrollbar": "^5.0.0-alpha.0",
58
+ "@hi-ui/times": "^5.0.0-alpha.0",
59
+ "@hi-ui/tooltip": "^5.0.0-alpha.0",
60
+ "@hi-ui/tree-utils": "^5.0.0-alpha.0",
61
+ "@hi-ui/type-assertion": "^5.0.0-alpha.0",
62
+ "@hi-ui/use-id": "^5.0.0-alpha.0",
63
+ "@hi-ui/use-latest": "^5.0.0-alpha.0",
64
+ "@hi-ui/use-merge-refs": "^5.0.0-alpha.0",
65
+ "@hi-ui/use-outside-click": "^5.0.0-alpha.0",
66
+ "@hi-ui/use-resize-observer": "^5.0.0-alpha.0",
67
+ "@hi-ui/use-toggle": "^5.0.0-alpha.0",
68
+ "@hi-ui/use-uncontrolled-state": "^5.0.0-alpha.0",
61
69
  "react-transition-group": "^4.4.2"
62
70
  },
63
71
  "peerDependencies": {
64
- "@hi-ui/core": ">=4.0.8",
72
+ "@hi-ui/core": ">=5.0.0-alpha.0",
65
73
  "react": ">=16.8.6",
66
74
  "react-dom": ">=16.8.6"
67
75
  },
68
76
  "devDependencies": {
69
- "@hi-ui/core": "^4.0.8",
70
- "@hi-ui/core-css": "^4.1.5",
77
+ "@hi-ui/core": "^5.0.0-alpha.0",
78
+ "@hi-ui/core-css": "^5.0.0-alpha.0",
71
79
  "react": "^17.0.1",
72
80
  "react-dom": "^17.0.1"
73
81
  }