diff --git a/.editorconfig b/.editorconfig index 604c94ef..7e3649ac 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,16 @@ -# top-most EditorConfig file +# http://editorconfig.org root = true -# Unix-style newlines with a newline ending every file -[*.{js,css}] -end_of_line = lf -insert_final_newline = true +[*] indent_style = space indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore index d7e68431..a599dfd5 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,9 @@ coverage yarn.lock .storybook .doc + +# umi +.umi +.umi-production +.umi-test +.env.local diff --git a/.umirc.ts b/.umirc.ts new file mode 100644 index 00000000..62f42288 --- /dev/null +++ b/.umirc.ts @@ -0,0 +1,17 @@ +// more config: https://d.umijs.org/config +import { defineConfig } from 'dumi'; + +export default defineConfig({ + title: 'rc-dialog', + favicon: + 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + logo: + 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + outputPath: '.doc', + exportStatic: {}, + styles: [ + `a img + svg { + display: none; + }` + ] +}); diff --git a/README.md b/README.md deleted file mode 100644 index 3fb3b760..00000000 --- a/README.md +++ /dev/null @@ -1,117 +0,0 @@ -# rc-dialog ---- - -react dialog component - -[![NPM version][npm-image]][npm-url] -[![build status][github-actions-image]][github-actions-url] -[![Test coverage][coveralls-image]][coveralls-url] -[![Dependencies][david-image]][david-url] -[![DevDependencies][david-dev-image]][david-dev-url] -[![npm download][download-image]][download-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] - -[npm-image]: http://img.shields.io/npm/v/rc-dialog.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-dialog -[github-actions-image]: https://github.com/react-component/dialog/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/dialog/actions -[circleci-image]: https://img.shields.io/circleci/react-component/dialog/master?style=flat-square -[circleci-url]: https://circleci.com/gh/react-component/dialog -[coveralls-image]: https://img.shields.io/coveralls/react-component/dialog.svg?style=flat-square -[coveralls-url]: https://coveralls.io/r/react-component/dialog?branch=master -[david-url]: https://david-dm.org/react-component/dialog -[david-image]: https://david-dm.org/react-component/dialog/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/dialog?type=dev -[david-dev-image]: https://david-dm.org/react-component/dialog/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/rc-dialog.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-dialog -[bundlephobia-url]: https://bundlephobia.com/result?p=rc-dialog -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-dialog - -## Screenshot - - - -## Install - -[![rc-dialog](https://nodei.co/npm/rc-dialog.png)](https://npmjs.org/package/rc-dialog) - -## Usage - -```js -var Dialog = require('rc-dialog'); - -ReactDOM.render( - -

first dialog

-
-), document.getElementById('t1')); - -// use dialog -``` - -## API - -### rc-dialog - -| Name | Type | Default | Description | Version | -| ---------------------- | ------------------------------ | --------- | ------------------------------------------------------------------------------- | ------- | -| prefixCls | String | rc-dialog | The dialog dom node's prefixCls | | -| className | String | | additional className for dialog | | -| style | Object | {} | Root style for dialog element.Such as width, height | | -| zIndex | Number | | | | -| bodyStyle | Object | {} | body style for dialog body element.Such as height | | -| maskStyle | Object | {} | style for mask element | | -| visible | Boolean | false | current dialog's visible status | | -| animation | String | | part of dialog animation css class name | | -| maskAnimation | String | | part of dialog's mask animation css class name | | -| transitionName | String | | dialog animation css class name | | -| maskTransitionName | String | | mask animation css class name | | -| title | String\|React.Element | | Title of the dialog | | -| footer | React.Element | | footer of the dialog | | -| closable | Boolean | true | whether show close button | | -| mask | Boolean | true | whether show mask | | -| maskClosable | Boolean | true | whether click mask to close | | -| keyboard | Boolean | true | whether support press esc to close | | -| mousePosition | {x:number,y:number} | | set pageX and pageY of current mouse(it will cause transform origin to be set). | | -| onClose | function() | | called when click close button or mask | | -| afterClose | function() | | called when close animation end | | -| getContainer | function(): HTMLElement | | to determine where Dialog will be mounted | | -| destroyOnClose | Boolean | false | to unmount child compenents on onClose | | -| closeIcon | ReactNode | | specific the close icon. | | -| forceRender | Boolean | false | Create dialog dom node before dialog first show | | -| focusTriggerAfterClose | Boolean | true | focus trigger element when dialog closed | | -| modalRender | (node: ReactNode) => ReactNode | | Custom modal content render | 8.3.0 | - -## Development - -``` -npm install -npm start -``` - -## Example - -http://localhost:8007/examples/ - -online example: http://react-component.github.io/dialog/ - -## Test Case - -``` -npm test -npm run chrome-test -``` - -## Coverage - -``` -npm run coverage -``` - -open coverage/ dir - - -## License - -rc-dialog is released under the MIT license. diff --git a/README.md b/README.md new file mode 120000 index 00000000..e8923303 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +docs/index.md \ No newline at end of file diff --git a/HISTORY.md b/docs/changelog.md similarity index 79% rename from HISTORY.md rename to docs/changelog.md index 355b1d35..e155ef3e 100644 --- a/HISTORY.md +++ b/docs/changelog.md @@ -1,5 +1,37 @@ -# History ----- +# Changelog + +## 8.4.4 + +`2020-12-03` + +- fix: dialog dont close when mouseDown in content and mouseUp in wrapper. [#210](https://github.com/react-component/dialog/pull/210) + +- chore: Should not re-render when dialog is invisible. [#212](https://github.com/react-component/dialog/pull/212) + + +## 8.4.3 + +`2020-10-21` + +- chore: support react 17. [#207](https://github.com/react-component/dialog/pull/207) + +## 8.4.2 + +`2020-10-14` + +- fix: Dialog should not auto destroy. [#206](https://github.com/react-component/dialog/pull/206) + +## 8.4.1 + +`2020-10-11` + +- fix: Portal event bubble. [#204](https://github.com/react-component/dialog/pull/204) + +## 8.4.0 + +`2020-09-29` + +- refactor: Use `rc-motion`. [#203](https://github.com/react-component/dialog/pull/203) ## 8.3.4 (8.2.2, 8.1.2) / 2020-09-04 - fix: prevent scroll behavior when focus trigger. [ant-design/ant-design#26582](https://github.com/ant-design/ant-design/issues/26582) diff --git a/docs/demo/ant-design.md b/docs/demo/ant-design.md new file mode 100644 index 00000000..a8441c94 --- /dev/null +++ b/docs/demo/ant-design.md @@ -0,0 +1,3 @@ +## ant-design + + diff --git a/docs/demo/bootstrap.md b/docs/demo/bootstrap.md new file mode 100644 index 00000000..10c34535 --- /dev/null +++ b/docs/demo/bootstrap.md @@ -0,0 +1,3 @@ +## bootstrap + + diff --git a/docs/demo/draggable.md b/docs/demo/draggable.md new file mode 100644 index 00000000..eced05ac --- /dev/null +++ b/docs/demo/draggable.md @@ -0,0 +1,3 @@ +## draggable + + diff --git a/docs/demo/multiple-Portal.md b/docs/demo/multiple-Portal.md new file mode 100644 index 00000000..d2e30ecb --- /dev/null +++ b/docs/demo/multiple-Portal.md @@ -0,0 +1,3 @@ +## multiple-Portal + + diff --git a/examples/ant-design.tsx b/docs/examples/ant-design.tsx similarity index 98% rename from examples/ant-design.tsx rename to docs/examples/ant-design.tsx index b4679296..5b68ee15 100644 --- a/examples/ant-design.tsx +++ b/docs/examples/ant-design.tsx @@ -1,9 +1,9 @@ /* eslint no-console:0 */ -import '../assets/index.less'; import * as React from 'react'; import Select from 'rc-select'; import 'rc-select/assets/index.less'; -import Dialog from '../src/DialogWrap'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; const clearPath = 'M793 242H366v-74c0-6.7-7.7-10.4-12.9' + diff --git a/examples/bootstrap.tsx b/docs/examples/bootstrap.tsx similarity index 98% rename from examples/bootstrap.tsx rename to docs/examples/bootstrap.tsx index 1420329b..2b696ac1 100644 --- a/examples/bootstrap.tsx +++ b/docs/examples/bootstrap.tsx @@ -1,7 +1,7 @@ import 'bootstrap/dist/css/bootstrap.css'; -import '../assets/bootstrap.less'; import * as React from 'react'; -import Dialog from '../src/DialogWrap'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; // Check for memo update should work const InnerRender = () => { diff --git a/examples/draggable.tsx b/docs/examples/draggable.tsx similarity index 95% rename from examples/draggable.tsx rename to docs/examples/draggable.tsx index 92cbc10c..789d5666 100644 --- a/examples/draggable.tsx +++ b/docs/examples/draggable.tsx @@ -1,8 +1,8 @@ import 'bootstrap/dist/css/bootstrap.css'; -import '../assets/bootstrap.less'; import * as React from 'react'; import Draggable from 'react-draggable'; -import Dialog from '../src/DialogWrap'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; const MyControl = () => { const [visible, setVisible] = React.useState(false); diff --git a/examples/multiple-Portal.tsx b/docs/examples/multiple-Portal.tsx similarity index 94% rename from examples/multiple-Portal.tsx rename to docs/examples/multiple-Portal.tsx index 81350206..b7d6c120 100644 --- a/examples/multiple-Portal.tsx +++ b/docs/examples/multiple-Portal.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import Drawer from 'rc-drawer'; -import Dialog from '../src/DialogWrap'; import 'rc-drawer/assets/index.css'; -import '../assets/index.less'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; const { useState } = React; diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..c7177b54 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,113 @@ +# rc-dialog +--- + +react dialog component + +[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] + +[npm-image]: http://img.shields.io/npm/v/rc-dialog.svg?style=flat-square +[npm-url]: http://npmjs.org/package/rc-dialog +[github-actions-image]: https://github.com/react-component/dialog/workflows/CI/badge.svg +[github-actions-url]: https://github.com/react-component/dialog/actions +[circleci-image]: https://img.shields.io/circleci/react-component/dialog/master?style=flat-square +[circleci-url]: https://circleci.com/gh/react-component/dialog +[coveralls-image]: https://img.shields.io/coveralls/react-component/dialog.svg?style=flat-square +[coveralls-url]: https://coveralls.io/r/react-component/dialog?branch=master +[david-url]: https://david-dm.org/react-component/dialog +[david-image]: https://david-dm.org/react-component/dialog/status.svg?style=flat-square +[david-dev-url]: https://david-dm.org/react-component/dialog?type=dev +[david-dev-image]: https://david-dm.org/react-component/dialog/dev-status.svg?style=flat-square +[download-image]: https://img.shields.io/npm/dm/rc-dialog.svg?style=flat-square +[download-url]: https://npmjs.org/package/rc-dialog +[bundlephobia-url]: https://bundlephobia.com/result?p=rc-dialog +[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-dialog + +## Screenshot + + + +## Example + +http://localhost:8007/examples/ + +online example: http://react-component.github.io/dialog/ + +## Install + +[![rc-dialog](https://nodei.co/npm/rc-dialog.png)](https://npmjs.org/package/rc-dialog) + +## Usage + +```js +var Dialog = require('rc-dialog'); + +ReactDOM.render( + +

first dialog

+
+), document.getElementById('t1')); + +// use dialog +``` + +## API + +### rc-dialog + +| Name | Type | Default | Description | Version | +| ---------------------- | ------------------------------ | --------- | ------------------------------------------------------------------------------- | ------- | +| prefixCls | String | rc-dialog | The dialog dom node's prefixCls | | +| className | String | | additional className for dialog | | +| style | Object | {} | Root style for dialog element.Such as width, height | | +| zIndex | Number | | | | +| bodyStyle | Object | {} | body style for dialog body element.Such as height | | +| maskStyle | Object | {} | style for mask element | | +| visible | Boolean | false | current dialog's visible status | | +| animation | String | | part of dialog animation css class name | | +| maskAnimation | String | | part of dialog's mask animation css class name | | +| transitionName | String | | dialog animation css class name | | +| maskTransitionName | String | | mask animation css class name | | +| title | String\|React.Element | | Title of the dialog | | +| footer | React.Element | | footer of the dialog | | +| closable | Boolean | true | whether show close button | | +| mask | Boolean | true | whether show mask | | +| maskClosable | Boolean | true | whether click mask to close | | +| keyboard | Boolean | true | whether support press esc to close | | +| mousePosition | {x:number,y:number} | | set pageX and pageY of current mouse(it will cause transform origin to be set). | | +| onClose | function() | | called when click close button or mask | | +| afterClose | function() | | called when close animation end | | +| getContainer | function(): HTMLElement | | to determine where Dialog will be mounted | | +| destroyOnClose | Boolean | false | to unmount child compenents on onClose | | +| closeIcon | ReactNode | | specific the close icon. | | +| forceRender | Boolean | false | Create dialog dom node before dialog first show | | +| focusTriggerAfterClose | Boolean | true | focus trigger element when dialog closed | | +| modalRender | (node: ReactNode) => ReactNode | | Custom modal content render | 8.3.0 | + +## Development + +``` +npm install +npm start +``` + + + +## Test Case + +``` +npm test +npm run chrome-test +``` + +## Coverage + +``` +npm run coverage +``` + +open coverage/ dir + + +## License + +rc-dialog is released under the MIT license. diff --git a/now.json b/now.json index 1d18e2a0..6eaa4d61 100644 --- a/now.json +++ b/now.json @@ -7,5 +7,8 @@ "use": "@now/static-build", "config": { "distDir": ".doc" } } + ], + "routes": [ + { "src": "/(.*)", "dest": "/dist/$1" } ] } diff --git a/package.json b/package.json index 8cdb85e6..c45928d6 100644 --- a/package.json +++ b/package.json @@ -28,15 +28,19 @@ "main": "./lib/index", "module": "./es/index", "scripts": { - "start": "cross-env NODE_ENV=development father doc dev --storybook", + "start": "dumi dev", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d .doc", "build": "father doc build --storybook", "compile": "father build && lessc assets/index.less assets/index.css && lessc assets/bootstrap.less assets/bootstrap.css", - "gh-pages": "npm run build && father doc deploy", + "deploy": "npm run docs:build && npm run docs:deploy", "prepublishOnly": "npm run compile && np --yolo --no-publish", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", + "lint:tsc": "tsc -p tsconfig.json --noEmit", "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", "test": "father test", - "coverage": "father test --coverage" + "coverage": "father test --coverage", + "now-build": "npm run docs:build" }, "peerDependencies": { "react": ">=16.9.0", @@ -57,6 +61,7 @@ "bluebird": "~3.7.2", "bootstrap": "^4.3.1", "cross-env": "^7.0.0", + "dumi": "^1.0.37", "enzyme": "^3.1.1", "enzyme-adapter-react-16": "^1.0.1", "enzyme-to-json": "^3.1.2", @@ -64,6 +69,9 @@ "eslint-config-airbnb": "^18.2.0", "eslint-plugin-react": "^7.20.6", "father": "^2.29.6", + "father-build": "^1.18.6", + "gh-pages": "^3.1.0", + "glob": "^7.1.6", "jquery": "^3.3.1", "less": "^3.12.2", "np": "^6.4.0", diff --git a/script/update-content.js b/script/update-content.js new file mode 100644 index 00000000..c898f9e3 --- /dev/null +++ b/script/update-content.js @@ -0,0 +1,29 @@ +/* + 用于 dumi 改造使用, + 可用于将 examples 的文件批量修改为 demo 引入形式, + 其他项目根据具体情况使用。 +*/ + +const fs = require('fs'); +const glob = require('glob'); + +const paths = glob.sync('./docs/examples/*.tsx'); + +paths.forEach(path => { + const name = path.split('/').pop().split('.')[0]; + fs.writeFile( + `./docs/demo/${name}.md`, + `## ${name} + + +`, + 'utf8', + function(error) { + if(error){ + console.log(error); + return false; + } + console.log(`${name} 更新成功~`); + } + ) +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..f6d96058 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "esnext", + "moduleResolution": "node", + "baseUrl": "./", + "jsx": "preserve", + "declaration": true, + "skipLibCheck": true, + "esModuleInterop": true, + "paths": { + "@/*": ["src/*"], + "@@/*": ["src/.umi/*"], + "rc-dialog": ["src/index.ts"] + } + } +} diff --git a/typings.d.ts b/typings.d.ts new file mode 100644 index 00000000..71e0e9f4 --- /dev/null +++ b/typings.d.ts @@ -0,0 +1,2 @@ +declare module '*.css'; +declare module '*.less';