Skip to content

Commit 51eb6f9

Browse files
committed
fix: 修改harmony
1 parent 423398c commit 51eb6f9

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

src/packages/inputnumber/demos/taro/demo9.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState } from 'react'
22
import { Cell, ConfigProvider, InputNumber } from '@nutui/nutui-react-taro'
3-
import { harmonyAndRn } from '@/utils/platform-taro'
43

54
const Demo9 = () => {
65
const customTheme3 = {
@@ -9,7 +8,6 @@ const Demo9 = () => {
98
const [toastType, SetToastType] = useState('text')
109
const [show, SetShow] = useState(false)
1110
const [toastMsg, SetToastMsg] = useState('')
12-
const isRnAndHarmony = harmonyAndRn()
1311
return (
1412
<>
1513
<Cell>
@@ -26,25 +24,15 @@ const Demo9 = () => {
2624
</ConfigProvider>
2725
</Cell>
2826
<Cell>
29-
{isRnAndHarmony ? (
27+
<ConfigProvider theme={customTheme3}>
3028
<InputNumber
3129
className="format-width"
3230
defaultValue={100}
3331
min={0}
3432
max={100}
3533
formatter={(value) => `${value}%`}
3634
/>
37-
) : (
38-
<ConfigProvider theme={customTheme3}>
39-
<InputNumber
40-
className="format-width"
41-
defaultValue={100}
42-
min={0}
43-
max={100}
44-
formatter={(value) => `${value}%`}
45-
/>
46-
</ConfigProvider>
47-
)}
35+
</ConfigProvider>
4836
</Cell>
4937
{/* <Toast
5038
type={toastType}

src/packages/inputnumber/inputnumber.taro.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ import React, {
66
ChangeEvent,
77
} from 'react'
88
import classNames from 'classnames'
9-
import { ITouchEvent, Input, InputProps, View, Text } from '@tarojs/components'
9+
import {
10+
ITouchEvent,
11+
Input as TaroInput,
12+
InputProps,
13+
View,
14+
Text,
15+
} from '@tarojs/components'
1016
import { Minus, Plus } from '@nutui/icons-react-taro'
1117
import { usePropsValue } from '@/utils/use-props-value'
1218
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
13-
import { harmony, harmonyAndRn, rn } from '@/utils/platform-taro'
19+
import { harmonyAndRn, rn } from '@/utils/platform-taro'
1420

1521
export interface InputNumberProps extends BasicComponent {
1622
value: number | string
1723
defaultValue: number | string
1824
allowEmpty: boolean
1925
min: number | string
2026
max: number | string
21-
type?: Extract<InputProps['type'], 'text' | 'number' | 'digit'>
27+
type?: Extract<InputProps['type'], 'number' | 'digit'>
2228
disabled: boolean
2329
readOnly: boolean
2430
step: number
@@ -183,6 +189,8 @@ export const InputNumber: FunctionComponent<
183189
return text
184190
}
185191
const handleInputChange = (e: any) => {
192+
if (!focused) return
193+
console.log('test', 3)
186194
// 设置 input 值, 在 blur 时格式化
187195
setInputValue(e.target.value)
188196
const valueStr = parseValue(e.target.value)
@@ -192,9 +200,6 @@ export const InputNumber: FunctionComponent<
192200
} else {
193201
setShadowValue(defaultValue)
194202
}
195-
} else if (harmony()) {
196-
// valueStr移除非数字字符
197-
setShadowValue(valueStr.replace(/[^\d/.]/g, ''))
198203
} else {
199204
setShadowValue(valueStr as any)
200205
}
@@ -203,6 +208,7 @@ export const InputNumber: FunctionComponent<
203208
}
204209
}
205210
const handleFocus = (e: any) => {
211+
console.log('test', 1)
206212
setFocused(true)
207213
setInputValue(
208214
shadowValue !== undefined && shadowValue !== null
@@ -212,6 +218,7 @@ export const InputNumber: FunctionComponent<
212218
onFocus && onFocus(e)
213219
}
214220
const handleBlur = (e: any) => {
221+
console.log('test', 2)
215222
setFocused(false)
216223
onBlur && onBlur(e)
217224
if (async) {
@@ -248,7 +255,7 @@ export const InputNumber: FunctionComponent<
248255
)}
249256
</View>
250257
{isRn ? (
251-
<Input
258+
<TaroInput
252259
className={classNames(`${classPrefix}-input`, {
253260
[`${classPrefix}-input-disabled`]: disabled,
254261
})}

src/styles/variables.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ $textarea-disabled-color: var(
592592
) !default;
593593

594594
// inputnumber(✅)
595-
// TODO: 临时修改
596595
$inputnumber-input-width: var(--nutui-inputnumber-input-width, 60px) !default;
597596
$inputnumber-input-height: var(--nutui-inputnumber-input-height, 24px) !default;
598597
$inputnumber-input-background-color: var(

0 commit comments

Comments
 (0)