ant-design / ant-design-mobile

Essential UI blocks for building mobile web apps.
https://mobile.ant.design
MIT License
11.64k stars 2.4k forks source link

InputItem display text use Formatter & Parser #1992

Closed paranoidjk closed 6 years ago

paranoidjk commented 6 years ago

Problem

Right now InputItem type will have impact on the value format, not just the display text format, eg: type="phone" will got something like "123 1234 5678". It may cause extra work when users want to post data to server etc.

Proposal

A

Just do a transform with display text, onChange always give a rawValue (rawValue: string) => {}

B

Add a formatter & parse to do all custom display feature. eg: antd InputNumber: formatter & parse https://ant.design/components/input-number-cn/#API

silentcloud commented 6 years ago

A may be better for no break changes.

paranoidjk commented 6 years ago

A still may consider as a break change. `

Only if we make (value: string, rawValue: string) => {} , which may consider no break change, but i think it's no use, the users still need to know that they should get the second params.

Break change may leave to antd-mobile@3. This problem is not very emergency.

silentcloud commented 6 years ago

image

terranc commented 4 years ago

B