@@ -6,19 +6,25 @@ import React, {
66 ChangeEvent ,
77} from 'react'
88import 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'
1016import { Minus , Plus } from '@nutui/icons-react-taro'
1117import { usePropsValue } from '@/utils/use-props-value'
1218import { BasicComponent , ComponentDefaults } from '@/utils/typings'
13- import { harmony , harmonyAndRn , rn } from '@/utils/platform-taro'
19+ import { harmonyAndRn , rn } from '@/utils/platform-taro'
1420
1521export 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 } ) }
0 commit comments