@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 4.34 kB
Source Map (JSON)
{"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","jsx","NumericFormat"],"mappings":";;;;;;;;;;;;;;;;;AAIA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAG,C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