From 68b6085dd77ddbe2b9a5d5812e03b8a60565df0c Mon Sep 17 00:00:00 2001 From: helsonxiao Date: Fri, 29 Oct 2021 12:11:46 +0800 Subject: [PATCH] feat: pure react usage --- dumi/docs/demos/lite-version.md | 6 + example/craco.config.js | 9 + example/package.json | 25 +- example/src/App.tsx | 4 + example/src/demos/antd-form.tsx | 22 +- example/src/demos/basic-usage.tsx | 2 +- example/src/demos/lite-version.tsx | 31 ++ example/tsconfig.json | 4 +- example/yarn.lock | 284 +++++++++++++++++- package.json | 14 +- src/area-select.lite.tsx | 48 +++ src/{area-select.antd.tsx => area-select.tsx} | 19 +- src/index.ts | 8 + src/index.tsx | 6 - src/lite.ts | 8 + src/{styles.less => phone-input.less} | 7 +- src/phone-input.lite.tsx | 58 ++++ src/phone-input.tsx | 63 ++++ src/{phone-input.antd.tsx => shared.tsx} | 93 ++---- src/typings.ts | 5 + yarn.lock | 22 ++ 21 files changed, 615 insertions(+), 123 deletions(-) create mode 100644 dumi/docs/demos/lite-version.md create mode 100644 example/craco.config.js create mode 100644 example/src/demos/lite-version.tsx create mode 100644 src/area-select.lite.tsx rename src/{area-select.antd.tsx => area-select.tsx} (68%) create mode 100644 src/index.ts delete mode 100644 src/index.tsx create mode 100644 src/lite.ts rename src/{styles.less => phone-input.less} (56%) create mode 100644 src/phone-input.lite.tsx create mode 100644 src/phone-input.tsx rename src/{phone-input.antd.tsx => shared.tsx} (53%) create mode 100644 src/typings.ts diff --git a/dumi/docs/demos/lite-version.md b/dumi/docs/demos/lite-version.md new file mode 100644 index 0000000..df109bd --- /dev/null +++ b/dumi/docs/demos/lite-version.md @@ -0,0 +1,6 @@ +--- +title: Lite Version(without antd) +order: 6 +--- + + diff --git a/example/craco.config.js b/example/craco.config.js new file mode 100644 index 0000000..9a94ce8 --- /dev/null +++ b/example/craco.config.js @@ -0,0 +1,9 @@ +const CracoLessPlugin = require('craco-less'); + +module.exports = { + plugins: [ + { + plugin: CracoLessPlugin, + }, + ], +}; diff --git a/example/package.json b/example/package.json index 5f3c0ad..284bdd3 100644 --- a/example/package.json +++ b/example/package.json @@ -4,12 +4,20 @@ "version": "0.0.0", "private": true, "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" + "start": "craco start", + "build": "craco build", + "test": "craco test" }, "dependencies": { + "antd-country-phone-input": "link:..", + "flagpack": "^1.0.5", + "rc-select": "^12.1.13", + "react": "link:../node_modules/react", + "react-dom": "link:../node_modules/react-dom", + "world_countries_lists": "^2.1.0" + }, + "devDependencies": { + "@craco/craco": "^6.4.0", "@testing-library/jest-dom": "link:../node_modules/@testing-library/jest-dom", "@testing-library/react": "link:../node_modules/@testing-library/react", "@testing-library/user-event": "link:../node_modules/@testing-library/user-event", @@ -17,15 +25,10 @@ "@types/node": "link:../node_modules/@types/node", "@types/react": "link:../node_modules/@types/react", "@types/react-dom": "link:../node_modules/@types/react-dom", - "antd-country-phone-input": "link:..", - "flagpack": "^1.0.5", - "react": "link:../node_modules/react", - "react-dom": "link:../node_modules/react-dom", + "craco-less": "^1.20.0", "react-scripts": "~4.0.1", - "typescript": "link:../node_modules/typescript", - "world_countries_lists": "^2.1.0" + "typescript": "link:../node_modules/typescript" }, - "devDependencies": {}, "browserslist": { "production": [ ">0.2%", diff --git a/example/src/App.tsx b/example/src/App.tsx index 58d075c..0eef161 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,6 +1,7 @@ import { Card } from 'antd'; import BasicUsage from './demos/basic-usage'; +import LiteVersion from './demos/lite-version'; import InlineStyle from './demos/inline-style'; import CustomArea from './demos/custom-area'; import CustomFlag from './demos/custom-flag'; @@ -26,6 +27,9 @@ const App = () => { + + + ); }; diff --git a/example/src/demos/antd-form.tsx b/example/src/demos/antd-form.tsx index eb1e0f1..97fab25 100644 --- a/example/src/demos/antd-form.tsx +++ b/example/src/demos/antd-form.tsx @@ -15,24 +15,20 @@ const App = () => { return ( -
+ - + }} + > - - + + - +