From 2e6f598871262577c9215230547198a8e6f4ac99 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 12:12:24 +0800 Subject: [PATCH] feat(nocodb-sdk): add isNumericCol --- packages/nocodb-sdk/src/index.ts | 2 +- packages/nocodb-sdk/src/lib/UITypes.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/nocodb-sdk/src/index.ts b/packages/nocodb-sdk/src/index.ts index cc60bc8476..c323e08cc1 100644 --- a/packages/nocodb-sdk/src/index.ts +++ b/packages/nocodb-sdk/src/index.ts @@ -7,7 +7,7 @@ export * from './lib/globals'; export * from './lib/helperFunctions'; export * from './lib/enums'; export * from './lib/formulaHelpers'; -export { default as UITypes, isVirtualCol } from './lib/UITypes'; +export { default as UITypes, isNumericCol, isVirtualCol } from './lib/UITypes'; export { default as CustomAPI } from './lib/CustomAPI'; export { default as TemplateGenerator } from './lib/TemplateGenerator'; export * from './lib/passwordHelpers'; diff --git a/packages/nocodb-sdk/src/lib/UITypes.ts b/packages/nocodb-sdk/src/lib/UITypes.ts index efef013b65..c80ae7f748 100644 --- a/packages/nocodb-sdk/src/lib/UITypes.ts +++ b/packages/nocodb-sdk/src/lib/UITypes.ts @@ -39,6 +39,24 @@ enum UITypes { Button = 'Button', } +export function isNumericCol( + col: + | UITypes + | { readonly uidt: UITypes | string } + | ColumnReqType + | ColumnType +) { + return [ + UITypes.Duration, + UITypes.Currency, + UITypes.Percent, + UITypes.Number, + UITypes.Decimal, + UITypes.Rating, + UITypes.Rollup, + ].includes((typeof col === 'object' ? col?.uidt : col)); +} + export function isVirtualCol( col: | UITypes