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 3ef440c9..8c2d5a2a 100755 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,10 @@ es coverage yarn.lock package-lock.json -.doc/ \ No newline at end of file +.doc/ + +# umi +.umi +.umi-production +.umi-test +.env.local diff --git a/.umirc.ts b/.umirc.ts new file mode 100644 index 00000000..00290453 --- /dev/null +++ b/.umirc.ts @@ -0,0 +1,19 @@ +// more config: https://d.umijs.org/config +import { defineConfig } from 'dumi'; + +export default defineConfig({ + title: 'rc-input-number', + 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: [ + ` + .markdown table { + width: auto !important; + } + `, + ] +}); diff --git a/HISTORY.md b/CHANGELOG.md similarity index 93% rename from HISTORY.md rename to CHANGELOG.md index f4b005c6..e015dd5a 100644 --- a/HISTORY.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -# History ----- +# Changelog + +https://github.com/react-component/input-number/releases ## 5.0.0 diff --git a/README.md b/README.md index b4059754..231a1b61 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,8 @@ # rc-input-number ---- Input number control. -[![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 version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![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-input-number.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-input-number @@ -55,7 +48,7 @@ npm start http://127.0.0.1:8000/examples/ -online example: http://react-component.github.io/input-number/examples +online example: https://input-number.vercel.app/ ## API diff --git a/docs/demo/combination-key-format.md b/docs/demo/combination-key-format.md new file mode 100644 index 00000000..312cea5e --- /dev/null +++ b/docs/demo/combination-key-format.md @@ -0,0 +1,3 @@ +## combination-key-format + + diff --git a/docs/demo/custom.md b/docs/demo/custom.md new file mode 100644 index 00000000..0949653e --- /dev/null +++ b/docs/demo/custom.md @@ -0,0 +1,3 @@ +## custom + + diff --git a/docs/demo/decimal.md b/docs/demo/decimal.md new file mode 100644 index 00000000..4204dc6e --- /dev/null +++ b/docs/demo/decimal.md @@ -0,0 +1,3 @@ +## decimal + + diff --git a/docs/demo/formatter.md b/docs/demo/formatter.md new file mode 100644 index 00000000..e4a75fba --- /dev/null +++ b/docs/demo/formatter.md @@ -0,0 +1,3 @@ +## formatter + + diff --git a/docs/demo/precision.md b/docs/demo/precision.md new file mode 100644 index 00000000..bb7135df --- /dev/null +++ b/docs/demo/precision.md @@ -0,0 +1,3 @@ +## precision + + diff --git a/docs/demo/simple-use-touch.md b/docs/demo/simple-use-touch.md new file mode 100644 index 00000000..bef7f876 --- /dev/null +++ b/docs/demo/simple-use-touch.md @@ -0,0 +1,3 @@ +## simple-use-touch + + diff --git a/docs/demo/simple.md b/docs/demo/simple.md new file mode 100644 index 00000000..efaf04c4 --- /dev/null +++ b/docs/demo/simple.md @@ -0,0 +1,3 @@ +## simple + + diff --git a/docs/demo/small-step.md b/docs/demo/small-step.md new file mode 100644 index 00000000..a9269a6e --- /dev/null +++ b/docs/demo/small-step.md @@ -0,0 +1,3 @@ +## small-step + + diff --git a/examples/combination-key-format.tsx b/docs/examples/combination-key-format.tsx similarity index 95% rename from examples/combination-key-format.tsx rename to docs/examples/combination-key-format.tsx index e2aa812d..be79ea82 100644 --- a/examples/combination-key-format.tsx +++ b/docs/examples/combination-key-format.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; class Component extends React.Component { state = { diff --git a/examples/custom.tsx b/docs/examples/custom.tsx similarity index 93% rename from examples/custom.tsx rename to docs/examples/custom.tsx index 3ccc6f1a..b2bf7e19 100644 --- a/examples/custom.tsx +++ b/docs/examples/custom.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; class Component extends React.Component { state = { diff --git a/examples/decimal.tsx b/docs/examples/decimal.tsx similarity index 93% rename from examples/decimal.tsx rename to docs/examples/decimal.tsx index da29364c..3766bbf9 100644 --- a/examples/decimal.tsx +++ b/docs/examples/decimal.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; export default class Demo extends React.Component { state = { diff --git a/examples/formatter.tsx b/docs/examples/formatter.tsx similarity index 96% rename from examples/formatter.tsx rename to docs/examples/formatter.tsx index 27b14912..9be8b67b 100644 --- a/examples/formatter.tsx +++ b/docs/examples/formatter.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; function getSum(str) { let total = 0; diff --git a/examples/precision.tsx b/docs/examples/precision.tsx similarity index 91% rename from examples/precision.tsx rename to docs/examples/precision.tsx index 0ed73e66..c2c233d8 100644 --- a/examples/precision.tsx +++ b/docs/examples/precision.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; class Component extends React.Component { state = { diff --git a/examples/simple-use-touch.tsx b/docs/examples/simple-use-touch.tsx similarity index 93% rename from examples/simple-use-touch.tsx rename to docs/examples/simple-use-touch.tsx index 0c93dedd..9659520f 100644 --- a/examples/simple-use-touch.tsx +++ b/docs/examples/simple-use-touch.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; class Component extends React.Component { state = { diff --git a/examples/simple.tsx b/docs/examples/simple.tsx similarity index 93% rename from examples/simple.tsx rename to docs/examples/simple.tsx index 2d16660c..ac6cfa45 100644 --- a/examples/simple.tsx +++ b/docs/examples/simple.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNumber from '../src'; -import '../assets/index.less'; +import InputNumber from 'rc-input-number'; +import '../../assets/index.less'; class Component extends React.Component { state = { diff --git a/examples/small-step.tsx b/docs/examples/small-step.tsx similarity index 89% rename from examples/small-step.tsx rename to docs/examples/small-step.tsx index 2343fa33..482e3c42 100644 --- a/examples/small-step.tsx +++ b/docs/examples/small-step.tsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ import React from 'react'; -import InputNum from '../src'; -import '../assets/index.less'; +import InputNum from 'rc-input-number'; +import '../../assets/index.less'; class Component extends React.Component { state = { diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..bb209b4a --- /dev/null +++ b/docs/index.md @@ -0,0 +1,5 @@ +--- +title: rc-input-number +--- + + diff --git a/now.json b/now.json index 5abb02cf..b73988b5 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 60a56808..9e7682c1 100644 --- a/package.json +++ b/package.json @@ -26,16 +26,16 @@ }, "license": "MIT", "scripts": { - "start": "cross-env NODE_ENV=development father doc dev --storybook", - "build": "father doc build --storybook", + "start": "dumi dev", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d docs-dist", "compile": "father build && lessc assets/index.less assets/index.css", - "gh-pages": "npm run build && father doc deploy", "prepublishOnly": "npm run compile && np --yolo --no-publish", - "postpublish": "npm run gh-pages", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", "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" }, "dependencies": { "@babel/runtime": "^7.10.1", @@ -49,12 +49,14 @@ "@types/react-dom": "^16.9.0", "@umijs/fabric": "^2.0.0", "cross-env": "^7.0.0", + "dumi": "^1.1.0", "enzyme": "^3.1.1", "enzyme-adapter-react-16": "^1.0.1", "enzyme-to-json": "^3.1.2", "eslint": "^7.1.0", "expect.js": "~0.3.1", "father": "^2.22.0", + "glob": "^7.1.6", "less": "^3.12.2", "np": "^6.0.0", "rc-tooltip": "^4.0.3", diff --git a/tsconfig.json b/tsconfig.json index 445f6ce7..0314f9fe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,9 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"] + "@/*": ["src/*"], + "@@/*": ["src/.umi/*"], + "rc-input-number": ["src/index.ts"] } } } diff --git a/update-demo.js b/update-demo.js new file mode 100644 index 00000000..c898f9e3 --- /dev/null +++ b/update-demo.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} 更新成功~`); + } + ) +});