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 { connect } from '@formily/react-schema-renderer'
|
||||||
import { InputNumber } from 'antd'
|
import { InputNumber } from 'antd'
|
||||||
import { acceptEnum, mapStyledProps, mapTextComponent } from '../shared'
|
import { acceptEnum, mapStyledProps, mapTextComponent } from '../shared'
|
||||||
@ -7,4 +8,15 @@ export const NumberPicker = connect({
|
|||||||
getComponent: mapTextComponent
|
getComponent: mapTextComponent
|
||||||
})(acceptEnum(InputNumber))
|
})(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
|
export default NumberPicker
|
||||||
|
@ -7,7 +7,7 @@ import { ArrayTable } from './array-table'
|
|||||||
import { Checkbox } from './checkbox'
|
import { Checkbox } from './checkbox'
|
||||||
import { DatePicker } from './date-picker'
|
import { DatePicker } from './date-picker'
|
||||||
import { Input } from './input'
|
import { Input } from './input'
|
||||||
import { NumberPicker } from './number-picker'
|
import { NumberPicker, Percent } from './number-picker'
|
||||||
import { Password } from './password'
|
import { Password } from './password'
|
||||||
import { Radio } from './radio'
|
import { Radio } from './radio'
|
||||||
import { Range } from './range'
|
import { Range } from './range'
|
||||||
@ -34,6 +34,7 @@ export const setup = () => {
|
|||||||
string: Input,
|
string: Input,
|
||||||
textarea: Input.TextArea,
|
textarea: Input.TextArea,
|
||||||
number: NumberPicker,
|
number: NumberPicker,
|
||||||
|
percent: Percent,
|
||||||
password: Password,
|
password: Password,
|
||||||
radio: Radio.Group,
|
radio: Radio.Group,
|
||||||
range: Range,
|
range: Range,
|
||||||
|
Loading…
Reference in New Issue
Block a user