提交 7b83bc27 编写于 作者: L lkjh3214

Merge branch 'upstream_main' into dev

<p align="center"> <p align="center">
<img alt="logo" src="https://img11.360buyimg.com/imagetools/jfs/t1/211965/25/7152/22022/61b16785E433119bb/aa41d7a9f7e823f3.png" width="150" style="margin-bottom: 10px;"> <img alt="logo" src="https://img11.360buyimg.com/imagetools/jfs/t1/211965/25/7152/22022/61b16785E433119bb/aa41d7a9f7e823f3.png" width="150" style="margin-bottom: 10px;">
</p> </p>
...@@ -6,61 +7,125 @@ ...@@ -6,61 +7,125 @@
<p align="center"> <p align="center">
<a href="http://makeapullrequest.com"> <a href="http://makeapullrequest.com">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome"> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome" />
</a> </a>
<a href="https://github.com/jdf2e/nutui-react">
<img src="https://coveralls.io/repos/github/jdf2e/nutui/badge.svg?branch=master" alt="Coverage Status" />
</a> <a href="https://github.com/jdf2e/nutui">
<a href="https://github.com/jdf2e/nutui-react"> <img src="https://img.shields.io/npm/l/@nutui/nutui-react.svg" alt="license"/>
<img src="https://img.shields.io/travis/jdf2e/nutui.svg?style=flat-square"> </a>
</a> <a href="https://www.npmjs.com/package/@nutui/nutui-react">
<a href="https://github.com/jdf2e/nutui-react"> <img src="https://img.shields.io/npm/v/@nutui/nutui-react.svg?style=flat-square">
<img src="https://img.shields.io/github/contributors/jdf2e/nutui-react" alt="GitHub contributors"> </a>
</a> <a href="https://www.npmjs.com/package/@nutui/nutui-react">
<a href="https://github.com/jdf2e/nutui-react"> <img src="https://img.shields.io/npm/dt/@nutui/nutui-react.svg?style=flat-square">
<img src="https://img.shields.io/github/commit-activity/w/jdf2e/nutui-react" alt="GitHub commit activity"> </a>
</a>
<a href="https://github.com/jdf2e/nutui-react"> <a href="https://github.com/jdf2e/nutui">
<img src="https://img.shields.io/github/issues-closed/jdf2e/nutui-react" alt="GitHub closed issues"> <img src="https://img.shields.io/github/contributors/jdf2e/nutui-react" alt="GitHub contributors">
</a> </a>
</p> </p>
## 背景
> Nut[nʌt],源自电影《冰河世纪》里松鼠 Scrat "执迷不悟",一生追求,即便引发大灾难也绝不松手的坚果。
随着 NutUI 的用户越来越多,在 NutUI 的交流群里对 React 版本的呼声也越来越高,我们积极响应社区的期待,于 2021 年年中开始规划并启动 React 版的开发,经过近半年的开发和打磨,将在 2022 年元旦前隆重推出 NutUI-React 元旦版。 ---
## 特性
## 组件开发状态
* 🚀 70+ 高质量组件(React 1.0 持续开发中),覆盖移动端主流场景
### 基础组件 * 📖 基于京东APP 10.0 视觉规范
* 🍭 支持按需引用
- [ ] Button * 📖 详尽的文档和示例
- [ ] Cell * 💪 支持 TypeScript
- [ ] Icon * 💪 支持服务端渲染(测试阶段)
- [ ] Layout * 🍭 支持定制主题
- [ ] Popup * 🍭 单元测试覆盖(1.0 开发中),保障稳定性
- [ ] Toast * 📖 提供 Sketch 设计资源
- [ ] Calendar
- [ ] Checkbox ## 示例 H5 & 小程序
- [ ] DatePicker
- [ ] Picker <p>
- [ ] Radio <img src="https://img12.360buyimg.com/imagetools/jfs/t1/202336/18/18586/7437/61b832ccE0b13d53d/18605da7232a5a0e.png" height="250" alt="NutUI" />
- [ ] Rate </p>
- [ ] Switch
- [ ] Uploader
- [ ] ActionSheet ## 构建版本
- [ ] Dialog
- [ ] Notify > AMD 环境、Webpack、Vite 等构建工具环境、服务端建议使用 es 版,非模块化环境(如通过 `<script>` 标签直接引用)建议使用 umd 压缩版。
- [ ] Overlay
- [ ] PullRefresh * es **nutui.react.es.js**
- [ ] Badge
- [ ] Circle * umd **nutui.umd.js**
- [ ] Collapse
- [ ] CountDown
- [ ] NoticeBar ## 链接
- [ ] Steps
- [ ] NavBar <ul>
- [ ] Tab <li>
- [ ] Tabbar <a href="https://github.com/jdf2e/nutui-react/discussions">
- [ ] TreeSelect Discussions (用👍投票)
</a>
</li>
<li>
<a href="https://github.com/jdf2e/nutui-react/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22">
Feature Requests (用👍投票)
</a>
</li>
<li>
<a href="https://github.com/jdf2e/nutui-react/labels/bug%203.0">
Bugs (用👍投票)
</a>
</li>
<li>
<a href="https://github.com/jdf2e/nutui-react/issues?q=is%3Aissue+is%3Aopen+label%3Aquestion">
Question (用👍投票)
</a>
</li>
</ul>
[//]: # (## 开发交流)
[//]: # ()
[//]: # (| 版本 | 微信群 |内部咚咚群 |)
[//]: # (| --- | --- |--- |)
[//]: # (| [NutUI React]&#40;https://github.com/jdf2e/nutui-react/issues&#41; | 回复「NutUI」 | 1022619199)
[//]: # (| [NutUI Vue]&#40;https://github.com/jdf2e/nutui/issues&#41; | <img src="https://nutui.jd.com/3x/3.1.12/vx-code1.png" width="100" /> 关注后回复「NutUI」 | 82957939)
[//]: # (| [NutUI x Taro]&#40;https://github.com/jdf2e/nutui/issues&#41; | <img src="https://camo.githubusercontent.com/db4276b4ee4b443158195e943e9e678cb4d2afb7580f70d4d817ef0a90413aec/687474703a2f2f73746f726167652e333630627579696d672e636f6d2f7461726f2d6a642d636f6d2f7374617469632f636f6e746163745f7461726f5f6e757475695f71722e706e67" width="100" /> 关注后回复「NutUI」 | 1022545110 |)
[//]: # ()
[//]: # (## 贡献者们)
[//]: # ()
[//]: # (感谢以下小伙伴们为 NutUI 发展做出的贡献:)
[//]: # ()
[//]: # (<a href="https://github.com/jdf2e/nutui/graphs/contributors">)
[//]: # ( <img src="https://opencollective.com/nutui/contributors.svg?width=890&button=false" alt="contributors">)
[//]: # (</a>)
## 参与共建
非常欢迎社区开发者为 NutUI 贡献代码,在贡献之前请先阅读 [贡献指南](https://nutui.jd.com/#/contributing),参与共建提 [PR](https://github.com/jdf2e/nutui/pulls)
感谢以下所有给 NutUI 贡献过代码的 [开发者](https://github.com/jdf2e/nutui/graphs/contributors)
## 开发计划
[Milestones](https://github.com/jdf2e/nutui-react/projects)
## 更新日志
本项目遵从 [Angular Style Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153),更新日志请查阅 [Release](https://github.com/jdf2e/nutui-react/releases)
## 开源协议
本项目基于 **MIT** 协议
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"style": "dist/style.css", "style": "dist/style.css",
"main": "dist/nutui.react.umd.js", "main": "dist/nutui.react.umd.js",
"module": "dist/esm/nutui-react.es.js", "module": "dist/esm/nutui-react.es.js",
"typings": "dist/esm/types/src/packages/nutui.react.d.ts", "typings": "dist/types/nutui.react.d.ts",
"sideEffects": [ "sideEffects": [
"*.scss", "*.scss",
"dist/esm/**/style/*", "dist/esm/**/style/*",
......
// replace types alias for build // replace types alias for build
const vfs = require('vinyl-fs') const vfs = require('vinyl-fs')
const map = require('map-stream') const map = require('map-stream')
const dest_docs = './dist/esm/types/src/packages' const fs = require('fs-extra')
const dest_docs = './dist/types'
vfs vfs
.src(['./dist/esm/types/src/packages/nutui.react.d.ts']) .src(['./dist/esm/types/src/packages/nutui.react.d.ts'])
...@@ -16,16 +17,18 @@ vfs ...@@ -16,16 +17,18 @@ vfs
}) })
) )
.pipe(vfs.dest(dest_docs, { overwrite: true })) .pipe(vfs.dest(dest_docs, { overwrite: true }))
.on('end', () => {}) .on('end', () => {
vfs
vfs .src(['./dist/esm/types/src/packages/**/*.d.ts', '!./dist/esm/types/src/packages/*.d.ts'])
.src(['./dist/esm/types/src/packages/**/*.d.ts', '!./dist/esm/types/src/packages/*.d.ts']) .pipe(
.pipe( map((file, cb) => {
map((file, cb) => { const contents = file.contents.toString().replaceAll('@/packages', `..`)
const contents = file.contents.toString().replaceAll('@/packages', `..`) file.contents = Buffer.from(contents, 'utf8')
file.contents = Buffer.from(contents, 'utf8') cb(null, file)
cb(null, file) })
}) )
) .pipe(vfs.dest(dest_docs, { overwrite: true }))
.pipe(vfs.dest(dest_docs, { overwrite: true })) .on('end', () => {
.on('end', () => {}) fs.remove('./dist/esm/types')
})
})
...@@ -172,6 +172,8 @@ export const Address: FunctionComponent< ...@@ -172,6 +172,8 @@ export const Address: FunctionComponent<
[tabName[i]]: {}, [tabName[i]]: {},
}) })
} }
console.log(selectedRegion)
} }
// 关闭 // 关闭
const closeFun = () => { const closeFun = () => {
......
...@@ -223,6 +223,40 @@ export const CustomRender: FunctionComponent< ...@@ -223,6 +223,40 @@ export const CustomRender: FunctionComponent<
nextAreaList(item) nextAreaList(item)
} }
useEffect(() => {
const { province } = { ...defaultProps, ...props }
setRegionList({
...regionList,
province: isCustom2() ? transformData(province) : province,
})
}, [province])
useEffect(() => {
const { city } = { ...defaultProps, ...props }
setRegionList({
...regionList,
city: isCustom2() ? transformData(city) : city,
})
}, [city])
useEffect(() => {
const { country } = { ...defaultProps, ...props }
setRegionList({
...regionList,
country: isCustom2() ? transformData(country) : country,
})
}, [country])
useEffect(() => {
const { town } = { ...defaultProps, ...props }
setRegionList({
...regionList,
town: isCustom2() ? transformData(town) : town,
})
}, [town])
return ( return (
<div className={b('custom')}> <div className={b('custom')}>
<div className={b('region-tab')}> <div className={b('region-tab')}>
......
...@@ -45,20 +45,9 @@ const AddressDemo = () => { ...@@ -45,20 +45,9 @@ const AddressDemo = () => {
{ id: 5, name: '浙江', title: 'Z' }, { id: 5, name: '浙江', title: 'Z' },
]) ])
const [city, setCity] = useState([ const [city, setCity] = useState([])
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
const [country, setCountry] = useState([ const [country, setCountry] = useState([])
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
const [town, setTown] = useState([]) const [town, setTown] = useState([])
...@@ -136,14 +125,34 @@ const AddressDemo = () => { ...@@ -136,14 +125,34 @@ const AddressDemo = () => {
} }
const onChange = (cal: CalBack, tag: string) => { const onChange = (cal: CalBack, tag: string) => {
console.log('change') console.log('change', cal)
const name = (address as any)[cal.next]
if (name.length < 1) { setTimeout(() => {
setShowPopup({ switch (cal.next) {
...showPopup, case 'city':
[tag]: false, setCity([
}) { id: 7, name: '朝阳区', title: 'C' },
} { id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
break
case 'country':
setCountry([
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
break
default:
setShowPopup({
...showPopup,
[tag]: false,
})
}
}, 200)
} }
const selected = (prevExistAdd: AddressList, nowExistAdd: AddressList, arr: AddressList[]) => { const selected = (prevExistAdd: AddressList, nowExistAdd: AddressList, arr: AddressList[]) => {
......
...@@ -29,21 +29,11 @@ const App = () => { ...@@ -29,21 +29,11 @@ const App = () => {
{ id: 5, name: '浙江', title: 'Z' }, { id: 5, name: '浙江', title: 'Z' },
]) ])
const [city, setCity] = useState([ const [city, setCity] = useState([])
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
const [country, setCountry] = useState([ const [country, setCountry] = useState([])
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
const [town, setTown] = useState([]) const [town, setTown] = useState([])
const [address, setAddress] = useState({ const [address, setAddress] = useState({
province: province, province: province,
city: city, city: city,
...@@ -52,11 +42,30 @@ const App = () => { ...@@ -52,11 +42,30 @@ const App = () => {
}) })
const onChange = (cal) => { const onChange = (cal) => {
const name = address[cal.next] const name = address[cal.next]
setTimeout(()=>{
if (name.length < 1) { switch (cal.next){
setNormal(false) case 'city':
setCity([
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
break;
case 'country':
setCountry([
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
break;
default:
setNormal(false)
} }
},200)
} }
const close = (val) => { const close = (val) => {
console.log(val) console.log(val)
...@@ -104,20 +113,9 @@ const App = () => { ...@@ -104,20 +113,9 @@ const App = () => {
{ id: 5, name: '浙江', title: 'Z' }, { id: 5, name: '浙江', title: 'Z' },
]) ])
const [city, setCity] = useState([ const [city, setCity] = useState([])
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
const [country, setCountry] = useState([ const [country, setCountry] = useState([])
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
const [town, setTown] = useState([]) const [town, setTown] = useState([])
const [address, setAddress] = useState({ const [address, setAddress] = useState({
province: province, province: province,
...@@ -127,10 +125,29 @@ const App = () => { ...@@ -127,10 +125,29 @@ const App = () => {
}) })
const onChange = (cal) => { const onChange = (cal) => {
const name = address[cal.next] setTimeout(()=>{
if (name.length < 1) { switch (cal.next){
setNormal2(false) case 'city':
setCity([
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
break;
case 'country':
setCountry([
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
break;
default:
setNormal2(false)
} }
},200)
} }
const close = (val) => { const close = (val) => {
setNormal2(false) setNormal2(false)
...@@ -360,20 +377,9 @@ const App = () => { ...@@ -360,20 +377,9 @@ const App = () => {
{ id: 5, name: '浙江', title: 'Z' }, { id: 5, name: '浙江', title: 'Z' },
]) ])
const [city, setCity] = useState([ const [city, setCity] = useState([])
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
const [country, setCountry] = useState([ const [country, setCountry] = useState([])
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
const [town, setTown] = useState([]) const [town, setTown] = useState([])
const [address, setAddress] = useState({ const [address, setAddress] = useState({
province: province, province: province,
...@@ -422,10 +428,30 @@ const App = () => { ...@@ -422,10 +428,30 @@ const App = () => {
} }
const onChange = (cal) => { const onChange = (cal) => {
const name = address[cal.next]
if (name.length < 1) { setTimeout(()=>{
setOther(false) switch (cal.next){
case 'city':
setCity([
{ id: 7, name: '朝阳区', title: 'C' },
{ id: 8, name: '崇文区', title: 'C' },
{ id: 9, name: '昌平区', title: 'C' },
{ id: 6, name: '石景山区', title: 'S' },
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
])
break;
case 'country':
setCountry([
{ id: 3, name: '八里庄街道', title: 'B' },
{ id: 9, name: '北苑', title: 'B' },
{ id: 4, name: '常营乡', title: 'C' },
])
break;
default:
setOther(false)
} }
},200)
} }
const close = (val) => { const close = (val) => {
setOther(false) setOther(false)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册