koval-ui
Version:
React components collection with minimalistic design. Supports theming, layout, and input validation.
1 lines • 6.93 kB
Source Map (JSON)
{"version":3,"file":"types.cjs","sources":["../../../../src/lib/Number/types.ts"],"sourcesContent":["import type {Range} from '@/internal/utils/rangeType.ts';\nimport type {Units, CurrencyCodes, Locale} from '@/internal/locale';\n\nexport enum Styles {\n decimal = 'decimal',\n currency = 'currency',\n percent = 'percent',\n unit = 'unit',\n}\n\nexport enum LocaleMatchers {\n lookup = 'lookup',\n 'best fit' = 'best fit',\n}\n\nexport enum Notations {\n standard = 'standard',\n 'scientific' = 'scientific',\n 'engineering' = 'engineering',\n 'compact' = 'compact',\n}\n\nexport enum CompactDisplayModes {\n short = 'short',\n long = 'long',\n}\n\nexport enum SignDisplayModes {\n auto = 'auto',\n always = 'always',\n exceptZero = 'exceptZero',\n // TODO: not present in built in types\n // negative = 'negative',\n never = 'never',\n}\n\nexport type DigitsConfig = {\n integer?: {\n /**\n * The minimum number of integer digits to use\n * @example\n * // minimumIntegerDigits=3\n * <Number value={3} /> // => 003\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumintegerdigits\n */\n minimum?: Range<1, 22>;\n };\n fraction?: {\n /**\n * The minimum number of fraction digits to use\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits\n */\n minimum?: Range<0, 101>;\n /**\n * The maximum number of fraction digits to use\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits\n */\n maximum?: Range<0, 101>;\n };\n significant?: {\n /**\n * The minimum number of significant digits to use\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumsignificantdigits\n */\n minimum?: Range<1, 22>;\n /**\n * The maximum number of significant digits to use\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumsignificantdigits\n */\n maximum?: Range<1, 22>;\n };\n};\n\nexport type NumberProps = {\n /** Provide a value to be formatted */\n value?: number;\n /**\n * Provide a string with a BCP 47 language tag or an Intl.Locale instance,\n * or an array of such locale identifiers. Defaults to user setting\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#locales\n */\n locale?: Locale;\n /**\n * The locale matching algorithm to use\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#localematcher\n */\n localeMatcher?: keyof typeof LocaleMatchers;\n /**\n * Provide a `digits` property config as an object\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumintegerdigits\n */\n digitsConfig?: DigitsConfig;\n /**\n * The formatting that should be displayed for the number (not %, currency) (decimal, unit)\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#notation\n */\n notation?: keyof typeof Notations;\n /**\n * Only used when `notation` is `compact` (not %, currency) (decimal, unit)\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#compactdisplay\n */\n compactDisplay?: keyof typeof CompactDisplayModes;\n /**\n * Whether to use grouping separators, such as thousands' separators (not %) (decimal, unit, currency)\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping\n */\n grouping?: boolean;\n /**\n * Display the sign for the number (all)\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#signdisplay\n */\n signDisplay?: keyof typeof SignDisplayModes;\n /**\n * Provide a unit for the number\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unit_2\n */\n // Unit specific props\n unit?: keyof typeof Units;\n /**\n * The unit formatting style to use in unit formatting\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unitdisplay\n */\n unitDisplay?: keyof typeof UnitDisplayModes;\n // Currency specific props\n /**\n * Provide ISO 4217 currency code\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currency_2\n */\n currency: keyof typeof CurrencyCodes;\n /**\n * How to display the currency in currency formatting\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencyDisplay?: keyof typeof CurrencyDisplayTypes;\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n */\n currencySign?: keyof typeof CurrencySignModes;\n};\n\nexport enum CurrencyDisplayTypes {\n code = 'code',\n symbol = 'symbol',\n narrowSymbol = 'narrowSymbol',\n name = 'name',\n}\n\nexport enum CurrencySignModes {\n standard = 'standard',\n accounting = 'accounting',\n}\n\nexport enum UnitDisplayModes {\n short = 'short',\n narrow = 'narrow',\n long = 'long',\n}\n"],"names":["Styles","LocaleMatchers","Notations","CompactDisplayModes","SignDisplayModes","CurrencyDisplayTypes","UnitDisplayModes"],"mappings":"6FAGY,IAAAA,GAAAA,IACRA,EAAA,QAAU,UACVA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,KAAO,OAJCA,IAAAA,GAAA,CAAA,CAAA,EAOAC,GAAAA,IACRA,EAAA,OAAS,SACTA,EAAA,UAAa,EAAA,WAFLA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACRA,EAAA,SAAW,WACXA,EAAA,WAAe,aACfA,EAAA,YAAgB,cAChBA,EAAA,QAAY,UAJJA,IAAAA,GAAA,CAAA,CAAA,EAOAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,KAAO,OAFCA,IAAAA,GAAA,CAAA,CAAA,EAKAC,GAAAA,IACRA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,WAAa,aAGbA,EAAA,MAAQ,QANAA,IAAAA,GAAA,CAAA,CAAA,EAiHAC,GAAAA,IACRA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,aAAe,eACfA,EAAA,KAAO,OAJCA,IAAAA,GAAA,CAAA,CAAA,EAYAC,GAAAA,IACRA,EAAA,MAAQ,QACRA,EAAA,OAAS,SACTA,EAAA,KAAO,OAHCA,IAAAA,GAAA,CAAA,CAAA"}