@procore/globalization-toolkit 2.1.0 → 2.3.0

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.
package/FAQ.md CHANGED
@@ -1,2 +1,19 @@
1
- # How does GTK work with en-international and en-specialty-contractor?
1
+ # How does GTK work with en-international and en-specialty-contractor? (Or, more generally, Are Procore specific locales compatible with the GTK? How should I handle Locale validation before sending a locale to the GTK?)
2
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"
3
+
4
+ # What is the best path for implementation?
5
+ Please see the [Adoption flowchart](https://lucid.app/lucidchart/47c65380-9d87-409a-a15e-77c668e4c474/edit?invitationId=inv_abb5b5f8-3d6f-499f-920d-6dc6b7c9734c&page=0_0#) to determine the best implementation strategy.
6
+
7
+ # Why should I adopt the GTK? (problems/benefits, ease of adoption and maintenance)
8
+ Benefits are explained [here](https://docs.google.com/presentation/d/1FtB2DR5qroKgGcxxWsu5Ac9QHA01I7WM75FUeB67izE/edit#slide=id.g13dc53b71f1_1_247).
9
+
10
+ # Can I adopt some parts of the GTK and not others?
11
+ TODO
12
+
13
+ # What Core-React components are supported by GTK?
14
+
15
+ # How do I alias core-react to use two separate versions?
16
+
17
+ # How does the peer dependency work with GTK and Core-react?
18
+
19
+ # Will it create more work if I adopt number formatting now and sorting later? Should I just wait until everything is available so I don't have to do it twice?
package/README.md CHANGED
@@ -117,6 +117,7 @@ The CurrencyFormatter has 4 available functions:
117
117
  - `formatCurrencyToParts(value: number)`
118
118
  - `parseCurrency(value: string)`
119
119
  - `getCurrencySeparators()`
120
+ - `getSupportedCurrencies()`
120
121
 
121
122
  The [CurrencyOptions](https://procore.github.io/globalization-toolkit/interfaces/CurrencyOptions.html) are summarized below:
122
123
  - `currencyIsoCode`: string ([acceptable ISO codes](https://github.com/formatjs/formatjs/blob/main/packages/intl-enumerator/src/currencies.generated.ts))
@@ -207,6 +208,24 @@ const formatter = new CurrencyFormatter(currencyOptions);
207
208
 
208
209
  console.log(formatter.getCurrencySeparators()) // expected outcome: { decimal: ",", group: "." }
209
210
  ```
211
+
212
+ [getSupportedCurrencies](https://procore.github.io/globalization-toolkit/classes/CurrencyFormatter.html#getSupportedCurrencies)
213
+ ```ts
214
+ const currencyOptions = { locale: "es-MX", currencyIsoCode: MXN" }
215
+ const formatter = new CurrencyFormatter(currencyOption)
216
+
217
+ console.log(formatter.getSupportedCurrencies())
218
+ /** expected outcome
219
+ * [
220
+ * "AED",
221
+ * "AFN",
222
+ * "ALL",
223
+ * ...
224
+ * ...
225
+ * "ZWL"
226
+ * ]
227
+ */
228
+ ```
210
229
  ### CurrencyFormatter Functions
211
230
  The functions used on the CurrencyFormatter class are also available as stand alone functions. Read more information about each function in the GTK Documentation.
212
231
  - [formatCurrency](https://procore.github.io/globalization-toolkit/functions/formatCurrency.html)
package/dependabot.yml ADDED
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "monthly"
7
+ versioning-strategy: increase
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { NumberFormatter, formatNumber, formatNumberToParts, parseNumber, getNumberSeparators, } from "./numbers/NumberFormatter";
2
- export { CurrencyFormatter, formatCurrency, formatCurrencyToParts, parseCurrency, getCurrencySeparators, } from "./numbers/CurrencyFormatter";
2
+ export { CurrencyFormatter, formatCurrency, formatCurrencyToParts, parseCurrency, getCurrencySeparators, getSupportedCurrencies, } from "./numbers/CurrencyFormatter";
3
3
  export { DateTimeFormatter, formatDateTime, formatDateTimeToParts, getStartDayOfTheWeek, getDatePartsWithPlaceholders, getDatePlaceholder, } from "./dateTimes/DateTimeFormatter";
4
4
  export type { Percent, NumberOptions, NumberFormatPart, Separators, } from "./numbers/Number.types";
5
5
  export type { CurrencyDisplay, CurrencySign, CurrencyOptions, } from "./numbers/Currency.types";
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
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;
12
+ exports.getDatePlaceholder = exports.getDatePartsWithPlaceholders = exports.getStartDayOfTheWeek = exports.formatDateTimeToParts = exports.formatDateTime = exports.DateTimeFormatter = exports.getSupportedCurrencies = exports.getCurrencySeparators = exports.parseCurrency = exports.formatCurrencyToParts = exports.formatCurrency = exports.CurrencyFormatter = exports.getNumberSeparators = exports.parseNumber = exports.formatNumberToParts = exports.formatNumber = exports.NumberFormatter = void 0;
13
13
  var NumberFormatter_1 = require("./numbers/NumberFormatter");
14
14
  Object.defineProperty(exports, "NumberFormatter", { enumerable: true, get: function () { return NumberFormatter_1.NumberFormatter; } });
15
15
  Object.defineProperty(exports, "formatNumber", { enumerable: true, get: function () { return NumberFormatter_1.formatNumber; } });
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: functi
22
22
  Object.defineProperty(exports, "formatCurrencyToParts", { enumerable: true, get: function () { return CurrencyFormatter_1.formatCurrencyToParts; } });
23
23
  Object.defineProperty(exports, "parseCurrency", { enumerable: true, get: function () { return CurrencyFormatter_1.parseCurrency; } });
24
24
  Object.defineProperty(exports, "getCurrencySeparators", { enumerable: true, get: function () { return CurrencyFormatter_1.getCurrencySeparators; } });
25
+ Object.defineProperty(exports, "getSupportedCurrencies", { enumerable: true, get: function () { return CurrencyFormatter_1.getSupportedCurrencies; } });
25
26
  var DateTimeFormatter_1 = require("./dateTimes/DateTimeFormatter");
26
27
  Object.defineProperty(exports, "DateTimeFormatter", { enumerable: true, get: function () { return DateTimeFormatter_1.DateTimeFormatter; } });
27
28
  Object.defineProperty(exports, "formatDateTime", { enumerable: true, get: function () { return DateTimeFormatter_1.formatDateTime; } });
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;AAwCpB,OAAO,CAAC,YAAY,GAAG,GAA2B,EAAE;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAA,CAAC"}
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,iEAOqC;AANnC,sHAAA,iBAAiB,OAAA;AACjB,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,kHAAA,aAAa,OAAA;AACb,0HAAA,qBAAqB,OAAA;AACrB,2HAAA,sBAAsB,OAAA;AAExB,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"}
@@ -8,9 +8,11 @@ export declare class CurrencyFormatter {
8
8
  parseCurrency(value: string): number;
9
9
  getCurrencySeparators(): Separators;
10
10
  getCurrencyPlaceholders(): string;
11
+ getSupportedCurrencies(): string[];
11
12
  }
12
13
  export declare function formatCurrency(value: number | string, currencyOptions: CurrencyOptions): string;
13
14
  export declare function formatCurrencyToParts(value: number, currencyOptions: CurrencyOptions): NumberFormatPart[];
14
15
  export declare function parseCurrency(value: string, currencyOptions: CurrencyOptions): number;
15
16
  export declare function getCurrencySeparators(currencyOptions: CurrencyOptions): Separators;
16
17
  export declare function getCurrencyPlaceholders(currencyOptions: CurrencyOptions): string;
18
+ export declare function getSupportedCurrencies(currencyOptions: CurrencyOptions): string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrencyPlaceholders = exports.getCurrencySeparators = exports.parseCurrency = exports.formatCurrencyToParts = exports.formatCurrency = exports.CurrencyFormatter = void 0;
3
+ exports.getSupportedCurrencies = 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");
@@ -55,6 +55,9 @@ class CurrencyFormatter {
55
55
  const negative = formattedNegativeNumber.replace(/[1-9]/g, "#");
56
56
  return `${positive};${negative}`;
57
57
  }
58
+ getSupportedCurrencies() {
59
+ return (0, CurrencyUtils_1.supportedCurrencies)();
60
+ }
58
61
  }
59
62
  exports.CurrencyFormatter = CurrencyFormatter;
60
63
  function formatCurrency(value, currencyOptions) {
@@ -82,4 +85,9 @@ function getCurrencyPlaceholders(currencyOptions) {
82
85
  return formatter.getCurrencyPlaceholders();
83
86
  }
84
87
  exports.getCurrencyPlaceholders = getCurrencyPlaceholders;
88
+ function getSupportedCurrencies(currencyOptions) {
89
+ const formatter = new CurrencyFormatter(currencyOptions);
90
+ return formatter.getSupportedCurrencies();
91
+ }
92
+ exports.getSupportedCurrencies = getSupportedCurrencies;
85
93
  //# 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,qBAAqB,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,MAAA,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAA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formatjs/intl-locale/polyfill";
3
4
  import "@formatjs/intl-pluralrules/polyfill";
@@ -28,3 +29,4 @@ export declare function transformOptions(options: CurrencyOptions): Intl.NumberF
28
29
  export declare function transformCurrencyOptions(options: CurrencyOptions): Intl.NumberFormatOptions;
29
30
  export declare function validateOptions(options: CurrencyOptions): CurrencyOptions;
30
31
  export declare function validateCurrencyOptions(currencyOptions: CurrencyOptions): CurrencyOptions;
32
+ export declare function supportedCurrencies(): string[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateCurrencyOptions = exports.validateOptions = exports.transformCurrencyOptions = exports.transformOptions = exports.getCurrencyFormatter = void 0;
3
+ exports.supportedCurrencies = exports.validateCurrencyOptions = exports.validateOptions = exports.transformCurrencyOptions = exports.transformOptions = exports.getCurrencyFormatter = void 0;
4
+ require("@formatjs/intl-enumerator/polyfill");
4
5
  require("@formatjs/intl-getcanonicallocales/polyfill");
5
6
  require("@formatjs/intl-locale/polyfill");
6
7
  require("@formatjs/intl-pluralrules/polyfill");
@@ -26,6 +27,7 @@ require("@formatjs/intl-numberformat/locale-data/ja");
26
27
  require("@formatjs/intl-numberformat/locale-data/ko");
27
28
  require("@formatjs/intl-numberformat/locale-data/th");
28
29
  const FormatterUtils_1 = require("../FormatterUtils");
30
+ const SupportedCurrencies_1 = require("./SupportedCurrencies");
29
31
  const NumberUtils_1 = require("./NumberUtils");
30
32
  function getCurrencyFormatter(options) {
31
33
  exports.validateOptions(options);
@@ -64,4 +66,9 @@ function validateCurrencyOptions(currencyOptions) {
64
66
  throw new Error(errorMessage);
65
67
  }
66
68
  exports.validateCurrencyOptions = validateCurrencyOptions;
69
+ function supportedCurrencies() {
70
+ const currencyCodes = Intl.supportedValuesOf("currency");
71
+ return currencyCodes.filter((currency) => SupportedCurrencies_1.SupportedCurrencies.includes(currency));
72
+ }
73
+ exports.supportedCurrencies = supportedCurrencies;
67
74
  //# sourceMappingURL=CurrencyUtils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AAC;IAC5B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAbD,0DAaC;AAED,SAAgB,mBAAmB;IACjC,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACzD,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CACvC,yCAAmB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACvC,CAAC;AACJ,CAAC;AALD,kDAKC"}
@@ -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: [