fix: percent field component should support decimal point (#2966)
This commit is contained in:
parent
59854085b2
commit
a42ee95e03
@ -1,10 +1,12 @@
|
||||
import { connect, mapReadPretty } from '@formily/react';
|
||||
import { isNumberLike } from '@formily/shared';
|
||||
import { isNum } from '@formily/shared';
|
||||
import { InputNumber } from 'antd';
|
||||
import * as math from 'mathjs';
|
||||
import React, { useMemo } from 'react';
|
||||
import { ReadPretty } from '../input-number/ReadPretty';
|
||||
|
||||
const isNumberLike = (index: any): index is number => isNum(index) || /^-?\d+(\.\d+)?$/.test(index);
|
||||
|
||||
const toValue = (value: any, callback: (v: number) => number) => {
|
||||
if (isNumberLike(value)) {
|
||||
return math.round(callback(value), 9);
|
||||
|
Loading…
Reference in New Issue
Block a user