@procore/globalization-toolkit 3.2.0 → 3.4.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.
Files changed (117) hide show
  1. package/.tool-versions +1 -1
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +36 -1
  4. package/dist/Formatter.types.d.ts +12 -2
  5. package/dist/Formatter.types.js +21 -0
  6. package/dist/Formatter.types.js.map +1 -1
  7. package/dist/FormatterUtils.d.ts +2 -2
  8. package/dist/FormatterUtils.js +1 -1
  9. package/dist/FormatterUtils.js.map +1 -1
  10. package/dist/dateTimes/DateTime.types.d.ts +12 -0
  11. package/dist/dateTimes/DateTime.types.js +11 -1
  12. package/dist/dateTimes/DateTime.types.js.map +1 -1
  13. package/dist/dateTimes/DateTimeFormatter.d.ts +10 -5
  14. package/dist/dateTimes/DateTimeFormatter.js +61 -2
  15. package/dist/dateTimes/DateTimeFormatter.js.map +1 -1
  16. package/dist/getFallbackLocaleList/GetFallbackLocaleList.d.ts +3 -0
  17. package/dist/getFallbackLocaleList/GetFallbackLocaleList.js +20 -0
  18. package/dist/getFallbackLocaleList/GetFallbackLocaleList.js.map +1 -0
  19. package/dist/getOverrideLocale/GetOverrideLocale.d.ts +3 -3
  20. package/dist/getOverrideLocale/GetOverrideLocale.js +6 -37
  21. package/dist/getOverrideLocale/GetOverrideLocale.js.map +1 -1
  22. package/dist/getTranslationsFromLocale/GetTranslationsFromLocale.d.ts +6 -0
  23. package/dist/getTranslationsFromLocale/GetTranslationsFromLocale.js +27 -0
  24. package/dist/getTranslationsFromLocale/GetTranslationsFromLocale.js.map +1 -0
  25. package/dist/index.d.ts +6 -4
  26. package/dist/index.js +8 -14
  27. package/dist/index.js.map +1 -1
  28. package/dist/numbers/NumberFormatter.d.ts +2 -2
  29. package/dist/numbers/NumberFormatter.js.map +1 -1
  30. package/dist/numbers/NumberFormatter.test.constants.js +399 -25
  31. package/dist/numbers/NumberFormatter.test.constants.js.map +1 -1
  32. package/dist/numbers/NumberUtils.js +7 -3
  33. package/dist/numbers/NumberUtils.js.map +1 -1
  34. package/dist/test/TestBuilder.d.ts +2 -3
  35. package/dist/test/TestBuilder.js.map +1 -1
  36. package/dist/tsconfig.build.tsbuildinfo +1 -1
  37. package/docs/assets/icons.js +18 -0
  38. package/docs/assets/icons.svg +1 -0
  39. package/docs/assets/main.js +5 -4
  40. package/docs/assets/navigation.js +1 -1
  41. package/docs/assets/search.js +1 -1
  42. package/docs/assets/style.css +110 -45
  43. package/docs/classes/CurrencyFormatter.html +20 -20
  44. package/docs/classes/DateTimeFormatter.html +17 -13
  45. package/docs/classes/NumberFormatter.html +17 -17
  46. package/docs/functions/formatCurrency.html +4 -4
  47. package/docs/functions/formatCurrencyToParts.html +4 -4
  48. package/docs/functions/formatDateTime.html +4 -4
  49. package/docs/functions/formatDateTimeToLocalISOString.html +5 -0
  50. package/docs/functions/formatDateTimeToParts.html +4 -4
  51. package/docs/functions/formatNumber.html +4 -4
  52. package/docs/functions/formatNumberToParts.html +4 -4
  53. package/docs/functions/getCurrencySeparators.html +3 -3
  54. package/docs/functions/getDatePartsWithPlaceholders.html +4 -4
  55. package/docs/functions/getDatePlaceholder.html +4 -4
  56. package/docs/functions/getFallbackLocaleList.html +4 -0
  57. package/docs/functions/getNumberSeparators.html +3 -3
  58. package/docs/functions/getOverrideLocale.html +6 -0
  59. package/docs/functions/getStartDayOfTheWeek.html +3 -3
  60. package/docs/functions/getSupportedCurrencies.html +3 -3
  61. package/docs/functions/parseCurrency.html +4 -4
  62. package/docs/functions/parseNumber.html +4 -4
  63. package/docs/index.html +203 -128
  64. package/docs/interfaces/CurrencyOptions.html +8 -8
  65. package/docs/interfaces/DateTimeOptionsBasic.html +4 -4
  66. package/docs/interfaces/DateTimeOptionsComponentsAll.html +14 -14
  67. package/docs/interfaces/DateTimeOptionsComponentsHourMinute.html +14 -14
  68. package/docs/interfaces/DateTimeOptionsComponentsHourMinuteSecond.html +14 -14
  69. package/docs/interfaces/DateTimeOptionsComponentsMonthDay.html +14 -14
  70. package/docs/interfaces/DateTimeOptionsComponentsWeekdayYearMonthDay.html +14 -14
  71. package/docs/interfaces/DateTimeOptionsComponentsYearMonth.html +14 -14
  72. package/docs/interfaces/DateTimeOptionsComponentsYearMonthDay.html +14 -14
  73. package/docs/interfaces/DateTimeOptionsStyle.html +14 -14
  74. package/docs/interfaces/NumberOptions.html +6 -6
  75. package/docs/modules.html +69 -66
  76. package/docs/types/CurrencyDisplay.html +1 -1
  77. package/docs/types/CurrencySign.html +1 -1
  78. package/docs/types/DateLabelOptions.html +1 -1
  79. package/docs/types/DateStyle.html +1 -1
  80. package/docs/types/DateTimeFormatPart.html +1 -1
  81. package/docs/types/DateTimeOptions.html +1 -1
  82. package/docs/types/DateTimeStyle.html +1 -1
  83. package/docs/types/Day.html +1 -1
  84. package/docs/types/FormatterOptions.html +1 -1
  85. package/docs/types/Hour.html +1 -1
  86. package/docs/types/Locale.html +1 -1
  87. package/docs/types/Minute.html +1 -1
  88. package/docs/types/Month.html +1 -1
  89. package/docs/types/NumberFormatPart.html +1 -1
  90. package/docs/types/NumericTwoDigit.html +1 -1
  91. package/docs/types/Percent.html +1 -1
  92. package/docs/types/Second.html +1 -1
  93. package/docs/types/Separators.html +1 -1
  94. package/docs/types/TimeStyle.html +1 -1
  95. package/docs/types/TimeZoneName.html +1 -1
  96. package/docs/types/Weekday.html +1 -1
  97. package/docs/types/Year.html +1 -1
  98. package/docs/variables/CurrencyDisplay-1.html +1 -1
  99. package/docs/variables/CurrencySign-1.html +1 -1
  100. package/docs/variables/DateStyle-1.html +1 -1
  101. package/docs/variables/DateTimeStyle-1.html +1 -1
  102. package/docs/variables/Day-1.html +1 -1
  103. package/docs/variables/Hour-1.html +1 -1
  104. package/docs/variables/Minute-1.html +1 -1
  105. package/docs/variables/Month-1.html +1 -1
  106. package/docs/variables/NumericTwoDigit-1.html +1 -1
  107. package/docs/variables/Percent-1.html +1 -1
  108. package/docs/variables/Second-1.html +1 -1
  109. package/docs/variables/TimeStyle-1.html +1 -1
  110. package/docs/variables/TimeZoneName-1.html +1 -1
  111. package/docs/variables/Weekday-1.html +1 -1
  112. package/docs/variables/Year-1.html +1 -1
  113. package/package.json +4 -4
  114. package/sonar-project.properties +1 -1
  115. package/dist/getOverrideLocale/GetOverrideLocale.types.d.ts +0 -1
  116. package/dist/getOverrideLocale/GetOverrideLocale.types.js +0 -3
  117. package/dist/getOverrideLocale/GetOverrideLocale.types.js.map +0 -1
package/.tool-versions CHANGED
@@ -1 +1 @@
1
- nodejs 18.18.2
1
+ nodejs 22.8.0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @procore/globalization-toolkit
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d4e56dd: added relative time formatter
8
+ - 93f1b25: - Upgraded node version to 22.8.0
9
+ - Exported OVERWRITE_LOCALE_MAP, FALLBACK_LOCALE_MAP
10
+ - Introduced Two new Lists and their corresponding type :
11
+ - TMS_SUPPORTED_LOCALES includes all languages we support their translations. Its corresponding type is TmsSupportedLocale.
12
+ - ALL_LOCALES includes all languages we have in the system in general. Its corresponding type is AllLocale.
13
+ - 62f169c: Added polish support
14
+ - 086474f: Add locale to translation mapper
15
+
16
+ ## 3.3.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 6f988d5: Adds getTranslationsFromLocale functionality so client can just send the module import and package keeps the logic inside
21
+
3
22
  ## 3.2.0
4
23
 
5
24
  ### Minor Changes
package/README.md CHANGED
@@ -382,6 +382,23 @@ const dateTimeOptions = { locale: "en-US", timeZone: "UTC" };
382
382
 
383
383
  console.log(formatDateTime(value, dateTimeOptions)) // expected output: 11/5/1955
384
384
  ```
385
+ ### FormatRelativeTime
386
+ The formatRelativeTime function allows you to format a time difference as a localized, human-readable string, based on the provided locale and relative time options. This is useful for displaying time differences like "2 hours ago" or "in 3 days" in a format that is appropriate for the user's language and region.
387
+
388
+ The example below shows usage of the stand alone function : `formatRelativeTime()`.
389
+ ```ts
390
+ import { formatRelativeTime} from '@procore/globalization-toolkit';
391
+
392
+ import formatRelativeTime from
393
+ const result1 = formatRelativeTime('en-US', { value: 1, unit: 'hour' });
394
+ // Output: "in 1 hour"
395
+
396
+ const result2 = formatRelativeTime('es-ES', { value: -1, unit: 'hour' });
397
+ // Output: "hace 1 hora"
398
+
399
+ const result3 = formatRelativeTime('en-GB', { value: new Date(Date.now() - 3600 * 1000) });
400
+ // Output: "1 hour ago"
401
+ ```
385
402
  ### GetOverrideLocale Function
386
403
  The getOverrideLocale function returns a mapped locale based on predefined settings.
387
404
  If the environment locale isn't directly supported, it provides a fallback from the predefined mappings.
@@ -436,6 +453,24 @@ const locale4 = getOverrideLocale('unknown');
436
453
  console.log(locale4); // Output: ['en']
437
454
 
438
455
  ```
456
+
457
+ ### `getTranslationsFromLocale` Function
458
+
459
+ The getTranslationsFromLocale function is a utility designed to load and merge translations for a given locale and its fallback locales. It is part of the @procore/globalization-toolkit and provides a robust way to handle multiple languages in your application.
460
+
461
+ ```ts
462
+ import { getTranslationsFromLocale } from "@procore/globalization-toolkit"
463
+
464
+ // Example locale loader function
465
+ async function loadLocale(lang: string): Promise<{ default: Translations }> {
466
+ return import(`../locales/${lang}.json`)
467
+ }
468
+
469
+ // Example usage of getTranslationsFromLocale
470
+ const envLocale = "en"
471
+ const translations = await getTranslationsFromLocale(envLocale, loadLocale)
472
+ ```
473
+
439
474
  ## Polyfills
440
475
  The GTK implementation relies heavily on [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) functionality. This is generally well-supported by browsers, but depending on the browser versions you intend to support and GTK features you plan to use, it may require polyfills. In particular, consumers have seen issues with Safari versions <14.1. If you intend to support older browser versions, we recommend using the [Format.JS polyfills](https://formatjs.io/docs/polyfills), of which `NumberFormat`, `PluralRules`, `Locale`, `GetCanonicalLocales`, and `supportedValuesOf` are the ones relevant to GTK. Please reach out if you have questions.
441
476
  ____
@@ -523,4 +558,4 @@ Procore - building the software that builds the world.
523
558
  Learn more about the #1 most widely used construction management software at [procore.com](https://www.procore.com/)
524
559
 
525
560
 
526
- [changesets]: https://github.com/changesets/changesets/
561
+ [changesets]: https://github.com/changesets/changesets/
@@ -1,4 +1,14 @@
1
- export type Locale = string;
1
+ export type DatesAndNumbersLocale = string;
2
2
  export type FormatterOptions = {
3
- locale: Locale;
3
+ locale: string;
4
4
  };
5
+ export declare const TMS_SUPPORTED_LOCALES: readonly ["de-DE", "en-AU", "en-CA", "en-GB", "en", "es-ES", "es", "fr-CA", "fr-FR", "is-IS", "ja-JP", "pl-PL", "pseudo", "pt-BR", "th-TH", "zh-SG"];
6
+ export declare const UNSUPPORTED_LOCALES: readonly ["en-AE", "en-SG"];
7
+ export declare const ALL_LOCALES: ("de-DE" | "en-AU" | "en-CA" | "en-GB" | "en" | "es-ES" | "es" | "fr-CA" | "fr-FR" | "is-IS" | "ja-JP" | "pl-PL" | "pseudo" | "pt-BR" | "th-TH" | "zh-SG" | "en-AE" | "en-SG")[];
8
+ export type TmsSupportedLocale = (typeof TMS_SUPPORTED_LOCALES)[number];
9
+ export type AllLocale = TmsSupportedLocale | (typeof UNSUPPORTED_LOCALES)[number];
10
+ export type MapLocalesToTranslations<Locales extends string = TmsSupportedLocale, TranslationType = DeepNestedRecords> = Record<Locales, TranslationType>;
11
+ type DeepNestedRecords = {
12
+ [K: string]: string | DeepNestedRecords;
13
+ };
14
+ export {};
@@ -1,3 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALL_LOCALES = exports.UNSUPPORTED_LOCALES = exports.TMS_SUPPORTED_LOCALES = void 0;
4
+ exports.TMS_SUPPORTED_LOCALES = [
5
+ "de-DE",
6
+ "en-AU",
7
+ "en-CA",
8
+ "en-GB",
9
+ "en",
10
+ "es-ES",
11
+ "es",
12
+ "fr-CA",
13
+ "fr-FR",
14
+ "is-IS",
15
+ "ja-JP",
16
+ "pl-PL",
17
+ "pseudo",
18
+ "pt-BR",
19
+ "th-TH",
20
+ "zh-SG",
21
+ ];
22
+ exports.UNSUPPORTED_LOCALES = ["en-AE", "en-SG"];
23
+ exports.ALL_LOCALES = [...exports.TMS_SUPPORTED_LOCALES, ...exports.UNSUPPORTED_LOCALES];
3
24
  //# sourceMappingURL=Formatter.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Formatter.types.js","sourceRoot":"","sources":["../src/Formatter.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"Formatter.types.js","sourceRoot":"","sources":["../src/Formatter.types.ts"],"names":[],"mappings":";;;AAWa,QAAA,qBAAqB,GAAG;IACnC,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;CACC,CAAC;AAEE,QAAA,mBAAmB,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAC;AAElD,QAAA,WAAW,GAAG,CAAC,GAAG,6BAAqB,EAAE,GAAG,2BAAmB,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- import { Locale } from "./Formatter.types";
2
- export declare function validateLocale(locale: Locale): Locale;
1
+ import type { FormatterOptions } from "./Formatter.types";
2
+ export declare function validateLocale(locale: string): FormatterOptions["locale"];
3
3
  export declare function escapeRegEx(value: string): string;
@@ -6,7 +6,7 @@ function validateLocale(locale) {
6
6
  new Intl.NumberFormat(locale);
7
7
  return locale;
8
8
  }
9
- catch (error) {
9
+ catch (_a) {
10
10
  const errorMessage = `@procore/globalization-toolkit Intl.NumberFormat error for locale ${locale}. Please use a supported locale.`;
11
11
  console.error(errorMessage);
12
12
  throw new Error(errorMessage);
@@ -1 +1 @@
1
- {"version":3,"file":"FormatterUtils.js","sourceRoot":"","sources":["../src/FormatterUtils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,cAAc,CAAC,MAAc;IAC3C,IAAI;QACF,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC;KACf;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,qEAAqE,MAAM,kCAAkC,CAAC;QACnI,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KAC/B;AACH,CAAC;AATD,wCASC;AAED,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAFD,kCAEC"}
1
+ {"version":3,"file":"FormatterUtils.js","sourceRoot":"","sources":["../src/FormatterUtils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,cAAc,CAAC,MAAc;IAC3C,IAAI;QACF,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC;KACf;IAAC,WAAM;QACN,MAAM,YAAY,GAAG,qEAAqE,MAAM,kCAAkC,CAAC;QACnI,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KAC/B;AACH,CAAC;AATD,wCASC;AAED,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAFD,kCAEC"}
@@ -176,3 +176,15 @@ export interface DateTimeOptionsComponentsHourMinute extends DateTimeOptionsBasi
176
176
  }
177
177
  export type DateTimeOptions = DateTimeOptionsStyle | DateTimeOptionsComponentsAll | DateTimeOptionsComponentsWeekdayYearMonthDay | DateTimeOptionsComponentsYearMonthDay | DateTimeOptionsComponentsYearMonth | DateTimeOptionsComponentsMonthDay | DateTimeOptionsComponentsHourMinuteSecond | DateTimeOptionsComponentsHourMinute;
178
178
  export type DateTimeFormatPart = Intl.DateTimeFormatPart;
179
+ export declare const supportedUnits: readonly ["second", "minute", "hour", "day", "month", "year", "weeks", "quarter"];
180
+ type TimeUnit = (typeof supportedUnits)[number];
181
+ type RelativeNumberTimeOptions = {
182
+ value: number;
183
+ unit: TimeUnit;
184
+ };
185
+ type RelativeDateTimeOptions = {
186
+ value: Date;
187
+ unit?: TimeUnit;
188
+ };
189
+ export type RelativeTimeOptions = RelativeNumberTimeOptions | RelativeDateTimeOptions;
190
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Second = exports.Minute = exports.Hour = exports.Day = exports.Month = exports.Year = exports.Weekday = exports.TimeStyle = exports.DateStyle = exports.NumericTwoDigit = exports.TimeZoneName = exports.DateTimeStyle = void 0;
3
+ exports.supportedUnits = exports.Second = exports.Minute = exports.Hour = exports.Day = exports.Month = exports.Year = exports.Weekday = exports.TimeStyle = exports.DateStyle = exports.NumericTwoDigit = exports.TimeZoneName = exports.DateTimeStyle = void 0;
4
4
  exports.DateTimeStyle = {
5
5
  FULL: "full",
6
6
  LONG: "long",
@@ -34,4 +34,14 @@ exports.Day = exports.NumericTwoDigit;
34
34
  exports.Hour = exports.NumericTwoDigit;
35
35
  exports.Minute = exports.NumericTwoDigit;
36
36
  exports.Second = exports.NumericTwoDigit;
37
+ exports.supportedUnits = [
38
+ "second",
39
+ "minute",
40
+ "hour",
41
+ "day",
42
+ "month",
43
+ "year",
44
+ "weeks",
45
+ "quarter",
46
+ ];
37
47
  //# sourceMappingURL=DateTime.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.types.js","sourceRoot":"","sources":["../../src/dateTimes/DateTime.types.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACN,CAAC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E,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAGE,QAAA,IAAI,GAAG,uBAAe,CAAC;AAGvB,QAAA,KAAK,GAAG;IACnB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACR,CAAC;AAGE,QAAA,GAAG,GAAG,uBAAe,CAAC;AAGtB,QAAA,IAAI,GAAG,uBAAe,CAAC;AAGvB,QAAA,MAAM,GAAG,uBAAe,CAAC;AAGzB,QAAA,MAAM,GAAG,uBAAe,CAAC;AAuIzB,QAAA,cAAc,GAAG;IAC5B,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,SAAS;CACD,CAAC"}
@@ -1,5 +1,6 @@
1
- import { Locale } from "../Formatter.types";
2
- import { DateLabelOptions, DateTimeFormatPart, DateTimeOptions } from "./DateTime.types";
1
+ import { FormatterOptions } from "../Formatter.types";
2
+ import { DateLabelOptions, DateTimeFormatPart, DateTimeOptions, RelativeTimeOptions } from "./DateTime.types";
3
+ type LocaleType = FormatterOptions["locale"];
3
4
  export declare class DateTimeFormatter {
4
5
  formatter: Intl.DateTimeFormat;
5
6
  constructor(dateTimeOptions: DateTimeOptions);
@@ -7,10 +8,14 @@ export declare class DateTimeFormatter {
7
8
  formatDateTimeToParts(value: Date | number): DateTimeFormatPart[];
8
9
  formatDateTimeToLocalISOString(value: Date | number): string;
9
10
  getStartDayOfTheWeek(): number;
11
+ formatTimeDifference(rtf: Intl.RelativeTimeFormat, difference: number): string;
12
+ formatRelativeTime(relativeTimeOptions: RelativeTimeOptions): string;
10
13
  }
11
14
  export declare function formatDateTime(value: Date | number, dateTimeOptions: DateTimeOptions): string;
12
15
  export declare function formatDateTimeToParts(value: Date | number, dateTimeOptions: DateTimeOptions): DateTimeFormatPart[];
13
16
  export declare function formatDateTimeToLocalISOString(value: Date | number, dateTimeOptions: DateTimeOptions): string;
14
- export declare function getStartDayOfTheWeek(locale: Locale): number;
15
- export declare function getDatePartsWithPlaceholders(locale: Locale, dateLabels: DateLabelOptions): DateTimeFormatPart[];
16
- export declare function getDatePlaceholder(locale: Locale, dateLabels: DateLabelOptions): string;
17
+ export declare function getStartDayOfTheWeek(locale: LocaleType): number;
18
+ export declare function getDatePartsWithPlaceholders(locale: LocaleType, dateLabels: DateLabelOptions): DateTimeFormatPart[];
19
+ export declare function getDatePlaceholder(locale: LocaleType, dateLabels: DateLabelOptions): string;
20
+ export declare function formatRelativeTime(locale: LocaleType, relativeTimeOptions: RelativeTimeOptions): string;
21
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDatePlaceholder = exports.getDatePartsWithPlaceholders = exports.getStartDayOfTheWeek = exports.formatDateTimeToLocalISOString = exports.formatDateTimeToParts = exports.formatDateTime = exports.DateTimeFormatter = void 0;
3
+ exports.formatRelativeTime = exports.getDatePlaceholder = exports.getDatePartsWithPlaceholders = exports.getStartDayOfTheWeek = exports.formatDateTimeToLocalISOString = exports.formatDateTimeToParts = exports.formatDateTime = exports.DateTimeFormatter = void 0;
4
4
  const weekstart_1 = require("weekstart");
5
5
  const DateTime_types_1 = require("./DateTime.types");
6
6
  const DateTimeUtils_1 = require("./DateTimeUtils");
@@ -33,6 +33,60 @@ class DateTimeFormatter {
33
33
  getStartDayOfTheWeek() {
34
34
  return (0, weekstart_1.getWeekStartByLocale)(this.formatter.resolvedOptions().locale);
35
35
  }
36
+ formatTimeDifference(rtf, difference) {
37
+ const isFuture = difference >= 0 ? 1 : -1;
38
+ difference = Math.abs(difference);
39
+ const seconds = difference;
40
+ if (seconds < 60) {
41
+ return rtf.format(isFuture * seconds, "second");
42
+ }
43
+ const minutes = Math.round(seconds / 60);
44
+ if (minutes < 60) {
45
+ return rtf.format(minutes * isFuture, "minute");
46
+ }
47
+ const hours = Math.round(minutes / 60);
48
+ if (hours < 24) {
49
+ return rtf.format(hours * isFuture, "hour");
50
+ }
51
+ const days = Math.round(hours / 24);
52
+ if (days < 7) {
53
+ return rtf.format(days * isFuture, "day");
54
+ }
55
+ const weeks = Math.round(days / 7);
56
+ if (weeks < 4.35) {
57
+ return rtf.format(weeks * isFuture, "week");
58
+ }
59
+ const months = Math.round(weeks / 4.35);
60
+ const quarters = Math.round(months / 4);
61
+ if (months < 12) {
62
+ if (quarters < 4) {
63
+ return rtf.format(quarters * isFuture, "quarter");
64
+ }
65
+ return rtf.format(months * isFuture, "month");
66
+ }
67
+ const years = Math.round(months / 12);
68
+ return rtf.format(years * isFuture, "year");
69
+ }
70
+ formatRelativeTime(relativeTimeOptions) {
71
+ const locale = this.formatter.resolvedOptions().locale;
72
+ const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
73
+ if (!relativeTimeOptions.value && relativeTimeOptions.value !== 0) {
74
+ throw new Error("Value is required");
75
+ }
76
+ if (typeof relativeTimeOptions.value === "number") {
77
+ if (relativeTimeOptions.unit === undefined) {
78
+ throw new Error("Unit is undefined.");
79
+ }
80
+ return rtf.format(relativeTimeOptions.value, relativeTimeOptions.unit);
81
+ }
82
+ const now = new Date();
83
+ const date = new Date(relativeTimeOptions.value);
84
+ if (isNaN(date.getTime())) {
85
+ throw new Error("Invalid date");
86
+ }
87
+ const difference = (relativeTimeOptions.value.getTime() - now.getTime()) / 1000;
88
+ return this.formatTimeDifference(rtf, difference);
89
+ }
36
90
  }
37
91
  exports.DateTimeFormatter = DateTimeFormatter;
38
92
  function formatDateTime(value, dateTimeOptions) {
@@ -57,7 +111,7 @@ function getStartDayOfTheWeek(locale) {
57
111
  exports.getStartDayOfTheWeek = getStartDayOfTheWeek;
58
112
  function getDatePartsWithPlaceholders(locale, dateLabels) {
59
113
  const dateTimeOptions = {
60
- locale: locale,
114
+ locale,
61
115
  year: DateTime_types_1.Year.NUMERIC,
62
116
  month: DateTime_types_1.Month.NUMERIC,
63
117
  day: DateTime_types_1.Day.NUMERIC,
@@ -85,4 +139,9 @@ function getDatePlaceholder(locale, dateLabels) {
85
139
  return parts.reduce((acc, curr) => acc + curr.value, "");
86
140
  }
87
141
  exports.getDatePlaceholder = getDatePlaceholder;
142
+ function formatRelativeTime(locale, relativeTimeOptions) {
143
+ const formatter = new DateTimeFormatter({ locale });
144
+ return formatter.formatRelativeTime(relativeTimeOptions);
145
+ }
146
+ exports.formatRelativeTime = formatRelativeTime;
88
147
  //# sourceMappingURL=DateTimeFormatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeFormatter.js","sourceRoot":"","sources":["../../src/dateTimes/DateTimeFormatter.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAEjD,qDAQ0B;AAC1B,mDAAuD;AAEvD,MAAa,iBAAiB;IAM5B,YAAY,eAAgC;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAA,oCAAoB,EAAC,eAAe,CAAC,CAAC;IACzD,CAAC;IAOD,cAAc,CAAC,KAAoB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAOD,qBAAqB,CAAC,KAAoB;QACxC,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAOD,8BAA8B,CAAC,KAAoB;;QACjD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;QAEzD,MAAM,SAAS,GAAG,IAAA,oCAAoB,EAAC;YACrC,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,QAAQ,EAAE,eAAe,CAAC,QAAQ;YAClC,IAAI,EAAE,qBAAI,CAAC,OAAO;YAClB,KAAK,EAAE,sBAAK,CAAC,SAAS;YACtB,GAAG,EAAE,oBAAG,CAAC,SAAS;SACnB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC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B,CAChC,MAAkB,EAClB,mBAAwC;IAExC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,OAAO,SAAS,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;AAC3D,CAAC;AAND,gDAMC"}
@@ -0,0 +1,3 @@
1
+ import { TmsSupportedLocale } from "../Formatter.types";
2
+ export declare const FALLBACK_LOCALE_MAP: Record<string, TmsSupportedLocale>;
3
+ export declare function getFallbackLocaleList(envLocale?: string): TmsSupportedLocale[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFallbackLocaleList = exports.FALLBACK_LOCALE_MAP = void 0;
4
+ const GetOverrideLocale_1 = require("../getOverrideLocale/GetOverrideLocale");
5
+ exports.FALLBACK_LOCALE_MAP = {
6
+ "es-ES": "es",
7
+ "fr-FR": "fr-CA",
8
+ };
9
+ function getFallbackLocaleList(envLocale = "en") {
10
+ const validLocale = (0, GetOverrideLocale_1.getOverrideLocale)(envLocale);
11
+ if (validLocale === "en") {
12
+ return ["en"];
13
+ }
14
+ if (exports.FALLBACK_LOCALE_MAP[validLocale]) {
15
+ return [validLocale, exports.FALLBACK_LOCALE_MAP[validLocale], "en"];
16
+ }
17
+ return [validLocale, "en"];
18
+ }
19
+ exports.getFallbackLocaleList = getFallbackLocaleList;
20
+ //# sourceMappingURL=GetFallbackLocaleList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetFallbackLocaleList.js","sourceRoot":"","sources":["../../src/getFallbackLocaleList/GetFallbackLocaleList.ts"],"names":[],"mappings":";;;AACA,8EAA2E;AAK9D,QAAA,mBAAmB,GAAuC;IACrE,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,OAAO;CACjB,CAAC;AAOF,SAAgB,qBAAqB,CACnC,YAAoB,IAAI;IAGxB,MAAM,WAAW,GAAG,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;IAEjD,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IAED,IAAI,2BAAmB,CAAC,WAAW,CAAC,EAAE;QACpC,OAAO,CAAC,WAAW,EAAE,2BAAmB,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;KAC9D;IAED,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAfD,sDAeC"}
@@ -1,3 +1,3 @@
1
- import { Locale } from "./GetOverrideLocale.types";
2
- export declare function getOverrideLocale(envLocale: string): Locale;
3
- export declare function getFallbackLocaleList(envLocale: string): Locale[];
1
+ import { TmsSupportedLocale } from "../Formatter.types";
2
+ export declare const OVERWRITE_LOCALE_MAP: Record<string, TmsSupportedLocale>;
3
+ export declare function getOverrideLocale(envLocale: string): TmsSupportedLocale;
@@ -1,51 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFallbackLocaleList = exports.getOverrideLocale = void 0;
4
- const SUPPORTED_LOCALES = [
5
- "de-DE",
6
- "en-AU",
7
- "en-CA",
8
- "en-GB",
9
- "en",
10
- "es-ES",
11
- "es",
12
- "fr-CA",
13
- "fr-FR",
14
- "is-IS",
15
- "ja-JP",
16
- "pseudo",
17
- "pt-BR",
18
- "th-TH",
19
- "zh-SG",
20
- ];
21
- const OVERWRITE_LOCALE_MAP = {
3
+ exports.getOverrideLocale = exports.OVERWRITE_LOCALE_MAP = void 0;
4
+ const Formatter_types_1 = require("../Formatter.types");
5
+ exports.OVERWRITE_LOCALE_MAP = {
22
6
  "en-AE": "en-GB",
23
7
  "en-SG": "en-GB",
24
8
  "es-419": "es",
25
9
  };
26
10
  function getOverrideLocale(envLocale) {
27
- if (SUPPORTED_LOCALES.includes(envLocale)) {
11
+ if (Formatter_types_1.TMS_SUPPORTED_LOCALES.includes(envLocale)) {
28
12
  return envLocale;
29
13
  }
30
- if (OVERWRITE_LOCALE_MAP[envLocale]) {
31
- return OVERWRITE_LOCALE_MAP[envLocale];
14
+ if (exports.OVERWRITE_LOCALE_MAP[envLocale]) {
15
+ return exports.OVERWRITE_LOCALE_MAP[envLocale];
32
16
  }
33
17
  return "en";
34
18
  }
35
19
  exports.getOverrideLocale = getOverrideLocale;
36
- const FALLBACK_LOCALE_MAP = {
37
- "es-ES": "es",
38
- "fr-FR": "fr-CA",
39
- };
40
- function getFallbackLocaleList(envLocale) {
41
- const validLocale = getOverrideLocale(envLocale);
42
- if (validLocale === "en") {
43
- return ["en"];
44
- }
45
- if (FALLBACK_LOCALE_MAP[validLocale]) {
46
- return [validLocale, FALLBACK_LOCALE_MAP[validLocale], "en"];
47
- }
48
- return [validLocale, "en"];
49
- }
50
- exports.getFallbackLocaleList = getFallbackLocaleList;
51
20
  //# sourceMappingURL=GetOverrideLocale.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GetOverrideLocale.js","sourceRoot":"","sources":["../../src/getOverrideLocale/GetOverrideLocale.ts"],"names":[],"mappings":";;;AAGA,MAAM,iBAAiB,GAAa;IAClC,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC;AAMF,MAAM,oBAAoB,GAA2B;IACnD,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,IAAI;CACN,CAAC;AAOX,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,SAAmB,CAAC,EAAE;QACnD,OAAO,SAAmB,CAAC;KAC5B;IACD,IAAI,oBAAoB,CAAC,SAAS,CAAC,EAAE;QACnC,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC;KACxC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AATD,8CASC;AAKD,MAAM,mBAAmB,GAA2B;IAClD,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,OAAO;CACjB,CAAC;AAOF,SAAgB,qBAAqB,CAAC,SAAiB;IAErD,MAAM,WAAW,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAEjD,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IACD,IAAI,mBAAmB,CAAC,WAAW,CAAC,EAAE;QACpC,OAAO,CAAC,WAAW,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;KAC9D;IAED,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAZD,sDAYC"}
1
+ {"version":3,"file":"GetOverrideLocale.js","sourceRoot":"","sources":["../../src/getOverrideLocale/GetOverrideLocale.ts"],"names":[],"mappings":";;;AAAA,wDAA+E;AAOlE,QAAA,oBAAoB,GAAuC;IACtE,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,IAAI;CACN,CAAC;AAOX,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,IAAI,uCAAqB,CAAC,QAAQ,CAAC,SAA+B,CAAC,EAAE;QACnE,OAAO,SAA+B,CAAC;KACxC;IACD,IAAI,4BAAoB,CAAC,SAAS,CAAC,EAAE;QACnC,OAAO,4BAAoB,CAAC,SAAS,CAAC,CAAC;KACxC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AATD,8CASC"}
@@ -0,0 +1,6 @@
1
+ export type Translations = {
2
+ [key: string]: string;
3
+ };
4
+ export declare function getTranslationsFromLocale(envLocale: string | undefined, localeLoader: (lang: string) => Promise<{
5
+ default: Translations;
6
+ }>): Promise<Record<string, Translations>>;
@@ -0,0 +1,27 @@
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
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getTranslationsFromLocale = void 0;
13
+ const GetFallbackLocaleList_1 = require("../getFallbackLocaleList/GetFallbackLocaleList");
14
+ function getTranslationsFromLocale(envLocale, localeLoader) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const languagesToLoad = (0, GetFallbackLocaleList_1.getFallbackLocaleList)(envLocale);
17
+ const translationPromises = languagesToLoad.map((lang) => localeLoader(lang)
18
+ .then((module) => ({
19
+ [lang]: module.default,
20
+ }))
21
+ .catch(() => ({})));
22
+ const translationsArray = yield Promise.all(translationPromises);
23
+ return translationsArray.reduce((acc, translations) => (Object.assign(Object.assign({}, acc), translations)), {});
24
+ });
25
+ }
26
+ exports.getTranslationsFromLocale = getTranslationsFromLocale;
27
+ //# sourceMappingURL=GetTranslationsFromLocale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetTranslationsFromLocale.js","sourceRoot":"","sources":["../../src/getTranslationsFromLocale/GetTranslationsFromLocale.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0FAAuF;AAevF,SAAsB,yBAAyB,CAC7C,SAA6B,EAC7B,YAAkE;;QAElE,MAAM,eAAe,GAAG,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;QACzD,MAAM,mBAAmB,GAAG,eAAe,CAAC,GAAG,CAC7C,CAAC,IAAI,EAAE,EAAE,CACP,YAAY,CAAC,IAAI,CAAC;aACf,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACjB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,OAAO;SACvB,CAAC,CAAC;aACF,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACvB,CAAC;QAEF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAEjE,OAAO,iBAAiB,CAAC,MAAM,CAC7B,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,CAAC,iCAAM,GAAG,GAAK,YAAY,EAAG,EACpD,EAAE,CACH,CAAC;IACJ,CAAC;CAAA;AApBD,8DAoBC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  export { NumberFormatter, formatNumber, formatNumberToParts, parseNumber, getNumberSeparators, } from "./numbers/NumberFormatter";
2
2
  export { CurrencyFormatter, formatCurrency, formatCurrencyToParts, parseCurrency, getCurrencySeparators, getSupportedCurrencies, } from "./numbers/CurrencyFormatter";
3
- export { DateTimeFormatter, formatDateTime, formatDateTimeToLocalISOString, formatDateTimeToParts, getStartDayOfTheWeek, getDatePartsWithPlaceholders, getDatePlaceholder, } from "./dateTimes/DateTimeFormatter";
4
- export { getOverrideLocale, getFallbackLocaleList, } from "./getOverrideLocale/GetOverrideLocale";
3
+ export { DateTimeFormatter, formatDateTime, formatDateTimeToLocalISOString, formatDateTimeToParts, getStartDayOfTheWeek, getDatePartsWithPlaceholders, getDatePlaceholder, formatRelativeTime, } from "./dateTimes/DateTimeFormatter";
4
+ export { getOverrideLocale, OVERWRITE_LOCALE_MAP, } from "./getOverrideLocale/GetOverrideLocale";
5
+ export { getFallbackLocaleList, FALLBACK_LOCALE_MAP, } from "./getFallbackLocaleList/GetFallbackLocaleList";
6
+ export { type Translations, getTranslationsFromLocale, } from "./getTranslationsFromLocale/GetTranslationsFromLocale";
5
7
  export type { Percent, NumberOptions, NumberFormatPart, Separators, } from "./numbers/Number.types";
6
8
  export type { CurrencyDisplay, CurrencySign, CurrencyOptions, } from "./numbers/Currency.types";
7
- export type { DateTimeStyle, NumericTwoDigit, DateStyle, TimeStyle, TimeZoneName, Weekday, Year, Month, Day, Hour, Minute, Second, DateLabelOptions, DateTimeOptionsBasic, DateTimeOptionsStyle, DateTimeOptionsComponentsAll, DateTimeOptionsComponentsWeekdayYearMonthDay, DateTimeOptionsComponentsYearMonthDay, DateTimeOptionsComponentsYearMonth, DateTimeOptionsComponentsMonthDay, DateTimeOptionsComponentsHourMinuteSecond, DateTimeOptionsComponentsHourMinute, DateTimeOptions, DateTimeFormatPart, } from "./dateTimes/DateTime.types";
8
- export type { Locale, FormatterOptions } from "./Formatter.types";
9
+ export type { DateTimeStyle, NumericTwoDigit, DateStyle, TimeStyle, TimeZoneName, Weekday, Year, Month, Day, Hour, Minute, Second, DateLabelOptions, DateTimeOptionsBasic, DateTimeOptionsStyle, DateTimeOptionsComponentsAll, DateTimeOptionsComponentsWeekdayYearMonthDay, DateTimeOptionsComponentsYearMonthDay, DateTimeOptionsComponentsYearMonth, DateTimeOptionsComponentsMonthDay, DateTimeOptionsComponentsHourMinuteSecond, DateTimeOptionsComponentsHourMinute, DateTimeOptions, DateTimeFormatPart, RelativeTimeOptions, } from "./dateTimes/DateTime.types";
10
+ export type { DatesAndNumbersLocale as Locale, FormatterOptions, TMS_SUPPORTED_LOCALES, TmsSupportedLocale, ALL_LOCALES, AllLocale, MapLocalesToTranslations, } from "./Formatter.types";
package/dist/index.js CHANGED
@@ -1,15 +1,6 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getFallbackLocaleList = exports.getOverrideLocale = exports.getDatePlaceholder = exports.getDatePartsWithPlaceholders = exports.getStartDayOfTheWeek = exports.formatDateTimeToParts = exports.formatDateTimeToLocalISOString = 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;
3
+ exports.getTranslationsFromLocale = exports.FALLBACK_LOCALE_MAP = exports.getFallbackLocaleList = exports.OVERWRITE_LOCALE_MAP = exports.getOverrideLocale = exports.formatRelativeTime = exports.getDatePlaceholder = exports.getDatePartsWithPlaceholders = exports.getStartDayOfTheWeek = exports.formatDateTimeToParts = exports.formatDateTimeToLocalISOString = 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
4
  var NumberFormatter_1 = require("./numbers/NumberFormatter");
14
5
  Object.defineProperty(exports, "NumberFormatter", { enumerable: true, get: function () { return NumberFormatter_1.NumberFormatter; } });
15
6
  Object.defineProperty(exports, "formatNumber", { enumerable: true, get: function () { return NumberFormatter_1.formatNumber; } });
@@ -31,10 +22,13 @@ Object.defineProperty(exports, "formatDateTimeToParts", { enumerable: true, get:
31
22
  Object.defineProperty(exports, "getStartDayOfTheWeek", { enumerable: true, get: function () { return DateTimeFormatter_1.getStartDayOfTheWeek; } });
32
23
  Object.defineProperty(exports, "getDatePartsWithPlaceholders", { enumerable: true, get: function () { return DateTimeFormatter_1.getDatePartsWithPlaceholders; } });
33
24
  Object.defineProperty(exports, "getDatePlaceholder", { enumerable: true, get: function () { return DateTimeFormatter_1.getDatePlaceholder; } });
25
+ Object.defineProperty(exports, "formatRelativeTime", { enumerable: true, get: function () { return DateTimeFormatter_1.formatRelativeTime; } });
34
26
  var GetOverrideLocale_1 = require("./getOverrideLocale/GetOverrideLocale");
35
27
  Object.defineProperty(exports, "getOverrideLocale", { enumerable: true, get: function () { return GetOverrideLocale_1.getOverrideLocale; } });
36
- Object.defineProperty(exports, "getFallbackLocaleList", { enumerable: true, get: function () { return GetOverrideLocale_1.getFallbackLocaleList; } });
37
- exports.r2gSmokeTest = () => __awaiter(void 0, void 0, void 0, function* () {
38
- return Promise.resolve(true);
39
- });
28
+ Object.defineProperty(exports, "OVERWRITE_LOCALE_MAP", { enumerable: true, get: function () { return GetOverrideLocale_1.OVERWRITE_LOCALE_MAP; } });
29
+ var GetFallbackLocaleList_1 = require("./getFallbackLocaleList/GetFallbackLocaleList");
30
+ Object.defineProperty(exports, "getFallbackLocaleList", { enumerable: true, get: function () { return GetFallbackLocaleList_1.getFallbackLocaleList; } });
31
+ Object.defineProperty(exports, "FALLBACK_LOCALE_MAP", { enumerable: true, get: function () { return GetFallbackLocaleList_1.FALLBACK_LOCALE_MAP; } });
32
+ var GetTranslationsFromLocale_1 = require("./getTranslationsFromLocale/GetTranslationsFromLocale");
33
+ Object.defineProperty(exports, "getTranslationsFromLocale", { enumerable: true, get: function () { return GetTranslationsFromLocale_1.getTranslationsFromLocale; } });
40
34
  //# 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,iEAOqC;AANnC,sHAAA,iBAAiB,OAAA;AACjB,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,kHAAA,aAAa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,mGAG+D;AAD7D,sIAAA,yBAAyB,OAAA"}
@@ -1,4 +1,4 @@
1
- import { Locale } from "../Formatter.types";
1
+ import { DatesAndNumbersLocale } from "../Formatter.types";
2
2
  import { NumberOptions, NumberFormatPart, Separators, Percent } from "./Number.types";
3
3
  export declare class NumberFormatter {
4
4
  formatter: Intl.NumberFormat;
@@ -12,4 +12,4 @@ export declare class NumberFormatter {
12
12
  export declare function formatNumber(value: number | string, numberOptions: NumberOptions): string;
13
13
  export declare function formatNumberToParts(value: number, numberOptions: NumberOptions): NumberFormatPart[];
14
14
  export declare function parseNumber(value: string, numberOptions: NumberOptions): number;
15
- export declare function getNumberSeparators(locale: Locale): Separators;
15
+ export declare function getNumberSeparators(locale: DatesAndNumbersLocale): Separators;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberFormatter.js","sourceRoot":"","sources":["../../src/numbers/NumberFormatter.ts"],"names":[],"mappings":";;;AAEA,sDAAgD;AAChD,+CAIuB;AACvB,iDAKwB;AAExB,MAAa,eAAe;IAO1B,YAAY,aAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,IAAA,gCAAkB,EAAC,aAAa,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC;IACxC,CAAC;IAOD,YAAY,CAAC,KAAsB;QACjC,OAAO,IAAA,oCAAsB,EAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAOD,mBAAmB,CAAC,KAAa;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CACjC,MAAM,CAAC,IAAA,mCAAqB,EAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACnE,CAAC;IACJ,CAAC;IAOD,WAAW,CAAC,KAAa;;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,GAAG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