Skip to content

Commit

Permalink
upgrade father, fix eslint and prettier (#241)
Browse files Browse the repository at this point in the history
* upgrade father, fix eslint and prettier

* use father

* upgrade father
  • Loading branch information
afc163 authored Feb 23, 2021
1 parent 2060372 commit 8804de4
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 91 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const base = require('@umijs/fabric/dist/eslint');

module.exports = {
...base,
extends: [require.resolve('@umijs/fabric/dist/eslint')],
rules: {
...base.rules,
'default-case': 0,
'import/no-extraneous-dependencies': 0,
'react/no-find-dom-node': 0,
Expand Down
7 changes: 4 additions & 3 deletions examples/case.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint no-console:0 */

import React from 'react';
import { CSSMotionProps } from 'rc-motion';
import Trigger, { BuildInPlacements } from '../src';
import type { CSSMotionProps } from 'rc-motion';
import type { BuildInPlacements } from '../src';
import Trigger from '../src';
import './case.less';

const builtinPlacements: BuildInPlacements = {
Expand Down Expand Up @@ -202,7 +203,7 @@ const Demo = () => {
maskMotion={motion ? MaskMotion : null}
maskClosable={maskClosable}
stretch={stretch}
action={Object.keys(actions).filter(action => actions[action])}
action={Object.keys(actions).filter((action) => actions[action])}
builtinPlacements={builtinPlacements}
forceRender={forceRender}
popupStyle={{
Expand Down
12 changes: 1 addition & 11 deletions examples/click-nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@ const popupBorderStyle = {
background: 'rgba(255, 0, 0, 0.1)',
};

function saveRef(name, component) {
this[name] = component;
}

class Test extends React.Component {
constructor(props) {
super(props);

this.saveContainerRef = saveRef.bind(this, 'containerInstance');
}

render() {
return (
<div style={{ margin: 200 }}>
Expand All @@ -68,7 +58,7 @@ class Test extends React.Component {
i am a click popup{' '}
<button
type="button"
onMouseDown={e => {
onMouseDown={(e) => {
e.stopPropagation();
e.preventDefault();
}}
Expand Down
14 changes: 4 additions & 10 deletions examples/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@ const popupBorderStyle = {
padding: 10,
};

function saveRef(name, component) {
this[name] = component;
}

class Test extends React.Component {
constructor(props) {
super(props);

this.saveContainerRef = saveRef.bind(this, 'containerInstance');
}
saveContainerRef = (node) => {
this.containerInstanceNode = node;
};

render() {
const innerTrigger = (
Expand All @@ -55,7 +49,7 @@ class Test extends React.Component {
popupPlacement="bottom"
action={['click']}
builtinPlacements={builtinPlacements}
getPopupContainer={() => this.containerInstance}
getPopupContainer={() => this.containerInstanceNode}
popup={<div style={popupBorderStyle}>I am inner Trigger Popup</div>}
>
<span href="#" style={{ margin: 20 }}>
Expand Down
26 changes: 13 additions & 13 deletions examples/simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function getPopupContainer(trigger) {
return trigger.parentNode;
}

const InnerTarget = props => (
const InnerTarget = (props) => (
<div
style={{
margin: 20,
Expand Down Expand Up @@ -78,7 +78,7 @@ interface TestState {
mobile?: boolean;
}

class Test extends React.Component<{}, TestState> {
class Test extends React.Component<any, TestState> {
state: TestState = {
mask: true,
maskClosable: true,
Expand All @@ -92,19 +92,19 @@ class Test extends React.Component<{}, TestState> {
transitionName: 'rc-trigger-popup-zoom',
};

onPlacementChange = e => {
onPlacementChange = (e) => {
this.setState({
placement: e.target.value,
});
};

onStretch = e => {
onStretch = (e) => {
this.setState({
stretch: e.target.value,
});
};

onTransitionChange = e => {
onTransitionChange = (e) => {
this.setState({
transitionName: e.target.checked ? e.target.value : '',
});
Expand All @@ -126,31 +126,31 @@ class Test extends React.Component<{}, TestState> {
});
};

onOffsetXChange = e => {
onOffsetXChange = (e) => {
const targetValue = e.target.value;
this.setState({
offsetX: targetValue || undefined,
});
};

onOffsetYChange = e => {
onOffsetYChange = (e) => {
const targetValue = e.target.value;
this.setState({
offsetY: targetValue || undefined,
});
};

onVisibleChange = visible => {
onVisibleChange = (visible) => {
console.log('tooltip', visible);
};

onMask = e => {
onMask = (e) => {
this.setState({
mask: e.target.checked,
});
};

onMaskClosable = e => {
onMaskClosable = (e) => {
this.setState({
maskClosable: e.target.checked,
});
Expand All @@ -173,13 +173,13 @@ class Test extends React.Component<{}, TestState> {
});
};

destroyPopupOnHide = e => {
destroyPopupOnHide = (e) => {
this.setState({
destroyPopupOnHide: e.target.checked,
});
};

autoDestroy = e => {
autoDestroy = (e) => {
this.setState({
autoDestroy: e.target.checked,
});
Expand Down Expand Up @@ -374,7 +374,7 @@ class Test extends React.Component<{}, TestState> {
background: '#FFF',
textAlign: 'center',
},
popupRender: node => (
popupRender: (node) => (
<>
<div>
<input
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.4.0",
"eslint": "^7.0.0",
"father": "^2.13.2",
"father": "^2.30.2",
"np": "^6.2.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"regenerator-runtime": "^0.13.7",
"typescript": "^3.5.2"
"typescript": "^4.0.0"
},
"dependencies": {
"@babel/runtime": "^7.11.2",
Expand Down
5 changes: 3 additions & 2 deletions src/Popup/Mask.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import classNames from 'classnames';
import CSSMotion, { CSSMotionProps } from 'rc-motion';
import { TransitionNameType, AnimationType } from '../interface';
import type { CSSMotionProps } from 'rc-motion';
import CSSMotion from 'rc-motion';
import type { TransitionNameType, AnimationType } from '../interface';
import { getMotion } from '../utils/legacyUtil';

export interface MaskProps {
Expand Down
4 changes: 2 additions & 2 deletions src/Popup/MobilePopupInner.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import CSSMotion from 'rc-motion';
import classNames from 'classnames';
import { PopupInnerProps, PopupInnerRef } from './PopupInner';
import { MobileConfig } from '../interface';
import type { PopupInnerProps, PopupInnerRef } from './PopupInner';
import type { MobileConfig } from '../interface';

interface MobilePopupInnerProps extends PopupInnerProps {
mobile?: MobileConfig;
Expand Down
13 changes: 7 additions & 6 deletions src/Popup/PopupInner.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as React from 'react';
import { useRef, useState } from 'react';
import Align from 'rc-align';
import { RefAlign } from 'rc-align/lib/Align';
import CSSMotion, { CSSMotionProps, MotionEndEventHandler } from 'rc-motion';
import type { RefAlign } from 'rc-align/lib/Align';
import type { CSSMotionProps, MotionEndEventHandler } from 'rc-motion';
import CSSMotion from 'rc-motion';
import classNames from 'classnames';
import {
import type {
Point,
AlignType,
StretchType,
Expand Down Expand Up @@ -97,7 +98,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
const [status, goNextStatus] = useVisibleStatus(visible, doMeasure);

// ======================== Aligns ========================
const prepareResolveRef = useRef<Function>();
const prepareResolveRef = useRef<(value?: unknown) => void>();

// `target` on `rc-align` can accept as a function to get the bind element or a point.
// ref: https://www.npmjs.com/package/rc-align
Expand Down Expand Up @@ -134,7 +135,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(

// ======================== Motion ========================
const motion = { ...getMotion(props) };
['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach(eventName => {
['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach((eventName) => {
const originHandler: MotionEndEventHandler = motion[eventName];
motion[eventName] = (element, event) => {
goNextStatus();
Expand All @@ -143,7 +144,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
});

function onShowPrepare() {
return new Promise(resolve => {
return new Promise((resolve) => {
prepareResolveRef.current = resolve;
});
}
Expand Down
9 changes: 5 additions & 4 deletions src/Popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { useState, useEffect } from 'react';
import { CSSMotionProps } from 'rc-motion';
import type { CSSMotionProps } from 'rc-motion';
import isMobile from 'rc-util/lib/isMobile';
import {
import type {
StretchType,
AlignType,
TransitionNameType,
Expand All @@ -11,7 +11,8 @@ import {
MobileConfig,
} from '../interface';
import Mask from './Mask';
import PopupInner, { PopupInnerRef } from './PopupInner';
import type { PopupInnerRef } from './PopupInner';
import PopupInner from './PopupInner';
import MobilePopupInner from './MobilePopupInner';

export interface PopupProps {
Expand Down Expand Up @@ -61,7 +62,7 @@ const Popup = React.forwardRef<PopupInnerRef, PopupProps>(
if (visible && mobile) {
setInMobile(isMobile());
}
}, [visible, !!mobile]);
}, [visible, mobile]);

const popupNode: React.ReactNode = inMobile ? (
<MobilePopupInner {...cloneProps} mobile={mobile} ref={ref} />
Expand Down
2 changes: 1 addition & 1 deletion src/Popup/useStretchStyle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { StretchType } from '../interface';
import type { StretchType } from '../interface';

export default (
stretch?: StretchType,
Expand Down
5 changes: 3 additions & 2 deletions src/Popup/useVisibleStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export default (
cancelRaf();
rafRef.current = raf(() => {
// Only align should be manually trigger
setStatus(prev => {
setStatus((prev) => {
switch (status) {
case 'align':
return 'motion';

case 'motion':
return 'stable';
default:
}

return prev;
Expand All @@ -59,6 +59,7 @@ export default (
case 'measure':
doMeasure();
break;
default:
}

if (status) {
Expand Down
Loading

0 comments on commit 8804de4

Please sign in to comment.