UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 4.25 kB
{"version":3,"file":"NumberFormatter.cjs","sources":["../../../src/components/NumberFormatter/NumberFormatter.tsx"],"sourcesContent":["import { NumericFormat } from 'react-number-format';\nimport { ExtendComponent, Factory, MantineThemeComponent, useProps } from '../../core';\n\nexport interface NumberFormatterProps extends React.ComponentPropsWithoutRef<'span'> {\n /** Value to format */\n value?: number | string;\n\n /** Determines whether negative values are allowed, `true` by default */\n allowNegative?: boolean;\n\n /** Limits the number of digits that are displayed after the decimal point, by default there is no limit */\n decimalScale?: number;\n\n /** Character used as a decimal separator, `'.'` by default */\n decimalSeparator?: string;\n\n /** If set, 0s are added after `decimalSeparator` to match given `decimalScale`. `false` by default */\n fixedDecimalScale?: boolean;\n\n /** Prefix added before the value */\n prefix?: string;\n\n /** Suffix added after the value */\n suffix?: string;\n\n /** Defines the thousand grouping style */\n thousandsGroupStyle?: 'thousand' | 'lakh' | 'wan' | 'none';\n\n /** A character used to separate thousands, `','` by default */\n thousandSeparator?: string | boolean;\n}\n\nexport type NumberFormatterFactory = Factory<{\n props: NumberFormatterProps;\n ref: HTMLDivElement;\n}>;\n\nconst defaultProps: Partial<NumberFormatterProps> = {};\n\nexport function NumberFormatter(_props: NumberFormatterProps) {\n const props = useProps('NumberFormatter', defaultProps, _props);\n const { value, defaultValue, ...others } = props;\n\n if (value === undefined) {\n return null;\n }\n\n return <NumericFormat displayType=\"text\" value={value} {...others} />;\n}\n\nconst extendNumberFormatter = (c: ExtendComponent<NumberFormatterFactory>): MantineThemeComponent =>\n c;\n\nNumberFormatter.extend = extendNumberFormatter;\nNumberFormatter.displayName = '@mantine/core/NumberFormatter';\n"],"names":["useProps","NumericFormat"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAA8C,CAAC,CAAA,CAA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