@procore/globalization-toolkit 1.16.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ {
2
+ "sonarlint.connectedMode.project": {
3
+ "projectKey": "globalization-toolkit"
4
+ },
5
+ "sonarlint.disableTelemetry": true
6
+ }
package/FAQ.md ADDED
@@ -0,0 +1,2 @@
1
+ # How does GTK work with en-international and en-specialty-contractor?
2
+ en-international and en-specialty-contractor are not valid locales. The GTK will throw an exception in both the cases. We recommend handling this issue in your testing during GTK adoption or a Core React upgrade to v11 or higher. To handle this issue, fallback to a valid ISO language like "en", or "en-us" or "en-gb"
package/README.md CHANGED
@@ -13,7 +13,7 @@ The engineering documentation contains technical documentation for the GTK repo.
13
13
  Further reading on the GTK:
14
14
  - [GTK Adoption Training Presentation](https://docs.google.com/presentation/d/1FtB2DR5qroKgGcxxWsu5Ac9QHA01I7WM75FUeB67izE/edit?usp=sharing)
15
15
  - [GTK SDR](https://github.com/procore/system-design-records/blob/main/lifecycle/2-pilot/internationalization/0002-globalization-toolkit.md)
16
- - [GTK FAQ]() - Coming soon!
16
+ - [GTK FAQ](https://github.com/procore/globalization-toolkit/blob/41ada23bfa8956c68a7c853da70ec11f766b417a/FAQ.md)
17
17
 
18
18
  ## Install
19
19
  NPM
@@ -443,4 +443,4 @@ The package is available under the [Procore Developers License](https://www.proc
443
443
 
444
444
  Procore - building the software that builds the world.
445
445
 
446
- Learn more about the #1 most widely used construction management software at [procore.com](https://www.procore.com/)
446
+ Learn more about the #1 most widely used construction management software at [procore.com](https://www.procore.com/)
@@ -1,4 +1,4 @@
1
- export declare type Locale = string;
2
- export declare type FormatterOptions = {
1
+ export type Locale = string;
2
+ export type FormatterOptions = {
3
3
  locale: Locale;
4
4
  };
@@ -5,42 +5,42 @@ export declare const DateTimeStyle: {
5
5
  readonly MEDIUM: "medium";
6
6
  readonly SHORT: "short";
7
7
  };
8
- export declare type DateTimeStyle = typeof DateTimeStyle[keyof typeof DateTimeStyle];
8
+ export type DateTimeStyle = (typeof DateTimeStyle)[keyof typeof DateTimeStyle];
9
9
  export declare const TimeZoneName: {
10
10
  readonly LONG: "long";
11
11
  readonly SHORT: "short";
12
12
  };
13
- export declare type TimeZoneName = typeof TimeZoneName[keyof typeof TimeZoneName];
13
+ export type TimeZoneName = (typeof TimeZoneName)[keyof typeof TimeZoneName];
14
14
  export declare const NumericTwoDigit: {
15
15
  readonly NUMERIC: "numeric";
16
16
  readonly TWO_DIGIT: "2-digit";
17
17
  };
18
- export declare type NumericTwoDigit = typeof NumericTwoDigit[keyof typeof NumericTwoDigit];
18
+ export type NumericTwoDigit = (typeof NumericTwoDigit)[keyof typeof NumericTwoDigit];
19
19
  export declare const DateStyle: {
20
20
  readonly FULL: "full";
21
21
  readonly LONG: "long";
22
22
  readonly MEDIUM: "medium";
23
23
  readonly SHORT: "short";
24
24
  };
25
- export declare type DateStyle = DateTimeStyle;
25
+ export type DateStyle = DateTimeStyle;
26
26
  export declare const TimeStyle: {
27
27
  readonly FULL: "full";
28
28
  readonly LONG: "long";
29
29
  readonly MEDIUM: "medium";
30
30
  readonly SHORT: "short";
31
31
  };
32
- export declare type TimeStyle = DateTimeStyle;
32
+ export type TimeStyle = DateTimeStyle;
33
33
  export declare const Weekday: {
34
34
  readonly LONG: "long";
35
35
  readonly SHORT: "short";
36
36
  readonly NARROW: "narrow";
37
37
  };
38
- export declare type Weekday = typeof Weekday[keyof typeof Weekday];
38
+ export type Weekday = (typeof Weekday)[keyof typeof Weekday];
39
39
  export declare const Year: {
40
40
  readonly NUMERIC: "numeric";
41
41
  readonly TWO_DIGIT: "2-digit";
42
42
  };
43
- export declare type Year = NumericTwoDigit;
43
+ export type Year = NumericTwoDigit;
44
44
  export declare const Month: {
45
45
  readonly NUMERIC: "numeric";
46
46
  readonly TWO_DIGIT: "2-digit";
@@ -48,28 +48,28 @@ export declare const Month: {
48
48
  readonly SHORT: "short";
49
49
  readonly NARROW: "narrow";
50
50
  };
51
- export declare type Month = typeof Month[keyof typeof Month];
51
+ export type Month = (typeof Month)[keyof typeof Month];
52
52
  export declare const Day: {
53
53
  readonly NUMERIC: "numeric";
54
54
  readonly TWO_DIGIT: "2-digit";
55
55
  };
56
- export declare type Day = NumericTwoDigit;
56
+ export type Day = NumericTwoDigit;
57
57
  export declare const Hour: {
58
58
  readonly NUMERIC: "numeric";
59
59
  readonly TWO_DIGIT: "2-digit";
60
60
  };
61
- export declare type Hour = NumericTwoDigit;
61
+ export type Hour = NumericTwoDigit;
62
62
  export declare const Minute: {
63
63
  readonly NUMERIC: "numeric";
64
64
  readonly TWO_DIGIT: "2-digit";
65
65
  };
66
- export declare type Minute = NumericTwoDigit;
66
+ export type Minute = NumericTwoDigit;
67
67
  export declare const Second: {
68
68
  readonly NUMERIC: "numeric";
69
69
  readonly TWO_DIGIT: "2-digit";
70
70
  };
71
- export declare type Second = NumericTwoDigit;
72
- export declare type DateLabelOptions = {
71
+ export type Second = NumericTwoDigit;
72
+ export type DateLabelOptions = {
73
73
  day: string;
74
74
  month: string;
75
75
  year: string;
@@ -174,5 +174,5 @@ export interface DateTimeOptionsComponentsHourMinute extends DateTimeOptionsBasi
174
174
  second?: never;
175
175
  timeZoneName?: TimeZoneName;
176
176
  }
177
- export declare type DateTimeOptions = DateTimeOptionsStyle | DateTimeOptionsComponentsAll | DateTimeOptionsComponentsWeekdayYearMonthDay | DateTimeOptionsComponentsYearMonthDay | DateTimeOptionsComponentsYearMonth | DateTimeOptionsComponentsMonthDay | DateTimeOptionsComponentsHourMinuteSecond | DateTimeOptionsComponentsHourMinute;
178
- export declare type DateTimeFormatPart = Intl.DateTimeFormatPart;
177
+ export type DateTimeOptions = DateTimeOptionsStyle | DateTimeOptionsComponentsAll | DateTimeOptionsComponentsWeekdayYearMonthDay | DateTimeOptionsComponentsYearMonthDay | DateTimeOptionsComponentsYearMonth | DateTimeOptionsComponentsMonthDay | DateTimeOptionsComponentsHourMinuteSecond | DateTimeOptionsComponentsHourMinute;
178
+ export type DateTimeFormatPart = Intl.DateTimeFormatPart;
package/dist/index.js CHANGED
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.getDatePlaceholder = exports.getDatePartsWithPlaceholders = exports.getStartDayOfTheWeek = exports.formatDateTimeToParts = exports.formatDateTime = exports.DateTimeFormatter = exports.getCurrencySeparators = exports.parseCurrency = exports.formatCurrencyToParts = exports.formatCurrency = exports.CurrencyFormatter = exports.getNumberSeparators = exports.parseNumber = exports.formatNumberToParts = exports.formatNumber = exports.NumberFormatter = void 0;
4
13
  var NumberFormatter_1 = require("./numbers/NumberFormatter");
@@ -20,4 +29,7 @@ Object.defineProperty(exports, "formatDateTimeToParts", { enumerable: true, get:
20
29
  Object.defineProperty(exports, "getStartDayOfTheWeek", { enumerable: true, get: function () { return DateTimeFormatter_1.getStartDayOfTheWeek; } });
21
30
  Object.defineProperty(exports, "getDatePartsWithPlaceholders", { enumerable: true, get: function () { return DateTimeFormatter_1.getDatePartsWithPlaceholders; } });
22
31
  Object.defineProperty(exports, "getDatePlaceholder", { enumerable: true, get: function () { return DateTimeFormatter_1.getDatePlaceholder; } });
32
+ exports.r2gSmokeTest = () => __awaiter(void 0, void 0, void 0, function* () {
33
+ return Promise.resolve(true);
34
+ });
23
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAMmC;AALjC,kHAAA,eAAe,OAAA;AACf,+GAAA,YAAY,OAAA;AACZ,sHAAA,mBAAmB,OAAA;AACnB,8GAAA,WAAW,OAAA;AACX,sHAAA,mBAAmB,OAAA;AAErB,iEAMqC;AALnC,sHAAA,iBAAiB,OAAA;AACjB,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,kHAAA,aAAa,OAAA;AACb,0HAAA,qBAAqB,OAAA;AAEvB,mEAOuC;AANrC,sHAAA,iBAAiB,OAAA;AACjB,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,yHAAA,oBAAoB,OAAA;AACpB,iIAAA,4BAA4B,OAAA;AAC5B,uHAAA,kBAAkB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAMmC;AALjC,kHAAA,eAAe,OAAA;AACf,+GAAA,YAAY,OAAA;AACZ,sHAAA,mBAAmB,OAAA;AACnB,8GAAA,WAAW,OAAA;AACX,sHAAA,mBAAmB,OAAA;AAErB,iEAMqC;AALnC,sHAAA,iBAAiB,OAAA;AACjB,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,kHAAA,aAAa,OAAA;AACb,0HAAA,qBAAqB,OAAA;AAEvB,mEAOuC;AANrC,sHAAA,iBAAiB,OAAA;AACjB,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,yHAAA,oBAAoB,OAAA;AACpB,iIAAA,4BAA4B,OAAA;AAC5B,uHAAA,kBAAkB,OAAA;AAwCpB,OAAO,CAAC,YAAY,GAAG,GAA2B,EAAE;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAA,CAAC"}
@@ -9,10 +9,10 @@ export declare const CurrencySign: {
9
9
  readonly ACCOUNTING: "accounting";
10
10
  readonly STANDARD: "standard";
11
11
  };
12
- declare type currencyDisplayKeys = keyof typeof CurrencyDisplay;
13
- export declare type CurrencyDisplay = typeof CurrencyDisplay[currencyDisplayKeys];
14
- declare type currencySignKeys = keyof typeof CurrencySign;
15
- export declare type CurrencySign = typeof CurrencySign[currencySignKeys];
12
+ type currencyDisplayKeys = keyof typeof CurrencyDisplay;
13
+ export type CurrencyDisplay = (typeof CurrencyDisplay)[currencyDisplayKeys];
14
+ type currencySignKeys = keyof typeof CurrencySign;
15
+ export type CurrencySign = (typeof CurrencySign)[currencySignKeys];
16
16
  export interface CurrencyOptions extends NumberOptionsBasic {
17
17
  currencyIsoCode: string;
18
18
  currencyDisplay?: CurrencyDisplay;
@@ -7,8 +7,10 @@ export declare class CurrencyFormatter {
7
7
  formatCurrencyToParts(value: number): NumberFormatPart[];
8
8
  parseCurrency(value: string): number;
9
9
  getCurrencySeparators(): Separators;
10
+ getCurrencyPlaceholders(): string;
10
11
  }
11
12
  export declare function formatCurrency(value: number | string, currencyOptions: CurrencyOptions): string;
12
13
  export declare function formatCurrencyToParts(value: number, currencyOptions: CurrencyOptions): NumberFormatPart[];
13
14
  export declare function parseCurrency(value: string, currencyOptions: CurrencyOptions): number;
14
15
  export declare function getCurrencySeparators(currencyOptions: CurrencyOptions): Separators;
16
+ export declare function getCurrencyPlaceholders(currencyOptions: CurrencyOptions): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrencySeparators = exports.parseCurrency = exports.formatCurrencyToParts = exports.formatCurrency = exports.CurrencyFormatter = void 0;
3
+ exports.getCurrencyPlaceholders = exports.getCurrencySeparators = exports.parseCurrency = exports.formatCurrencyToParts = exports.formatCurrency = exports.CurrencyFormatter = void 0;
4
4
  const FormatterUtils_1 = require("../FormatterUtils");
5
5
  const CurrencyUtils_1 = require("./CurrencyUtils");
6
6
  const NumberUtils_1 = require("./NumberUtils");
@@ -48,6 +48,13 @@ class CurrencyFormatter {
48
48
  group: parts.find(({ type }) => type === "group").value,
49
49
  };
50
50
  }
51
+ getCurrencyPlaceholders() {
52
+ const formattedPositiveNumber = this.formatCurrency(1234560.0);
53
+ const formattedNegativeNumber = this.formatCurrency(-1234560.0);
54
+ const positive = formattedPositiveNumber.replace(/[1-9]/g, "#");
55
+ const negative = formattedNegativeNumber.replace(/[1-9]/g, "#");
56
+ return `${positive};${negative}`;
57
+ }
51
58
  }
52
59
  exports.CurrencyFormatter = CurrencyFormatter;
53
60
  function formatCurrency(value, currencyOptions) {
@@ -70,4 +77,9 @@ function getCurrencySeparators(currencyOptions) {
70
77
  return formatter.getCurrencySeparators();
71
78
  }
72
79
  exports.getCurrencySeparators = getCurrencySeparators;
80
+ function getCurrencyPlaceholders(currencyOptions) {
81
+ const formatter = new CurrencyFormatter(currencyOptions);
82
+ return formatter.getCurrencyPlaceholders();
83
+ }
84
+ exports.getCurrencyPlaceholders = getCurrencyPlaceholders;
73
85
  //# sourceMappingURL=CurrencyFormatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyFormatter.js","sourceRoot":"","sources":["../../src/numbers/CurrencyFormatter.ts"],"names":[],"mappings":";;;AACA,sDAAgD;AAGhD,mDAAuD;AACvD,+CAAuD;AACvD,MAAa,iBAAiB;IAM5B,YAAY,eAAgC;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAA,oCAAoB,EAAC,eAAe,CAAC,CAAC;IACzD,CAAC;IAOD,cAAc,CAAC,KAAsB;QACnC,OAAO,IAAA,oCAAsB,EAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IAOD,qBAAqB,CAAC,KAAa;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAOD,aAAa,CAAC,KAAa;;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,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Aa,CAC3B,KAAa,EACb,eAAgC;IAEhC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAND,sCAMC;AAQD,SAAgB,qBAAqB,CACnC,eAAgC;IAEhC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,qBAAqB,EAAE,CAAC;AAC3C,CAAC;AALD,sDAKC;AAOD,SAAgB,uBAAuB,CACrC,eAAgC;IAEhC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,uBAAuB,EAAE,CAAC;AAC7C,CAAC;AALD,0DAKC"}
@@ -1,3 +1,27 @@
1
+ import "@formatjs/intl-getcanonicallocales/polyfill";
2
+ import "@formatjs/intl-locale/polyfill";
3
+ import "@formatjs/intl-pluralrules/polyfill";
4
+ import "@formatjs/intl-pluralrules/locale-data/en";
5
+ import "@formatjs/intl-pluralrules/locale-data/es";
6
+ import "@formatjs/intl-pluralrules/locale-data/fr";
7
+ import "@formatjs/intl-pluralrules/locale-data/de";
8
+ import "@formatjs/intl-pluralrules/locale-data/ja";
9
+ import "@formatjs/intl-pluralrules/locale-data/ko";
10
+ import "@formatjs/intl-pluralrules/locale-data/th";
11
+ import "@formatjs/intl-numberformat/polyfill";
12
+ import "@formatjs/intl-numberformat/locale-data/en";
13
+ import "@formatjs/intl-numberformat/locale-data/en-AE";
14
+ import "@formatjs/intl-numberformat/locale-data/en-AU";
15
+ import "@formatjs/intl-numberformat/locale-data/en-CA";
16
+ import "@formatjs/intl-numberformat/locale-data/en-GB";
17
+ import "@formatjs/intl-numberformat/locale-data/es";
18
+ import "@formatjs/intl-numberformat/locale-data/es-419";
19
+ import "@formatjs/intl-numberformat/locale-data/fr-CA";
20
+ import "@formatjs/intl-numberformat/locale-data/fr";
21
+ import "@formatjs/intl-numberformat/locale-data/de";
22
+ import "@formatjs/intl-numberformat/locale-data/ja";
23
+ import "@formatjs/intl-numberformat/locale-data/ko";
24
+ import "@formatjs/intl-numberformat/locale-data/th";
1
25
  import { CurrencyOptions } from "./Currency.types";
2
26
  export declare function getCurrencyFormatter(options: CurrencyOptions): Intl.NumberFormat;
3
27
  export declare function transformOptions(options: CurrencyOptions): Intl.NumberFormatOptions;
@@ -1,6 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateCurrencyOptions = exports.validateOptions = exports.transformCurrencyOptions = exports.transformOptions = exports.getCurrencyFormatter = void 0;
4
+ require("@formatjs/intl-getcanonicallocales/polyfill");
5
+ require("@formatjs/intl-locale/polyfill");
6
+ require("@formatjs/intl-pluralrules/polyfill");
7
+ require("@formatjs/intl-pluralrules/locale-data/en");
8
+ require("@formatjs/intl-pluralrules/locale-data/es");
9
+ require("@formatjs/intl-pluralrules/locale-data/fr");
10
+ require("@formatjs/intl-pluralrules/locale-data/de");
11
+ require("@formatjs/intl-pluralrules/locale-data/ja");
12
+ require("@formatjs/intl-pluralrules/locale-data/ko");
13
+ require("@formatjs/intl-pluralrules/locale-data/th");
14
+ require("@formatjs/intl-numberformat/polyfill");
15
+ require("@formatjs/intl-numberformat/locale-data/en");
16
+ require("@formatjs/intl-numberformat/locale-data/en-AE");
17
+ require("@formatjs/intl-numberformat/locale-data/en-AU");
18
+ require("@formatjs/intl-numberformat/locale-data/en-CA");
19
+ require("@formatjs/intl-numberformat/locale-data/en-GB");
20
+ require("@formatjs/intl-numberformat/locale-data/es");
21
+ require("@formatjs/intl-numberformat/locale-data/es-419");
22
+ require("@formatjs/intl-numberformat/locale-data/fr-CA");
23
+ require("@formatjs/intl-numberformat/locale-data/fr");
24
+ require("@formatjs/intl-numberformat/locale-data/de");
25
+ require("@formatjs/intl-numberformat/locale-data/ja");
26
+ require("@formatjs/intl-numberformat/locale-data/ko");
27
+ require("@formatjs/intl-numberformat/locale-data/th");
4
28
  const FormatterUtils_1 = require("../FormatterUtils");
5
29
  const NumberUtils_1 = require("./NumberUtils");
6
30
  function getCurrencyFormatter(options) {
@@ -30,45 +54,14 @@ function validateOptions(options) {
30
54
  }
31
55
  exports.validateOptions = validateOptions;
32
56
  function validateCurrencyOptions(currencyOptions) {
33
- if (!supportedCurrencyIsoCodes.has(currencyOptions.currencyIsoCode)) {
34
- const errorMessage = `@procore/globalization-toolkit Intl.NumberFormat error for currency ${currencyOptions.currencyIsoCode}. Please use a valid ISO Currency Code.`;
35
- console.error(errorMessage);
36
- throw new Error(errorMessage);
57
+ const alphabeticRegex = /^[a-z]*$/i;
58
+ if (currencyOptions.currencyIsoCode.length === 3 &&
59
+ alphabeticRegex.test(currencyOptions.currencyIsoCode)) {
60
+ return currencyOptions;
37
61
  }
38
- return currencyOptions;
62
+ const errorMessage = `@procore/globalization-toolkit Intl.NumberFormat error for currency ${currencyOptions.currencyIsoCode}. Please use a valid ISO Currency Code.`;
63
+ console.error(errorMessage);
64
+ throw new Error(errorMessage);
39
65
  }
40
66
  exports.validateCurrencyOptions = validateCurrencyOptions;
41
- const supportedCurrencyIsoCodes = new Set([
42
- "ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK",
43
- "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG",
44
- "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL",
45
- "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL",
46
- "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD",
47
- "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE",
48
- "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CNY", "COP", "COU",
49
- "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM",
50
- "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA",
51
- "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK",
52
- "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ",
53
- "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR",
54
- "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL",
55
- "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO",
56
- "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL",
57
- "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF",
58
- "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP",
59
- "MRO", "MRU", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP",
60
- "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG",
61
- "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP",
62
- "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD",
63
- "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK",
64
- "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD",
65
- "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT",
66
- "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK",
67
- "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS",
68
- "VEB", "VEF", "VES", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU",
69
- "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF",
70
- "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER",
71
- "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ",
72
- "ZWD", "ZWL", "ZWR"
73
- ]);
74
67
  //# sourceMappingURL=CurrencyUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyUtils.js","sourceRoot":"","sources":["../../src/numbers/CurrencyUtils.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,+CAGuB;AAEvB,SAAgB,oBAAoB,CAClC,OAAwB;IAExB,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,WAAW,GACf,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEpC,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAC5D,CAAC;AARD,oDAQC;AAED,SAAgB,gBAAgB,CAC9B,OAAwB;IAExB,uCACK,IAAA,yCAA2B,EAAC,OAAO,CAAC,GACpC,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAC5C;AACJ,CAAC;AAPD,4CAOC;AAED,SAAgB,wBAAwB,CACtC,OAAwB;IAExB,MAAM,mBAAmB,GAA6B,EAAE,CAAC;IAEzD,mBAAmB,CAAC,KAAK,GAAG,UAAU,CAAC;IACvC,mBAAmB,CAAC,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC;IACvD,mBAAmB,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAC9D,mBAAmB,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAExD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAXD,4DAWC;AAED,SAAgB,eAAe,CAAC,OAAwB;IACtD,IAAA,+BAAc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Formatter.types";
2
+ export declare const Notation: {
3
+ readonly STANDARD: "standard";
4
+ readonly COMPACT: "compact";
5
+ };
6
+ type notationKeys = keyof typeof Notation;
7
+ export type Notation = (typeof Notation)[notationKeys];
2
8
  export interface NumberOptionsBasic extends FormatterOptions {
3
9
  minimumFractionDigits?: number;
4
10
  maximumFractionDigits?: number;
11
+ notation?: Notation;
5
12
  }
6
13
  export declare const Percent: {
7
14
  readonly STANDARD: "standard";
8
15
  readonly DECIMAL: "decimal";
9
16
  };
10
- export declare type Percent = typeof Percent[keyof typeof Percent] | boolean;
17
+ export type Percent = (typeof Percent)[keyof typeof Percent] | boolean;
11
18
  export interface NumberOptions extends NumberOptionsBasic {
12
19
  percent?: Percent;
13
20
  }
14
- export declare type NumberFormatPart = Intl.NumberFormatPart;
15
- export declare type Separators = {
21
+ export type NumberFormatPart = Intl.NumberFormatPart;
22
+ export type Separators = {
16
23
  decimal?: string;
17
24
  group: string;
18
25
  };
26
+ export {};
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Percent = void 0;
3
+ exports.Percent = exports.Notation = void 0;
4
+ exports.Notation = {
5
+ STANDARD: "standard",
6
+ COMPACT: "compact",
7
+ };
4
8
  exports.Percent = {
5
9
  STANDARD: "standard",
6
10
  DECIMAL: "decimal",
@@ -1 +1 @@
1
- {"version":3,"file":"Number.types.js","sourceRoot":"","sources":["../../src/numbers/Number.types.ts"],"names":[],"mappings":";;;AAOa,QAAA,OAAO,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACV,CAAC"}
1
+ {"version":3,"file":"Number.types.js","sourceRoot":"","sources":["../../src/numbers/Number.types.ts"],"names":[],"mappings":";;;AAEa,QAAA,QAAQ,GAAG;IACtB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACV,CAAC;AAUE,QAAA,OAAO,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACV,CAAC"}
@@ -442,6 +442,52 @@ const percentTrueAndStandard = [
442
442
  { locale: "zh-SG", value: "12345.678", expected: "12,345.678%" },
443
443
  ],
444
444
  },
445
+ {
446
+ description: "decimal that processor cannot divide by 100 without error",
447
+ tests: [
448
+ {
449
+ locale: "de-DE",
450
+ value: "4.02",
451
+ expected: "4,02\u00A0%",
452
+ },
453
+ { locale: "en", value: "4.02", expected: "4.02%" },
454
+ { locale: "en-AE", value: "4.02", expected: "4.02%" },
455
+ { locale: "en-AU", value: "4.02", expected: "4.02%" },
456
+ { locale: "en-CA", value: "4.02", expected: "4.02%" },
457
+ { locale: "en-GB", value: "4.02", expected: "4.02%" },
458
+ { locale: "en-SG", value: "4.02", expected: "4.02%" },
459
+ { locale: "en-US", value: "4.02", expected: "4.02%" },
460
+ {
461
+ locale: "es",
462
+ value: "4.02",
463
+ expected: "4,02\u00A0%",
464
+ },
465
+ {
466
+ locale: "es-ES",
467
+ value: "4.02",
468
+ expected: "4,02\u00A0%",
469
+ },
470
+ {
471
+ locale: "es-419",
472
+ value: "4.02",
473
+ expected: "4.02\u00A0%",
474
+ },
475
+ {
476
+ locale: "fr-FR",
477
+ value: "4.02",
478
+ expected: "4,02\u00A0%",
479
+ },
480
+ {
481
+ locale: "fr-CA",
482
+ value: "4.02",
483
+ expected: "4,02\u00A0%",
484
+ },
485
+ { locale: "is-IS", value: "4.02", expected: "4,02%" },
486
+ { locale: "ko", value: "4.02", expected: "4.02%" },
487
+ { locale: "tr-CY", value: "4.02", expected: "%4,02" },
488
+ { locale: "zh-SG", value: "4.02", expected: "4.02%" },
489
+ ],
490
+ },
445
491
  {
446
492
  description: "big number",
447
493
  tests: [
@@ -580,6 +626,17 @@ exports.formatNumberTestData = {
580
626
  { locale: "zh-SG", value: 12345670, expected: "12,345,670" },
581
627
  ],
582
628
  },
629
+ {
630
+ description: "compact",
631
+ config: { notation: "compact" },
632
+ tests: [
633
+ { locale: "en-US", value: 0, expected: "0" },
634
+ { locale: "en-US", value: 123, expected: "123" },
635
+ { locale: "en-US", value: 123.45, expected: "123" },
636
+ { locale: "en-US", value: 12345.67, expected: "12K" },
637
+ { locale: "en-US", value: 1234567890, expected: "1.2B" },
638
+ ],
639
+ },
583
640
  ],
584
641
  },
585
642
  {