Skip to content

Commit a5e8915

Browse files
committed
chore: tmp of it
1 parent ffa313a commit a5e8915

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

docs/examples/multiple-Portal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const Demo: React.FC = () => {
2424
onClose={onToggleDialog}
2525
forceRender
2626
title="basic modal"
27+
mask={false}
2728
>
2829
<p>
2930
<button type="button" onClick={onToggleDrawer}>
@@ -46,7 +47,7 @@ const Demo: React.FC = () => {
4647
open dialog
4748
</button>
4849
{dialog}
49-
{drawer}
50+
{/* {drawer} */}
5051
</div>
5152
);
5253
};

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"lint:tsc": "tsc -p tsconfig.json --noEmit",
3838
"now-build": "npm run docs:build",
3939
"prepare": "husky install",
40-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
40+
"prepublishOnly": "npm run compile && rc-np",
4141
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
4242
"start": "dumi dev",
4343
"test": "rc-test"
@@ -49,14 +49,14 @@
4949
]
5050
},
5151
"dependencies": {
52-
"@babel/runtime": "^7.10.1",
5352
"@rc-component/portal": "^1.0.0-8",
5453
"@rc-component/util": "^1.0.1",
5554
"classnames": "^2.2.6",
56-
"rc-motion": "^2.3.0"
55+
"@rc-component/motion": "^1.1.0"
5756
},
5857
"devDependencies": {
59-
"@rc-component/father-plugin": "^2.0.1",
58+
"@rc-component/father-plugin": "^2.0.2",
59+
"@rc-component/np": "^1.0.3",
6060
"@testing-library/jest-dom": "^6.1.6",
6161
"@testing-library/react": "^13.0.0",
6262
"@types/jest": "^29.4.0",
@@ -77,7 +77,6 @@
7777
"husky": "^8.0.3",
7878
"less": "^4.1.3",
7979
"lint-staged": "^15.2.0",
80-
"np": "^10.0.5",
8180
"prettier": "^3.2.1",
8281
"rc-drawer": "^7.0.0",
8382
"rc-select": "^14.11.0",

src/Dialog/Content/index.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as React from 'react';
22
import { useRef } from 'react';
33
import classNames from 'classnames';
4-
import CSSMotion from 'rc-motion';
4+
import CSSMotion from '@rc-component/motion';
55
import { offset } from '../../util';
66
import type { PanelProps, ContentRef } from './Panel';
77
import Panel from './Panel';
88

9+
console.log(CSSMotion);
10+
911
export type ContentProps = {
1012
motionName: string;
1113
ariaId: string;
@@ -27,7 +29,10 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
2729
mousePosition,
2830
} = props;
2931

30-
const dialogRef = useRef<HTMLDivElement>();
32+
const dialogRef = useRef<{
33+
nativeElement: HTMLDivElement;
34+
inMotion: () => boolean;
35+
}>();
3136

3237
// ============================= Style ==============================
3338
const [transformOrigin, setTransformOrigin] = React.useState<string>();
@@ -38,7 +43,8 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
3843
}
3944

4045
function onPrepare() {
41-
const elementOffset = offset(dialogRef.current);
46+
console.log('onPrepare', dialogRef.current);
47+
const elementOffset = offset(dialogRef.current?.nativeElement);
4248

4349
setTransformOrigin(
4450
mousePosition && (mousePosition.x || mousePosition.y)
@@ -47,6 +53,12 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
4753
);
4854
}
4955

56+
const bbb = React.useCallback((aaa) => {
57+
console.log('???', aaa);
58+
dialogRef.current = aaa;
59+
}, []);
60+
console.log('render....');
61+
5062
// ============================= Render =============================
5163
return (
5264
<CSSMotion
@@ -57,7 +69,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
5769
forceRender={forceRender}
5870
motionName={motionName}
5971
removeOnLeave={destroyOnClose}
60-
ref={dialogRef}
72+
ref={bbb}
6173
>
6274
{({ className: motionClassName, style: motionStyle }, motionRef) => (
6375
<Panel

src/Dialog/Mask.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
3-
import CSSMotion from 'rc-motion';
3+
import CSSMotion from '@rc-component/motion';
44

55
export type MaskProps = {
66
prefixCls: string;

tests/index.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-disable react/no-render-return-value, max-classes-per-file, func-names, no-console */
22
import { fireEvent, render, act } from '@testing-library/react';
3-
import { Provider } from 'rc-motion';
3+
import { Provider } from '@rc-component/motion';
44
import KeyCode from '@rc-component/util/lib/KeyCode';
55
import React, { cloneElement, useEffect } from 'react';
66
import type { DialogProps } from '../src';
77
import Dialog from '../src';
88

9-
jest.mock('rc-motion', () => {
9+
jest.mock('@rc-component/motion', () => {
1010
const OriReact = jest.requireActual('react');
11-
const origin = jest.requireActual('rc-motion');
11+
const origin = jest.requireActual('@rc-component/motion');
1212
const OriCSSMotion = origin.default;
1313

1414
const ProxyCSSMotion = OriReact.forwardRef((props: any, ref: any) => {

tests/ref.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react/no-render-return-value, max-classes-per-file, func-names, no-console */
22
import { render } from '@testing-library/react';
3-
import { Provider } from 'rc-motion';
3+
import { Provider } from '@rc-component/motion';
44
import React from 'react';
55
import Dialog from '../src';
66

0 commit comments

Comments
 (0)