feat: add percent field component
This commit is contained in:
parent
cbc81f1173
commit
2828a82f7d
@ -1,3 +1,4 @@
|
||||
import React from 'react';
|
||||
import { connect } from '@formily/react-schema-renderer'
|
||||
import { InputNumber } from 'antd'
|
||||
import { acceptEnum, mapStyledProps, mapTextComponent } from '../shared'
|
||||
@ -7,4 +8,15 @@ export const NumberPicker = connect({
|
||||
getComponent: mapTextComponent
|
||||
})(acceptEnum(InputNumber))
|
||||
|
||||
export const Percent = connect({
|
||||
getProps: mapStyledProps,
|
||||
getComponent: mapTextComponent
|
||||
})(acceptEnum((props) => (
|
||||
<InputNumber
|
||||
formatter={value => value ? `${value}%` : ''}
|
||||
parser={value => value.replace('%', '')}
|
||||
{...props}
|
||||
/>
|
||||
)))
|
||||
|
||||
export default NumberPicker
|
||||
|
@ -7,7 +7,7 @@ import { ArrayTable } from './array-table'
|
||||
import { Checkbox } from './checkbox'
|
||||
import { DatePicker } from './date-picker'
|
||||
import { Input } from './input'
|
||||
import { NumberPicker } from './number-picker'
|
||||
import { NumberPicker, Percent } from './number-picker'
|
||||
import { Password } from './password'
|
||||
import { Radio } from './radio'
|
||||
import { Range } from './range'
|
||||
@ -34,6 +34,7 @@ export const setup = () => {
|
||||
string: Input,
|
||||
textarea: Input.TextArea,
|
||||
number: NumberPicker,
|
||||
percent: Percent,
|
||||
password: Password,
|
||||
radio: Radio.Group,
|
||||
range: Range,
|
||||
|
Loading…
Reference in New Issue
Block a user