Skip to content

Commit 7cdd0a9

Browse files
committed
2.0.0
1 parent 304919d commit 7cdd0a9

25 files changed

+348
-36102
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 react-widget
3+
Copyright (c) 2018-2020 nobo react-widget-trigger
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,162 @@
11
# trigger
2-
trigger
2+
3+
Trigger触发组件
4+
5+
## 安装
6+
7+
`npm install --save react-widget-trigger`
8+
9+
10+
## 使用
11+
12+
[![Edit react-wiget-trigger](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-wiget-trigger-llvwn?fontsize=14&hidenavigation=1&theme=dark)
13+
14+
15+
### Interfaces
16+
17+
```ts
18+
import React from "react";
19+
import Popup, { PopupProps } from "react-widget-popup";
20+
import { PositionOptions } from "jq-position";
21+
import { Placements } from "./getPlacement";
22+
declare type ActionType = "click" | "contextMenu" | "focus" | "hover" | "mouseDown";
23+
declare type ShowActionType = "click" | "contextMenu" | "focus" | "mouseEnter" | "mouseDown";
24+
declare type HideActionType = "click" | "mouseLeave" | "blur" | "resize" | "scroll" | "mouseDown";
25+
declare type Delay = {
26+
show?: number;
27+
hide?: number;
28+
};
29+
export declare const version = "%VERSION%";
30+
export interface TriggerProps {
31+
/** 样式前缀 */
32+
prefixCls?: string;
33+
/** 弹出框显示位置 */
34+
placement?: Placements;
35+
/** 弹出框位置偏移量 */
36+
offset?: [number, number] | number;
37+
/** 触发事件 */
38+
action?: ActionType | ActionType[] | null;
39+
/** 显示触发事件,同action合并 */
40+
showAction?: ShowActionType | ShowActionType[] | null;
41+
/** 隐藏触发事件,同action合并 */
42+
hideAction?: HideActionType | HideActionType[] | null;
43+
/** 显示/隐藏延迟时间 */
44+
delay?: number | Delay;
45+
/** 触发后弹出显示内容 */
46+
popup?: React.ReactNode | ((trigger: Trigger) => React.ReactNode);
47+
/** 弹出框CSS样式 */
48+
popupClassName?: string;
49+
/** 弹出框遮罩层CSS样式 */
50+
popupMaskClassName?: string;
51+
/** 弹出框根节点元素CSS样式 */
52+
popupRootClassName?: string;
53+
/** 弹出框CSSTransition参数,参考:react-transition-group */
54+
popupTransition?: PopupProps["transition"];
55+
/** 弹出框遮罩层CSSTransition参数,参考:react-transition-group */
56+
popupMaskTransition?: PopupProps["maskTransition"];
57+
/** 初始时弹出框是否可见 */
58+
defaultPopupVisible?: boolean;
59+
/** 控制弹出框是否可见(受控) */
60+
popupVisible?: boolean;
61+
/** 弹出框组件(Popup)属性,参考:react-widget-popup */
62+
popupProps?: Omit<PopupProps, "className" | "maskClassName" | "rootClassName" | "prefixCls" | "transition" | "maskTransition" | "maskProps" | "style" | "mask" | "disableMask" | "destroyOnClose" | "maskStyle" | "rootStyle" | "zIndex">;
63+
/** 弹出框样式 */
64+
popupStyle?: React.CSSProperties;
65+
/** 弹出框遮罩层样式 */
66+
popupMaskStyle?: React.CSSProperties;
67+
popupRootStyle?: React.CSSProperties;
68+
/** 弹出框的遮罩层元素的属性,参考:PopupProps["maskProps"] */
69+
popupMaskProps?: PopupProps["maskProps"];
70+
/** 是否显示遮罩层 */
71+
mask?: boolean;
72+
/** 是否禁用遮罩层 */
73+
disableMask?: boolean;
74+
/** 点击遮罩层隐藏弹出框 */
75+
maskClosable?: boolean;
76+
/** 隐藏销毁弹出框 */
77+
destroyPopupOnHide?: boolean;
78+
/** 设置弹出框的zIndex */
79+
zIndex?: number;
80+
/** 是否使用Portal进行渲染弹出框 */
81+
usePortal?: boolean;
82+
/** 当destroyPopupOnHide=false时,组件刷新时强制更新弹出框组件 */
83+
forceRender?: boolean;
84+
/** jquery-ui/position.js 的配置参数 */
85+
position?: PositionOptions;
86+
/** 内部使用 */
87+
getDocument?: () => Document | Element;
88+
/** 内部使用 */
89+
checkDefaultPrevented?: boolean;
90+
onPopupVisibleChange?: (visible: boolean) => void;
91+
onBeforeShow?: (popupNode: HTMLElement) => void;
92+
onAfterShow?: (popupNode: HTMLElement) => void;
93+
onBeforeHide?: (popupNode: HTMLElement) => void;
94+
onAfterHide?: (popupNode: HTMLElement) => void;
95+
}
96+
export interface TriggerState {
97+
popupVisible: boolean;
98+
}
99+
export declare class Trigger extends React.Component<TriggerProps, TriggerState> {
100+
popupInstance: Popup;
101+
triggerInstance: React.ReactInstance;
102+
componentDidMount(): void;
103+
componentDidUpdate(): void;
104+
componentWillUnmount(): void;
105+
show(): void;
106+
hide(): void;
107+
}
108+
export default Trigger;
109+
```
110+
111+
### defaultProps
112+
```js
113+
{
114+
prefixCls: "rw-trigger",
115+
placement: "bottomLeft",
116+
offset: 0,
117+
defaultPopupVisible: false,
118+
action: ["click"],
119+
showAction: [],
120+
hideAction: [],
121+
delay: 0,
122+
getDocument: () => window.document,
123+
container: document.body,
124+
mask: false,
125+
maskClosable: true,
126+
destroyPopupOnHide: true,
127+
popupProps: {},
128+
popupStyle: {},
129+
popupMaskStyle: {},
130+
checkDefaultPrevented: false,
131+
usePortal: true,
132+
}
133+
```
134+
135+
### 基础样式
136+
137+
```css
138+
.rw-trigger-root {
139+
position: absolute;
140+
left: 0;
141+
top: 0;
142+
}
143+
144+
.rw-trigger {
145+
position: absolute;
146+
left: 0;
147+
top: 0;
148+
z-index: 2000;
149+
}
150+
151+
.rw-trigger-mask {
152+
position: fixed;
153+
left: 0;
154+
top: 0;
155+
right: 0;
156+
bottom: 0;
157+
background: #000;
158+
opacity: 0.1;
159+
z-index: 2000;
160+
}
161+
162+
```

docs/asset-manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"index.css": "static/css/index.a9115b2c.chunk.css",
3+
"index.js": "static/js/index.a9115b2c.chunk.js",
4+
"runtime-index.js": "static/js/runtime-index.7c9988e7.js",
5+
"static/js/2.74857955.chunk.js": "static/js/2.74857955.chunk.js",
6+
"index.html": "index.html"
7+
}

docs/index.html

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
1-
<!DOCTYPE html>
2-
<html style="width:100%; height:100%; overflow:hidden;">
3-
4-
<head>
5-
<meta charset="utf-8">
6-
<title>popup</title>
7-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1">
8-
<style type="text/css">
9-
.demo {
10-
width: 800px;
11-
height: 450px;
12-
margin: 100px auto;
13-
background: #FFF;
14-
font-size: 12px;
15-
overflow: auto;
16-
}
17-
</style>
18-
<link href="static\css\vendors.e646e3e1.css" rel="stylesheet"><link href="static\css\index.f9427e34.css" rel="stylesheet"></head>
19-
20-
<body style="background:#F5F5F5">
21-
<div class="demo" id="demo">
22-
</div>
23-
<script src="static\js\vendors.aed3cfaf.chunk.js"></script><script src="static\js\index.e5562d28.js"></script></body>
24-
25-
</html>
1+
<!doctype html><html><head><meta charset="utf-8"/><title>trigger</title><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1"/><style>.demo{width:800px;height:450px;margin:100px auto;background:#fff;font-size:12px;overflow:auto}</style><link href="static/css/index.a9115b2c.chunk.css" rel="stylesheet"></head><body style="background:#f5f5f5"><div class="demo" id="demo"></div><script src="static/js/runtime-index.7c9988e7.js"></script><script src="static/js/2.74857955.chunk.js"></script><script src="static/js/index.a9115b2c.chunk.js"></script></body></html>

docs/static/css/index.a9115b2c.chunk.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)