Skip to content

Commit

Permalink
fix(inputnumber): 适配RN和鸿蒙,加减按钮icon在RN和鸿蒙暂不展示 (jdf2e#2353)
Browse files Browse the repository at this point in the history
* fix: 适配rn

* fix: 适配鸿蒙

* fix: 鸿蒙适配

* fix: 样式优化

* fix: 更改版本号

* fix: 多端验证修改

* fix: demo增加平台判断

* fix: cr修改

* fix: 修改harmony

* fix: 移除无用代码
  • Loading branch information
irisSong authored Jun 18, 2024
1 parent 5d2cc78 commit c92319a
Show file tree
Hide file tree
Showing 26 changed files with 273 additions and 215 deletions.
1 change: 1 addition & 0 deletions packages/nutui-taro-demo-rn/scripts/taro/adapted.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports = module.exports = [
'hoverbutton',
'safearea',
'hoverbuttonitem',
'inputnumber',
'configprovider',
'input',
]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export default <>button</>;
import Demo from '@/packages/inputnumber/demo.taro';
export default Demo;
2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
"author": "VickyYe"
},
{
"version": "2.0.0",
"version": "3.0.0",
"name": "InputNumber",
"type": "component",
"cName": "数字输入框",
Expand Down
60 changes: 19 additions & 41 deletions src/packages/inputnumber/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { Cell } from '@nutui/nutui-react-taro'
import { ScrollView, View } from '@tarojs/components'
import { useTranslate } from '@/sites/assets/locale/taro'
import Header from '@/sites/components/header'

Expand Down Expand Up @@ -63,48 +63,26 @@ const InputNumberDemo = () => {
return (
<>
<Header />
<div className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}>
<h2>{translated['84aa6bce']}</h2>
<Cell>
<Demo1 />
</Cell>

<h2>{translated['55cc5fb7']}</h2>
<Cell>
<Demo2 />
</Cell>

<h2>{translated['9636103a']}</h2>
<Cell>
<Demo3 />
</Cell>

<h2>{translated['181965e2']}</h2>
<Cell>
<Demo4 />
</Cell>

<h2>{translated.e7b2ce1f}</h2>
<Cell>
<Demo5 />
</Cell>

<h2>{translated.e7b2ce1g}</h2>
<ScrollView className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}>
<View className="h2">{translated['84aa6bce']}</View>
<Demo1 />
<View className="h2">{translated['55cc5fb7']}</View>
<Demo2 />
<View className="h2">{translated['9636103a']}</View>
<Demo3 />
<View className="h2">{translated['181965e2']}</View>
<Demo4 />
<View className="h2">{translated.e7b2ce1f}</View>
<Demo5 />
<View className="h2">{translated.e7b2ce1g}</View>
<Demo6 />

<h2>{translated['3a42134b']}</h2>
<Cell>
<Demo7 />
</Cell>

<h2>{translated['65bafb1d']}</h2>
<Cell>
<Demo8 />
</Cell>

<h2>Formatter</h2>
<View className="h2">{translated['3a42134b']}</View>
<Demo7 />
<View className="h2">{translated['65bafb1d']}</View>
<Demo8 />
<View className="h2">Formatter</View>
<Demo9 />
</div>
</ScrollView>
</>
)
}
Expand Down
37 changes: 7 additions & 30 deletions src/packages/inputnumber/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import { useTranslate } from '../../sites/assets/locale'
import Cell from '@/packages/cell'
import Demo1 from './demos/h5/demo1'
import Demo2 from './demos/h5/demo2'
import Demo3 from './demos/h5/demo3'
Expand Down Expand Up @@ -61,43 +60,21 @@ const InputNumberDemo = () => {
<>
<div className="demo">
<h2>{translated['84aa6bce']}</h2>
<Cell>
<Demo1 />
</Cell>

<Demo1 />
<h2>{translated['55cc5fb7']}</h2>
<Cell>
<Demo2 />
</Cell>

<Demo2 />
<h2>{translated['9636103a']}</h2>
<Cell>
<Demo3 />
</Cell>

<Demo3 />
<h2>{translated['181965e2']}</h2>
<Cell>
<Demo4 />
</Cell>

<Demo4 />
<h2>{translated.e7b2ce1f}</h2>
<Cell>
<Demo5 />
</Cell>

<Demo5 />
<h2>{translated.e7b2ce1g}</h2>
<Demo6 />

<h2>{translated['3a42134b']}</h2>
<Cell>
<Demo7 />
</Cell>

<Demo7 />
<h2>{translated['65bafb1d']}</h2>
<Cell>
<Demo8 />
</Cell>

<Demo8 />
<h2>Formatter</h2>
<Demo9 />
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react'
import { Cell, InputNumber } from '@nutui/nutui-react'

const Demo1 = () => {
return <InputNumber defaultValue={1} allowEmpty />
return (
<Cell>
<InputNumber defaultValue={1} allowEmpty />
</Cell>
)
}
export default Demo1
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/h5/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react'
import { Cell, InputNumber } from '@nutui/nutui-react'

const Demo2 = () => {
return <InputNumber defaultValue={0} min={0} step={5} />
return (
<Cell>
<InputNumber defaultValue={0} min={0} step={5} />
</Cell>
)
}
export default Demo2
11 changes: 9 additions & 2 deletions src/packages/inputnumber/demos/h5/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import React from 'react'
import { InputNumber, Toast } from '@nutui/nutui-react'
import { Cell, InputNumber, Toast } from '@nutui/nutui-react'

const Demo3 = () => {
const overlimit = () => {
Toast.show({ content: '超出限制事件触发', icon: 'warn' })
}
return (
<InputNumber defaultValue={10} min={10} max={20} onOverlimit={overlimit} />
<Cell>
<InputNumber
defaultValue={10}
min={10}
max={20}
onOverlimit={overlimit}
/>
</Cell>
)
}
export default Demo3
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/h5/demo4.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react'
import { Cell, InputNumber } from '@nutui/nutui-react'

const Demo4 = () => {
return <InputNumber defaultValue={0} disabled />
return (
<Cell>
<InputNumber defaultValue={0} disabled />
</Cell>
)
}
export default Demo4
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/h5/demo5.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react'
import { Cell, InputNumber } from '@nutui/nutui-react'

const Demo5 = () => {
return <InputNumber defaultValue={1} readOnly />
return (
<Cell>
<InputNumber defaultValue={1} readOnly />
</Cell>
)
}
export default Demo5
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/h5/demo7.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react'
import { Cell, InputNumber } from '@nutui/nutui-react'

const Demo7 = () => {
return <InputNumber defaultValue={5.5} step={0.1} digits={1} readOnly />
return (
<Cell>
<InputNumber defaultValue={5.5} step={0.1} digits={1} readOnly />
</Cell>
)
}
export default Demo7
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/h5/demo8.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { InputNumber, Toast } from '@nutui/nutui-react'
import { Cell, InputNumber, Toast } from '@nutui/nutui-react'

const Demo8 = () => {
const [inputValue, setInputValue] = useState(0)
Expand All @@ -10,6 +10,10 @@ const Demo8 = () => {
Toast.clear()
}, 2000)
}
return <InputNumber value={inputValue} min={-6} onChange={onChange} async />
return (
<Cell>
<InputNumber value={inputValue} min={-6} onChange={onChange} async />
</Cell>
)
}
export default Demo8
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react-taro'
import { Cell, InputNumber } from '@nutui/nutui-react-taro'

const Demo1 = () => {
return <InputNumber defaultValue={1} allowEmpty />
return (
<Cell>
<InputNumber defaultValue={1} allowEmpty />
</Cell>
)
}
export default Demo1
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/taro/demo2.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react-taro'
import { Cell, InputNumber } from '@nutui/nutui-react-taro'

const Demo2 = () => {
return <InputNumber defaultValue={0} min={0} step={5} />
return (
<Cell>
<InputNumber defaultValue={0} min={0} step={5} />
</Cell>
)
}
export default Demo2
20 changes: 11 additions & 9 deletions src/packages/inputnumber/demos/taro/demo3.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { InputNumber, Toast } from '@nutui/nutui-react-taro'
import { Cell, InputNumber } from '@nutui/nutui-react-taro'

const Demo3 = () => {
const overlimit = () => {
Expand All @@ -17,20 +17,22 @@ const Demo3 = () => {

return (
<>
<InputNumber
defaultValue={10}
min={10}
max={20}
onOverlimit={overlimit}
/>
<Toast
<Cell>
<InputNumber
defaultValue={10}
min={10}
max={20}
onOverlimit={overlimit}
/>
</Cell>
{/* <Toast
type={toastType}
visible={show}
content={toastMsg}
onClose={() => {
SetShow(false)
}}
/>
/> */}
</>
)
}
Expand Down
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/taro/demo4.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react-taro'
import { Cell, InputNumber } from '@nutui/nutui-react-taro'

const Demo4 = () => {
return <InputNumber defaultValue={0} disabled />
return (
<Cell>
<InputNumber defaultValue={0} disabled />
</Cell>
)
}
export default Demo4
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react-taro'
import { Cell, InputNumber } from '@nutui/nutui-react-taro'

const Demo5 = () => {
return <InputNumber defaultValue={1} readOnly />
return (
<Cell>
<InputNumber defaultValue={1} readOnly />
</Cell>
)
}
export default Demo5
2 changes: 1 addition & 1 deletion src/packages/inputnumber/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Cell, InputNumber, ConfigProvider } from '@nutui/nutui-react-taro'
import { Cell, ConfigProvider, InputNumber } from '@nutui/nutui-react-taro'

const Demo6 = () => {
const customTheme = {
Expand Down
8 changes: 6 additions & 2 deletions src/packages/inputnumber/demos/taro/demo7.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react'
import { InputNumber } from '@nutui/nutui-react-taro'
import { Cell, InputNumber } from '@nutui/nutui-react-taro'

const Demo7 = () => {
return <InputNumber defaultValue={5.5} step={0.1} digits={1} readOnly />
return (
<Cell>
<InputNumber defaultValue={5.5} step={0.1} digits={1} readOnly />
</Cell>
)
}
export default Demo7
Loading

0 comments on commit c92319a

Please sign in to comment.