Skip to content

Commit f6935db

Browse files
shaodahongzombieJ
authored andcommitted
refactor: upgrade rc-trigger (#18)
* refactor: upgrade rc-trigger * fix lint fail * upgrade rc-menu and define KeywordTriggerProps children type * fix textarea example transitionName fail * update package.json * v1.0.0-alpha.0
1 parent c5cca9c commit f6935db

File tree

7 files changed

+67
-21
lines changed

7 files changed

+67
-21
lines changed

examples/textarea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default () => (
2222
</Mentions>
2323

2424
<div style={{ paddingTop: 200 }}>
25-
<Mentions placeholder="placement: top" placement="top" transitionName="motion">
25+
<Mentions placeholder="placement: top" placement="top" transitionName="motion-zoom">
2626
<Option value="light">Light</Option>
2727
<Option value="bamboo">Bamboo</Option>
2828
<Option value="cat">Cat</Option>

examples/textarea.less

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
11
.motion {
2-
transform: scale(.3);
2+
3+
.effect() {
4+
animation-duration: 0.3s;
5+
animation-fill-mode: both;
6+
}
7+
8+
&-zoom-enter,&-zoom-appear {
9+
opacity: 0;
10+
.effect();
11+
animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
12+
animation-play-state: paused;
13+
}
14+
15+
&-zoom-leave {
16+
.effect();
17+
animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05);
18+
animation-play-state: paused;
19+
}
20+
21+
&-zoom-enter&-zoom-enter-active, &-zoom-appear&-zoom-appear-active {
22+
animation-name: rcTriggerZoomIn;
23+
animation-play-state: running;
24+
}
25+
26+
&-zoom-leave&-zoom-leave-active {
27+
animation-name: rcTriggerZoomOut;
28+
animation-play-state: running;
29+
}
30+
31+
@keyframes rcTriggerZoomIn {
32+
0% {
33+
opacity: 0;
34+
transform-origin: 50% 50%;
35+
transform: scale(0, 0);
36+
}
37+
100% {
38+
opacity: 1;
39+
transform-origin: 50% 50%;
40+
transform: scale(1, 1);
41+
}
42+
}
43+
@keyframes rcTriggerZoomOut {
44+
0% {
45+
opacity: 1;
46+
transform-origin: 50% 50%;
47+
transform: scale(1, 1);
48+
}
49+
100% {
50+
opacity: 0;
51+
transform-origin: 50% 50%;
52+
transform: scale(0, 0);
53+
}
54+
}
355
}

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-mentions",
3-
"version": "0.4.1",
3+
"version": "1.0.0-alpha.0",
44
"description": "React Mentions",
55
"keywords": [
66
"react",
@@ -29,7 +29,7 @@
2929
"start": "father doc dev --storybook",
3030
"build": "father doc build --storybook",
3131
"compile": "father build",
32-
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
32+
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish --any-branch",
3333
"lint": "eslint src/ --ext .tsx,.ts",
3434
"test": "father test",
3535
"now-build": "npm run build"
@@ -55,9 +55,8 @@
5555
"dependencies": {
5656
"@ant-design/create-react-context": "^0.2.4",
5757
"classnames": "^2.2.6",
58-
"rc-menu": "^7.4.22",
59-
"rc-trigger": "^2.6.2",
60-
"rc-util": "^4.6.0",
61-
"react-lifecycles-compat": "^3.0.4"
58+
"rc-menu": "^8.0.0-alpha.2",
59+
"rc-trigger": "^4.0.0-alpha.4",
60+
"rc-util": "^4.6.0"
6261
}
6362
}

src/DropdownMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DropdownMenu extends React.Component<DropdownMenuProps, {}> {
2828
<Menu
2929
prefixCls={`${prefixCls}-menu`}
3030
activeKey={activeOption.value}
31-
onSelect={({ key }: { key: string }) => {
31+
onSelect={({ key }) => {
3232
const option = options.find(({ value }) => value === key);
3333
selectOption(option);
3434
}}

src/KeywordTrigger.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface KeywordTriggerProps {
3131
placement?: Placement;
3232
visible?: boolean;
3333
transitionName?: string;
34+
children?: React.ReactElement;
3435
getPopupContainer?: () => HTMLElement;
3536
}
3637

src/Mentions.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import classNames from 'classnames';
22
import toArray from 'rc-util/lib/Children/toArray';
33
import KeyCode from 'rc-util/lib/KeyCode';
44
import * as React from 'react';
5-
import { polyfill } from 'react-lifecycles-compat';
65
import KeywordTrigger from './KeywordTrigger';
76
import { MentionsContextProvider } from './MentionsContext';
87
import Option, { OptionProps } from './Option';
@@ -57,6 +56,12 @@ interface MentionsState {
5756
class Mentions extends React.Component<MentionsProps, MentionsState> {
5857
public static Option = Option;
5958

59+
public textarea?: HTMLTextAreaElement;
60+
61+
public measure?: HTMLDivElement;
62+
63+
public focusId: number | undefined = undefined;
64+
6065
public static defaultProps = {
6166
prefixCls: 'rc-mentions',
6267
prefix: '@',
@@ -77,12 +82,6 @@ class Mentions extends React.Component<MentionsProps, MentionsState> {
7782
return newState;
7883
}
7984

80-
public textarea?: HTMLTextAreaElement;
81-
82-
public measure?: HTMLDivElement;
83-
84-
public focusId: number | undefined = undefined;
85-
8685
constructor(props: MentionsProps) {
8786
super(props);
8887
this.state = {
@@ -399,6 +398,4 @@ class Mentions extends React.Component<MentionsProps, MentionsState> {
399398
}
400399
}
401400

402-
polyfill(Mentions);
403-
404401
export default Mentions;

typings/index.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
declare module 'react-lifecycles-compat';
2-
declare module 'rc-trigger';
31
declare module 'rc-util/*';
4-
declare module 'rc-menu';

0 commit comments

Comments
 (0)