From 45c0cf9a01e2ef825d548e9c2ee082620f143641 Mon Sep 17 00:00:00 2001 From: Son Tran Date: Tue, 5 Dec 2023 09:52:36 +0700 Subject: [PATCH] Support `roundingMode` for InputNumber --- components/lib/inputnumber/InputNumber.js | 9 ++++++--- components/lib/inputnumber/inputnumber.d.ts | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index e73cc328a7..42d7173a0a 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -58,7 +58,8 @@ export const InputNumber = React.memo( currencyDisplay: props.currencyDisplay, useGrouping: props.useGrouping, minimumFractionDigits: props.minFractionDigits, - maximumFractionDigits: props.maxFractionDigits + maximumFractionDigits: props.maxFractionDigits, + roundingMode: props.roundingMode, }; }; @@ -108,7 +109,8 @@ export const InputNumber = React.memo( currency: props.currency, currencyDisplay: props.currencyDisplay, minimumFractionDigits: 0, - maximumFractionDigits: 0 + maximumFractionDigits: 0, + roundingMode: props.roundingMode, }); return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(_numeral.current, '').replace(_group.current, '')}]`, 'g'); @@ -138,7 +140,8 @@ export const InputNumber = React.memo( currency: props.currency, currencyDisplay: props.currencyDisplay, minimumFractionDigits: 0, - maximumFractionDigits: 0 + maximumFractionDigits: 0, + roundingMode: props.roundingMode, }); suffixChar.current = formatter.format(1).split('1')[1]; diff --git a/components/lib/inputnumber/inputnumber.d.ts b/components/lib/inputnumber/inputnumber.d.ts index 4497b2c80f..34a82e1145 100644 --- a/components/lib/inputnumber/inputnumber.d.ts +++ b/components/lib/inputnumber/inputnumber.d.ts @@ -16,6 +16,17 @@ import { TooltipOptions } from '../tooltip/tooltipoptions'; import { FormEvent } from '../ts-helpers'; import { IconType, PassThroughType } from '../utils/utils'; +export declare type RoundingMode = + | 'ceil' + | 'floor' + | 'expand' + | 'trunc' + | 'halfCeil' + | 'halfFloor' + | 'halfExpand' + | 'halfTrunc' + | 'halfEven'; + export declare type InputNumberPassThroughType = PassThroughType; /** @@ -190,6 +201,11 @@ export interface InputNumberProps extends Omit