diff --git a/.dumirc.ts b/.dumirc.ts index bd809418..efcef9c5 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -19,5 +19,5 @@ export default defineConfig({ min-height: 300px; } `, - ] + ], }); diff --git a/.fatherrc.js b/.fatherrc.js index 4ddbafd1..96268ae1 100644 --- a/.fatherrc.js +++ b/.fatherrc.js @@ -2,4 +2,4 @@ import { defineConfig } from 'father'; export default defineConfig({ plugins: ['@rc-component/father-plugin'], -}); \ No newline at end of file +}); diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 23a5fb82..dcc76231 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,30 +1,30 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: np - versions: - - 7.2.0 - - 7.3.0 - - 7.4.0 - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: typescript - versions: - - 4.1.3 - - 4.1.4 - - 4.1.5 + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + time: '21:00' + open-pull-requests-limit: 10 + ignore: + - dependency-name: np + versions: + - 7.2.0 + - 7.3.0 + - 7.4.0 + - dependency-name: '@types/react-dom' + versions: + - 17.0.0 + - 17.0.1 + - 17.0.2 + - dependency-name: '@types/react' + versions: + - 17.0.0 + - 17.0.1 + - 17.0.2 + - 17.0.3 + - dependency-name: typescript + versions: + - 4.1.3 + - 4.1.4 + - 4.1.5 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 67f7884a..d7208a4a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,12 +1,12 @@ -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ "master" ] + branches: ['master'] pull_request: - branches: [ "master" ] + branches: ['master'] schedule: - - cron: "40 12 * * 0" + - cron: '40 12 * * 0' jobs: analyze: @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ javascript ] + language: [javascript] steps: - name: Checkout @@ -38,4 +38,4 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 with: - category: "/language:${{ matrix.language }}" + category: '/language:${{ matrix.language }}' diff --git a/HISTORY.md b/HISTORY.md index 7ee63c89..c159b6b6 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,6 @@ # History ----- + +--- ## 4.1.0 / 2020-05-08 diff --git a/README.md b/README.md index e479e565..9e191b3a 100644 --- a/README.md +++ b/README.md @@ -39,25 +39,26 @@ import React from 'react'; import ReactDOM from 'react-dom'; import Trigger from '@rc-component/trigger'; -ReactDOM.render(( +ReactDOM.render( popup} popupAlign={{ points: ['tl', 'bl'], - offset: [0, 3] + offset: [0, 3], }} > - hover - -), container); + hover + , + container, +); ``` ## Compatibility | [IE / Edge](http://godban.github.io/browsers-support-badges/)
IE / Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | [Electron](http://godban.github.io/browsers-support-badges/)
Electron | -| --- | --- | --- | --- | --- | -| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions | ## Example @@ -243,7 +244,6 @@ npm start - ## Test Case ``` diff --git a/assets/index/Mask.less b/assets/index/Mask.less index 81692e64..a7b40bf5 100644 --- a/assets/index/Mask.less +++ b/assets/index/Mask.less @@ -22,7 +22,8 @@ animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); } - &-fade-enter,&-fade-appear { + &-fade-enter, + &-fade-appear { opacity: 0; .fade-effect(); animation-play-state: paused; @@ -33,7 +34,8 @@ animation-play-state: paused; } - &-fade-enter&-fade-enter-active,&-fade-appear&-fade-appear-active { + &-fade-enter&-fade-enter-active, + &-fade-appear&-fade-appear-active { animation-name: rcTriggerMaskFadeIn; animation-play-state: running; } diff --git a/docs/demos/body-overflow.md b/docs/demos/body-overflow.md index 6f6f9c48..b8fe6faf 100644 --- a/docs/demos/body-overflow.md +++ b/docs/demos/body-overflow.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/case.md b/docs/demos/case.md index 053a1bcf..7a7c3cfe 100644 --- a/docs/demos/case.md +++ b/docs/demos/case.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/click-nested.md b/docs/demos/click-nested.md index c67236dd..d1fa6ccf 100644 --- a/docs/demos/click-nested.md +++ b/docs/demos/click-nested.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/clip.md b/docs/demos/clip.md index e2798ee3..017d539f 100644 --- a/docs/demos/clip.md +++ b/docs/demos/clip.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/container.md b/docs/demos/container.md index a4860cbc..d607f169 100644 --- a/docs/demos/container.md +++ b/docs/demos/container.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/inside.md b/docs/demos/inside.md index a9853c32..6a1ccb04 100644 --- a/docs/demos/inside.md +++ b/docs/demos/inside.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/large-popup.md b/docs/demos/large-popup.md index 048c77a7..24cf8b10 100644 --- a/docs/demos/large-popup.md +++ b/docs/demos/large-popup.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/nested.md b/docs/demos/nested.md index 5daf43b0..bfd0c6ba 100644 --- a/docs/demos/nested.md +++ b/docs/demos/nested.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/point.md b/docs/demos/point.md index 073a89bc..1d31f1c1 100644 --- a/docs/demos/point.md +++ b/docs/demos/point.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/shadow.md b/docs/demos/shadow.md index 379812b7..029c60c2 100644 --- a/docs/demos/shadow.md +++ b/docs/demos/shadow.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/simple.md b/docs/demos/simple.md index dbb7c35a..6ac4ca8d 100644 --- a/docs/demos/simple.md +++ b/docs/demos/simple.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/demos/visible-fallback.md b/docs/demos/visible-fallback.md index cb5a8f24..71d0d910 100644 --- a/docs/demos/visible-fallback.md +++ b/docs/demos/visible-fallback.md @@ -5,4 +5,4 @@ nav: path: /demo --- - \ No newline at end of file + diff --git a/docs/examples/case.tsx b/docs/examples/case.tsx index 695f0db2..74e8740d 100644 --- a/docs/examples/case.tsx +++ b/docs/examples/case.tsx @@ -115,8 +115,10 @@ const Demo = () => { click, contextMenu, }; - - const actionsKeys = Object.keys(actions).filter((action) => actions[action]) as ActionType[]; + + const actionsKeys = Object.keys(actions).filter( + (action) => actions[action], + ) as ActionType[]; return ( diff --git a/docs/examples/nested.tsx b/docs/examples/nested.tsx index 259ea0a3..12dffe09 100644 --- a/docs/examples/nested.tsx +++ b/docs/examples/nested.tsx @@ -67,9 +67,7 @@ const Test = () => { getPopupContainer={() => containerRef.current} popup={
I am inner Trigger Popup
} > - - clickToShowInnerTrigger - + clickToShowInnerTrigger ); @@ -94,9 +92,7 @@ const Test = () => { builtinPlacements={builtinPlacements} popup={
i am a hover popup
} > - - trigger - + trigger @@ -108,9 +104,7 @@ const Test = () => { builtinPlacements={builtinPlacements} popup={innerTrigger} > - - trigger - + trigger diff --git a/docs/examples/point.less b/docs/examples/point.less index 4adc3418..3ea05e58 100644 --- a/docs/examples/point.less +++ b/docs/examples/point.less @@ -1,3 +1,3 @@ .point-popup { pointer-events: none; -} \ No newline at end of file +} diff --git a/docs/examples/point.tsx b/docs/examples/point.tsx index c2b48b8f..1e1e16ef 100644 --- a/docs/examples/point.tsx +++ b/docs/examples/point.tsx @@ -12,7 +12,9 @@ const builtinPlacements = { }; const innerTrigger = ( -
This is popup
+
+ This is popup +
); class Test extends React.Component { @@ -45,7 +47,11 @@ class Test extends React.Component { {action === 'hover' && ( )}
diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx index 59a2641e..aa4c7033 100644 --- a/docs/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -200,7 +200,7 @@ class Test extends React.Component { return null; } - const actions = Object.keys(state.trigger) as ActionType[] + const actions = Object.keys(state.trigger) as ActionType[]; return (
diff --git a/docs/index.md b/docs/index.md index 2782d1cf..6e9e0db6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,4 +4,4 @@ hero: description: React Trigger Component --- - \ No newline at end of file + diff --git a/now.json b/now.json index 76d28fa1..716cff0a 100644 --- a/now.json +++ b/now.json @@ -8,4 +8,4 @@ "config": { "distDir": ".doc" } } ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index b58ec3d9..55c24e14 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "prepublishOnly": "npm run compile && np --yolo --no-publish", "lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js", "test": "rc-test", + "prettier": "prettier --write .", "coverage": "rc-test --coverage", "now-build": "npm run build" }, @@ -55,6 +56,7 @@ "father": "^4.0.0", "less": "^4.2.0", "np": "^10.0.5", + "prettier": "^3.3.3", "rc-test": "^7.0.13", "react": "^18.0.0", "react-dom": "^18.0.0", diff --git a/src/hooks/useAlign.ts b/src/hooks/useAlign.ts index 6eacbf2f..8af82525 100644 --- a/src/hooks/useAlign.ts +++ b/src/hooks/useAlign.ts @@ -213,7 +213,7 @@ export default function useAlign( } else { const rect = target.getBoundingClientRect(); rect.x = rect.x ?? rect.left; - rect.y = rect.y ?? rect.top + rect.y = rect.y ?? rect.top; targetRect = { x: rect.x, y: rect.y, diff --git a/tests/flip.test.tsx b/tests/flip.test.tsx index 17fb0dd4..853ec980 100644 --- a/tests/flip.test.tsx +++ b/tests/flip.test.tsx @@ -353,7 +353,7 @@ describe('Trigger.Align', () => { top: 100, width: 300, height: 300, - } as any); + }) as any; const visibleArea = getVisibleArea(initArea, [affectEle]); expect(visibleArea).toEqual({ diff --git a/tests/rect.test.tsx b/tests/rect.test.tsx index 8f708bfe..596689f0 100644 --- a/tests/rect.test.tsx +++ b/tests/rect.test.tsx @@ -74,5 +74,4 @@ describe('Trigger.Rect', () => { bottom: `100px`, }); }); - }); diff --git a/tests/util.tsx b/tests/util.tsx index c06684f4..c706654d 100644 --- a/tests/util.tsx +++ b/tests/util.tsx @@ -1,4 +1,4 @@ -import { act } from "@testing-library/react"; +import { act } from '@testing-library/react'; const autoAdjustOverflow = { adjustX: 1, @@ -94,7 +94,6 @@ export function getMouseEvent(type: string, values = {}): FakeMouseEvent { return new FakeMouseEvent(type, values); } - export async function awaitFakeTimer() { for (let i = 0; i < 10; i += 1) { await act(async () => {