@hi-ui/dropdown 4.0.0-alpha.1

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,43 @@
1
+ import React from 'react';
2
+ import { TriggerActionEnum } from './types';
3
+ import { PopperPortalProps } from '@hi-ui/popper';
4
+ export declare const useDropdown: (props: UseDropdownProps) => {
5
+ width: number | undefined;
6
+ rootProps: {};
7
+ disabled: boolean;
8
+ menuVisible: boolean;
9
+ menuVisibleAction: {
10
+ set: (stateOrFunction: React.SetStateAction<boolean>, ...args: any[]) => void;
11
+ on: () => void;
12
+ off: () => void;
13
+ not: () => void;
14
+ };
15
+ triggerElementRef: React.RefObject<HTMLElement>;
16
+ triggerMethods: TriggerActionEnum[];
17
+ getTriggerProps: () => any;
18
+ getMenuProps: (props?: any, ref?: any) => any;
19
+ };
20
+ export interface UseDropdownProps {
21
+ /**
22
+ * 下拉菜单触发方式
23
+ */
24
+ trigger?: TriggerActionEnum | TriggerActionEnum[];
25
+ /**
26
+ * 是否禁用下拉菜单
27
+ */
28
+ disabled?: boolean;
29
+ /**
30
+ * 菜单项宽度
31
+ */
32
+ width?: number;
33
+ /**
34
+ * 祖先吸附节点
35
+ * @private
36
+ */
37
+ parents?: any[];
38
+ /**
39
+ * 自定义控制 下拉 popper 行为
40
+ */
41
+ popper?: Omit<PopperPortalProps, 'visible' | 'attachEl'>;
42
+ }
43
+ export declare type UseDropdownReturn = ReturnType<typeof useDropdown>;
@@ -0,0 +1,8 @@
1
+ import { TriggerActionEnum } from '../types';
2
+ /**
3
+ * 抹平 trigger 结构为数组
4
+ *
5
+ * @param trigger
6
+ * @returns
7
+ */
8
+ export declare const normalizeTrigger: (trigger: TriggerActionEnum | TriggerActionEnum[]) => TriggerActionEnum[];
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@hi-ui/dropdown",
3
+ "version": "4.0.0-alpha.1",
4
+ "description": "A sub-package for @hi-ui/hiui.",
5
+ "keywords": [],
6
+ "author": "HIUI <mi-hiui@xiaomi.com>",
7
+ "homepage": "https://github.com/XiaoMi/hiui/tree/master/packages/ui/dropdown#readme",
8
+ "license": "MIT",
9
+ "directories": {
10
+ "lib": "lib",
11
+ "test": "__tests__"
12
+ },
13
+ "files": [
14
+ "lib"
15
+ ],
16
+ "main": "lib/cjs/index.js",
17
+ "module": "lib/esm/index.js",
18
+ "types": "lib/types/index.d.ts",
19
+ "typings": "lib/types/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "require": "./lib/cjs/index.js",
23
+ "default": "./lib/esm/index.js"
24
+ }
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/XiaoMi/hiui.git"
32
+ },
33
+ "scripts": {
34
+ "test": "jest",
35
+ "clean": "rimraf lib",
36
+ "prebuild": "yarn clean",
37
+ "build:esm": "hi-build ./src/index.ts --format esm -d ./lib/esm",
38
+ "build:cjs": "hi-build ./src/index.ts --format cjs -d ./lib/cjs",
39
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib/types",
40
+ "build": "concurrently yarn:build:*"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/XiaoMi/hiui/issues"
44
+ },
45
+ "dependencies": {
46
+ "@hi-ui/button": "^4.0.0-alpha.15",
47
+ "@hi-ui/classname": "^4.0.0-alpha.3",
48
+ "@hi-ui/core": "^4.0.0-alpha.12",
49
+ "@hi-ui/core-css": "^4.0.0-alpha.10",
50
+ "@hi-ui/env": "^4.0.0-alpha.5",
51
+ "@hi-ui/icons": "^4.0.0-alpha.18",
52
+ "@hi-ui/popper": "^4.0.0-alpha.15",
53
+ "@hi-ui/react-utils": "^4.0.0-alpha.6",
54
+ "@hi-ui/type-assertion": "^4.0.0-alpha.13",
55
+ "@hi-ui/use-latest": "^4.0.0-alpha.4",
56
+ "@hi-ui/use-timeout": "^4.0.0-alpha.3",
57
+ "@hi-ui/use-toggle": "^4.0.0-alpha.10",
58
+ "@hi-ui/use-unmount-effect": "^4.0.0-alpha.5"
59
+ },
60
+ "peerDependencies": {
61
+ "react": "^17.0.1",
62
+ "react-dom": "^17.0.1"
63
+ },
64
+ "devDependencies": {
65
+ "@hi-ui/hi-build": "^4.0.0-alpha.4",
66
+ "react": "^17.0.1",
67
+ "react-dom": "^17.0.1"
68
+ },
69
+ "gitHead": "4fe4855aa7b3180a4e30ffa0972ac39a04947b4b"
70
+ }