gt-next 5.2.37 → 5.2.39-alpha.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 (85) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/branches/Plural.d.ts +4 -4
  3. package/dist/branches/Plural.d.ts.map +1 -1
  4. package/dist/branches/Plural.js +7 -48
  5. package/dist/branches/Plural.js.map +1 -1
  6. package/dist/config-dir/DictionaryManager.js +2 -2
  7. package/dist/config-dir/DictionaryManager.js.map +1 -1
  8. package/dist/config-dir/I18NConfiguration.d.ts +1 -1
  9. package/dist/config-dir/I18NConfiguration.d.ts.map +1 -1
  10. package/dist/config-dir/I18NConfiguration.js +4 -5
  11. package/dist/config-dir/I18NConfiguration.js.map +1 -1
  12. package/dist/config-dir/TranslationManager.js +3 -3
  13. package/dist/config-dir/TranslationManager.js.map +1 -1
  14. package/dist/config.js +3 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/dictionary/getDictionary.d.ts.map +1 -1
  17. package/dist/dictionary/getDictionary.js +2 -2
  18. package/dist/dictionary/getDictionary.js.map +1 -1
  19. package/dist/errors/createErrors.js +5 -2
  20. package/dist/errors/createErrors.js.map +1 -1
  21. package/dist/index.client.d.ts +2 -2
  22. package/dist/index.client.d.ts.map +1 -1
  23. package/dist/index.client.js +1 -3
  24. package/dist/index.client.js.map +1 -1
  25. package/dist/index.server.d.ts +9 -2
  26. package/dist/index.server.d.ts.map +1 -1
  27. package/dist/index.server.js +25 -11
  28. package/dist/index.server.js.map +1 -1
  29. package/dist/index.types.d.ts +16 -35
  30. package/dist/index.types.d.ts.map +1 -1
  31. package/dist/index.types.js +16 -41
  32. package/dist/index.types.js.map +1 -1
  33. package/dist/middleware-dir/createNextMiddleware.d.ts.map +1 -1
  34. package/dist/middleware-dir/createNextMiddleware.js +10 -6
  35. package/dist/middleware-dir/createNextMiddleware.js.map +1 -1
  36. package/dist/middleware-dir/utils.d.ts.map +1 -1
  37. package/dist/middleware-dir/utils.js +13 -10
  38. package/dist/middleware-dir/utils.js.map +1 -1
  39. package/dist/next/getNextLocale.js +2 -2
  40. package/dist/next/getNextLocale.js.map +1 -1
  41. package/dist/provider/ClientProviderWrapper.js +6 -3
  42. package/dist/provider/ClientProviderWrapper.js.map +1 -1
  43. package/dist/provider/GTProvider.js +2 -2
  44. package/dist/provider/GTProvider.js.map +1 -1
  45. package/dist/request/getLocale.d.ts +2 -1
  46. package/dist/request/getLocale.d.ts.map +1 -1
  47. package/dist/request/getLocale.js +6 -1
  48. package/dist/request/getLocale.js.map +1 -1
  49. package/dist/server-dir/buildtime/T.js +2 -2
  50. package/dist/server-dir/buildtime/T.js.map +1 -1
  51. package/dist/server-dir/buildtime/getGT.d.ts +11 -1
  52. package/dist/server-dir/buildtime/getGT.d.ts.map +1 -1
  53. package/dist/server-dir/buildtime/getGT.js +37 -27
  54. package/dist/server-dir/buildtime/getGT.js.map +1 -1
  55. package/dist/server-dir/buildtime/getTranslations.d.ts +16 -2
  56. package/dist/server-dir/buildtime/getTranslations.d.ts.map +1 -1
  57. package/dist/server-dir/buildtime/getTranslations.js +43 -18
  58. package/dist/server-dir/buildtime/getTranslations.js.map +1 -1
  59. package/dist/server-dir/runtime/_Tx.js +2 -2
  60. package/dist/server-dir/runtime/_Tx.js.map +1 -1
  61. package/dist/server-dir/runtime/tx.d.ts +1 -1
  62. package/dist/server-dir/runtime/tx.d.ts.map +1 -1
  63. package/dist/server-dir/runtime/tx.js +18 -16
  64. package/dist/server-dir/runtime/tx.js.map +1 -1
  65. package/dist/server.d.ts +5 -4
  66. package/dist/server.d.ts.map +1 -1
  67. package/dist/server.js +11 -7
  68. package/dist/server.js.map +1 -1
  69. package/dist/utils/use.d.ts +4 -0
  70. package/dist/utils/use.d.ts.map +1 -0
  71. package/dist/utils/use.js +73 -0
  72. package/dist/utils/use.js.map +1 -0
  73. package/dist/variables/Currency.d.ts +20 -3
  74. package/dist/variables/Currency.d.ts.map +1 -1
  75. package/dist/variables/Currency.js +29 -58
  76. package/dist/variables/Currency.js.map +1 -1
  77. package/dist/variables/DateTime.d.ts +20 -3
  78. package/dist/variables/DateTime.d.ts.map +1 -1
  79. package/dist/variables/DateTime.js +26 -70
  80. package/dist/variables/DateTime.js.map +1 -1
  81. package/dist/variables/Num.d.ts +6 -4
  82. package/dist/variables/Num.d.ts.map +1 -1
  83. package/dist/variables/Num.js +15 -59
  84. package/dist/variables/Num.js.map +1 -1
  85. package/package.json +4 -4
@@ -51,9 +51,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.default = tx;
54
- var generaltranslation_1 = require("generaltranslation");
54
+ var generaltranslation_1 = __importDefault(require("generaltranslation"));
55
55
  var getI18NConfig_1 = __importDefault(require("../../config-dir/getI18NConfig"));
56
- var getLocale_1 = __importDefault(require("../../request/getLocale"));
56
+ var getLocale_1 = require("../../request/getLocale");
57
57
  var createErrors_1 = require("../../errors/createErrors");
58
58
  var id_1 = require("generaltranslation/id");
59
59
  /**
@@ -88,20 +88,20 @@ var id_1 = require("generaltranslation/id");
88
88
  * // Using variables in the content string
89
89
  * const translation = await tx("The price is {price}", { locale: 'es-MX', variables: { price: 29.99 } });
90
90
  */
91
- function tx(string_1) {
92
- return __awaiter(this, arguments, void 0, function (string, options) {
93
- var I18NConfig, locale, _a, defaultLocale, translationRequired, source, renderContent, hash, recentTranslations, target, error_1;
91
+ function tx(message_1) {
92
+ return __awaiter(this, arguments, void 0, function (message, options) {
93
+ var I18NConfig, locale, _a, defaultLocale, translationRequired, renderContent, hash, recentTranslations, target, error_1;
94
94
  var _b;
95
95
  if (options === void 0) { options = {}; }
96
96
  return __generator(this, function (_c) {
97
97
  switch (_c.label) {
98
98
  case 0:
99
- if (!string || typeof string !== 'string')
99
+ if (!message || typeof message !== 'string')
100
100
  return [2 /*return*/, ''];
101
101
  I18NConfig = (0, getI18NConfig_1.default)();
102
102
  _a = options.locale;
103
103
  if (_a) return [3 /*break*/, 2];
104
- return [4 /*yield*/, (0, getLocale_1.default)()];
104
+ return [4 /*yield*/, (0, getLocale_1.getLocale)()];
105
105
  case 1:
106
106
  _a = (_c.sent());
107
107
  _c.label = 2;
@@ -109,14 +109,16 @@ function tx(string_1) {
109
109
  locale = _a;
110
110
  defaultLocale = I18NConfig.getDefaultLocale();
111
111
  translationRequired = I18NConfig.requiresTranslation(locale)[0];
112
- source = (0, generaltranslation_1.splitStringToContent)(string);
113
- renderContent = function (content, locales) {
114
- return (0, generaltranslation_1.renderContentToString)(content, locales, options.variables, options.variablesOptions);
112
+ renderContent = function (message, locales) {
113
+ return generaltranslation_1.default.formatMessage(message, {
114
+ locales: locales,
115
+ variables: options.variables,
116
+ });
115
117
  };
116
118
  // ----- CHECK IF TRANSLATION REQUIRED ----- //
117
119
  if (!translationRequired)
118
- return [2 /*return*/, renderContent(source, [defaultLocale])];
119
- hash = (0, id_1.hashJsxChildren)(__assign(__assign(__assign({ source: source }, ((options === null || options === void 0 ? void 0 : options.context) && { context: options.context })), ((options === null || options === void 0 ? void 0 : options.id) && { id: options.id })), { dataFormat: 'JSX' }));
120
+ return [2 /*return*/, renderContent(message, [defaultLocale])];
121
+ hash = (0, id_1.hashJsxChildren)(__assign(__assign(__assign({ source: message }, ((options === null || options === void 0 ? void 0 : options.context) && { context: options.context })), ((options === null || options === void 0 ? void 0 : options.id) && { id: options.id })), { dataFormat: 'JSX' }));
120
122
  recentTranslations = I18NConfig.getRecentTranslations(locale);
121
123
  if (((_b = recentTranslations === null || recentTranslations === void 0 ? void 0 : recentTranslations[hash]) === null || _b === void 0 ? void 0 : _b.state) === 'success') {
122
124
  return [2 /*return*/, renderContent(recentTranslations[hash].target, [
@@ -128,17 +130,17 @@ function tx(string_1) {
128
130
  case 3:
129
131
  _c.trys.push([3, 5, , 6]);
130
132
  return [4 /*yield*/, I18NConfig.translateContent({
131
- source: source,
133
+ source: message,
132
134
  targetLocale: locale,
133
135
  options: __assign(__assign({}, options), { hash: hash }),
134
136
  })];
135
137
  case 4:
136
- target = _c.sent();
138
+ target = (_c.sent());
137
139
  return [2 /*return*/, renderContent(target, [locale, defaultLocale])];
138
140
  case 5:
139
141
  error_1 = _c.sent();
140
- console.error((0, createErrors_1.createStringTranslationError)(string, options.id), error_1);
141
- return [2 /*return*/, renderContent(source, [defaultLocale])];
142
+ console.error((0, createErrors_1.createStringTranslationError)(message, options.id), error_1);
143
+ return [2 /*return*/, renderContent(message, [defaultLocale])];
142
144
  case 6: return [2 /*return*/];
143
145
  }
144
146
  });
@@ -1 +1 @@
1
- {"version":3,"file":"tx.js","sourceRoot":"","sources":["../../../src/server-dir/runtime/tx.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,qBA8DC;AAxGD,yDAG4B;AAC5B,iFAA2D;AAC3D,sEAAgD;AAChD,0DAAyE;AACzE,4CAAwD;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAA8B,EAAE;wDAC9B,MAAc,EACd,OAAuC;;;QAAvC,wBAAA,EAAA,YAAuC;;;;oBAEvC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;wBAAE,sBAAO,EAAE,EAAC;oBAI/C,UAAU,GAAG,IAAA,uBAAa,GAAE,CAAC;oBACpB,KAAA,OAAO,CAAC,MAAM,CAAA;4BAAd,wBAAc;oBAAK,qBAAM,IAAA,mBAAS,GAAE,EAAA;;oBAAlB,KAAA,CAAC,SAAiB,CAAC,CAAA;;;oBAA9C,MAAM,KAAwC;oBAC9C,aAAa,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;oBAC7C,mBAAmB,GAAI,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAA1C,CAA2C;oBAC/D,MAAM,GAAG,IAAA,yCAAoB,EAAC,MAAM,CAAC,CAAC;oBAItC,aAAa,GAAG,UAAC,OAAY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AAe,+BAC1B,MAAM,EAAE,OAAO,IACZ,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,KAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,GAClD,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,KAAI,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,KACtC,UAAU,EAAE,KAAK,IACjB,CAAC;oBAIG,kBAAkB,GAAG,UAAU,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;oBACpE,IAAI,CAAA,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,0CAAE,KAAK,MAAK,SAAS,EAAE,CAAC;wBACpD,sBAAO,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAgB,EAAE;gCAC9D,MAAM;gCACN,aAAa;6BACd,CAAC,EAAC;oBACL,CAAC;;;;oBAMiB,qBAAM,UAAU,CAAC,gBAAgB,CAAC;4BAChD,MAAM,EAAE,OAAO;4BACf,YAAY,EAAE,MAAM;4BACpB,OAAO,wBAAO,OAAO,KAAE,IAAI,MAAA,GAAE;yBAC9B,CAAC,EAAA;;oBAJI,MAAM,GAAG,CAAC,SAId,CAAW;oBACb,sBAAO,aAAa,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,EAAC;;;oBAEtD,OAAO,CAAC,KAAK,CAAC,IAAA,2CAA4B,EAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,OAAK,CAAC,CAAC;oBACxE,sBAAO,aAAa,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,EAAC;;;;;CAElD"}
package/dist/server.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import T from './server-dir/buildtime/T';
2
2
  import tx from './server-dir/runtime/tx';
3
- import getLocale from './request/getLocale';
4
- import getTranslations from './server-dir/buildtime/getTranslations';
3
+ import { getLocale } from './request/getLocale';
4
+ import { getTranslations } from './server-dir/buildtime/getTranslations';
5
5
  import GTProvider from './provider/GTProvider';
6
6
  import Tx from './server-dir/runtime/_Tx';
7
- import getGT from './server-dir/buildtime/getGT';
7
+ import { getGT } from './server-dir/buildtime/getGT';
8
8
  import { LocaleProperties } from 'generaltranslation/types';
9
9
  export declare function getDefaultLocale(): string;
10
- export declare function getGTClass(): import("generaltranslation").GT;
10
+ export declare function getGTClass(): import("generaltranslation").default;
11
11
  export declare function getLocaleProperties(locale: string): LocaleProperties;
12
+ export declare function getLocales(): string[];
12
13
  export { GTProvider, T, getGT, tx, Tx, getLocale, // getDefaultLocale
13
14
  getTranslations,
14
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,OAAO,eAAe,MAAM,wCAAwC,CAAC;AACrE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1C,OAAO,KAAK,MAAM,8BAA8B,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,UAAU,oCAEzB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEpE;AAED,OAAO,EACL,UAAU,EACV,CAAC,EACD,KAAK,EACL,EAAE,EACF,EAAE,EACF,SAAS,EAAE,mBAAmB;AAC9B,eAAe;AACf;;GAEG;AACH,eAAe,IAAI,OAAO,GAC3B,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,UAAU,yCAEzB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEpE;AAED,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAErC;AAED,OAAO,EACL,UAAU,EACV,CAAC,EACD,KAAK,EACL,EAAE,EACF,EAAE,EACF,SAAS,EAAE,mBAAmB;AAC9B,eAAe;AACf;;GAEG;AACH,eAAe,IAAI,OAAO,GAC3B,CAAC"}
package/dist/server.js CHANGED
@@ -7,22 +7,23 @@ exports.getDict = exports.getTranslations = exports.getLocale = exports.Tx = exp
7
7
  exports.getDefaultLocale = getDefaultLocale;
8
8
  exports.getGTClass = getGTClass;
9
9
  exports.getLocaleProperties = getLocaleProperties;
10
+ exports.getLocales = getLocales;
10
11
  var T_1 = __importDefault(require("./server-dir/buildtime/T"));
11
12
  exports.T = T_1.default;
12
13
  var tx_1 = __importDefault(require("./server-dir/runtime/tx"));
13
14
  exports.tx = tx_1.default;
14
- var getLocale_1 = __importDefault(require("./request/getLocale"));
15
- exports.getLocale = getLocale_1.default;
15
+ var getLocale_1 = require("./request/getLocale");
16
+ Object.defineProperty(exports, "getLocale", { enumerable: true, get: function () { return getLocale_1.getLocale; } });
16
17
  var getI18NConfig_1 = __importDefault(require("./config-dir/getI18NConfig"));
17
- var getTranslations_1 = __importDefault(require("./server-dir/buildtime/getTranslations"));
18
- exports.getTranslations = getTranslations_1.default;
19
- exports.getDict = getTranslations_1.default;
18
+ var getTranslations_1 = require("./server-dir/buildtime/getTranslations");
19
+ Object.defineProperty(exports, "getTranslations", { enumerable: true, get: function () { return getTranslations_1.getTranslations; } });
20
+ Object.defineProperty(exports, "getDict", { enumerable: true, get: function () { return getTranslations_1.getTranslations; } });
20
21
  var GTProvider_1 = __importDefault(require("./provider/GTProvider"));
21
22
  exports.GTProvider = GTProvider_1.default;
22
23
  var _Tx_1 = __importDefault(require("./server-dir/runtime/_Tx"));
23
24
  exports.Tx = _Tx_1.default;
24
- var getGT_1 = __importDefault(require("./server-dir/buildtime/getGT"));
25
- exports.getGT = getGT_1.default;
25
+ var getGT_1 = require("./server-dir/buildtime/getGT");
26
+ Object.defineProperty(exports, "getGT", { enumerable: true, get: function () { return getGT_1.getGT; } });
26
27
  function getDefaultLocale() {
27
28
  return (0, getI18NConfig_1.default)().getDefaultLocale();
28
29
  }
@@ -32,4 +33,7 @@ function getGTClass() {
32
33
  function getLocaleProperties(locale) {
33
34
  return getGTClass().getLocaleProperties(locale);
34
35
  }
36
+ function getLocales() {
37
+ return (0, getI18NConfig_1.default)().getLocales();
38
+ }
35
39
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAUA,4CAEC;AAED,gCAEC;AAED,kDAEC;AApBD,+DAAyC;AAwBvC,YAxBK,WAAC,CAwBL;AAvBH,+DAAyC;AAyBvC,aAzBK,YAAE,CAyBL;AAxBJ,kEAA4C;AA0B1C,oBA1BK,mBAAS,CA0BL;AAzBX,6EAAuD;AACvD,2FAAqE;AAyBnE,0BAzBK,yBAAe,CAyBL;AAII,kBA7Bd,yBAAe,CA6BM;AA5B5B,qEAA+C;AAkB7C,qBAlBK,oBAAU,CAkBL;AAjBZ,iEAA0C;AAqBxC,aArBK,aAAE,CAqBL;AApBJ,uEAAiD;AAkB/C,gBAlBK,eAAK,CAkBL;AAfP,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAc;IAChD,OAAO,UAAU,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC"}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAUA,4CAEC;AAED,gCAEC;AAED,kDAEC;AAED,gCAEC;AAxBD,+DAAyC;AA4BvC,YA5BK,WAAC,CA4BL;AA3BH,+DAAyC;AA6BvC,aA7BK,YAAE,CA6BL;AA5BJ,iDAAgD;AA8B9C,0FA9BO,qBAAS,OA8BP;AA7BX,6EAAuD;AACvD,0EAAyE;AA6BvE,gGA7BO,iCAAe,OA6BP;AAII,wFAjCZ,iCAAe,OAiCI;AAhC5B,qEAA+C;AAsB7C,qBAtBK,oBAAU,CAsBL;AArBZ,iEAA0C;AAyBxC,aAzBK,aAAE,CAyBL;AAxBJ,sDAAqD;AAsBnD,sFAtBO,aAAK,OAsBP;AAnBP,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAc;IAChD,OAAO,UAAU,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import * as react from 'react';
2
+ declare const _default: typeof react.use;
3
+ export default _default;
4
+ //# sourceMappingURL=use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../src/utils/use.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;wBAYO,OAAO,KAAK,CAAC,GAAG;AAAtD,wBAAuD"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // The code in this file is taken from https://github.com/amannn/next-intl/blob/main/packages/next-intl/src/shared/use.tsx
3
+ // And is therefore MIT licensed
4
+ // Thank you Jan Amann!
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ /*
40
+ MIT License
41
+
42
+ Copyright (c) 2024 Jan Amann
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining a copy
45
+ of this software and associated documentation files (the "Software"), to deal
46
+ in the Software without restriction, including without limitation the rights
47
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
48
+ copies of the Software, and to permit persons to whom the Software is
49
+ furnished to do so, subject to the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be included in all
52
+ copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60
+ SOFTWARE.
61
+ */
62
+ var react = __importStar(require("react"));
63
+ // Original comments included for reference:
64
+ // @ts-expect-error -- Ooof, Next.js doesn't make this easy.
65
+ // `use` is only available in React 19 canary, but we can
66
+ // use it in Next.js already as Next.js "vendors" a fixed
67
+ // version of React. However, if we'd simply put `use` in
68
+ // ESM code, then the build doesn't work since React does
69
+ // not export `use` officially. Therefore, we have to use
70
+ // something that is not statically analyzable. Once React
71
+ // 19 is out, we can remove this in the next major version.
72
+ exports.default = react['use'.trim()];
73
+ //# sourceMappingURL=use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/utils/use.ts"],"names":[],"mappings":";AAAA,0HAA0H;AAC1H,gCAAgC;AAChC,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvB;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAEF,2CAA+B;AAE/B,4CAA4C;AAE5C,4DAA4D;AAC5D,yDAAyD;AACzD,yDAAyD;AACzD,yDAAyD;AACzD,yDAAyD;AACzD,yDAAyD;AACzD,0DAA0D;AAC1D,2DAA2D;AAC3D,kBAAe,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAqB,CAAC"}
@@ -1,10 +1,27 @@
1
- declare function Currency({ children, currency, name, locales, options, }: {
2
- children?: any;
1
+ import React from 'react';
2
+ /**
3
+ * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.
4
+ *
5
+ * @example
6
+ * ```jsx
7
+ * <Currency currency="USD">
8
+ * 1000
9
+ * </Currency>
10
+ * ```
11
+ *
12
+ * @param {number | string} children - Content to render inside the currency component.
13
+ * @param {string} [currency="USD"] - The currency type (e.g., USD, EUR, etc.).
14
+ * @param {string[]} [locales] - Optional locales to use for currency formatting. If not provided, the library will default to the user's locale..
15
+ * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options to customize how the currency is displayed.
16
+ * @returns {JSX.Element} The formatted currency component.
17
+ */
18
+ declare function Currency({ children, currency, locales, options, }: {
19
+ children: number | string;
3
20
  currency?: string;
4
21
  name?: string;
5
22
  options?: Intl.NumberFormatOptions;
6
23
  locales?: string[];
7
- }): Promise<React.JSX.Element>;
24
+ }): React.JSX.Element;
8
25
  declare namespace Currency {
9
26
  var gtTransformation: string;
10
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Currency.d.ts","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"AAIA,iBAAe,QAAQ,CAAC,EACtB,QAAQ,EACR,QAAgB,EAChB,IAAI,EACJ,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAgB7B;kBA5Bc,QAAQ;;;AAgCvB,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Currency.d.ts","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAkBpB;kBA7BQ,QAAQ;;;AAiCjB,eAAe,QAAQ,CAAC"}
@@ -10,71 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
15
  };
52
16
  Object.defineProperty(exports, "__esModule", { value: true });
53
17
  var jsx_runtime_1 = require("react/jsx-runtime");
54
- var generaltranslation_1 = require("generaltranslation");
55
18
  var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
56
- var getLocale_1 = __importDefault(require("../request/getLocale"));
19
+ var getLocale_1 = require("../request/getLocale");
20
+ /**
21
+ * The `<Currency>` component renders a formatted currency string, allowing customization of name, default value, currency type, and formatting options.
22
+ *
23
+ * @example
24
+ * ```jsx
25
+ * <Currency currency="USD">
26
+ * 1000
27
+ * </Currency>
28
+ * ```
29
+ *
30
+ * @param {number | string} children - Content to render inside the currency component.
31
+ * @param {string} [currency="USD"] - The currency type (e.g., USD, EUR, etc.).
32
+ * @param {string[]} [locales] - Optional locales to use for currency formatting. If not provided, the library will default to the user's locale..
33
+ * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options to customize how the currency is displayed.
34
+ * @returns {JSX.Element} The formatted currency component.
35
+ */
57
36
  function Currency(_a) {
58
- return __awaiter(this, arguments, void 0, function (_b) {
59
- var renderedValue, formattedValue;
60
- var children = _b.children, _c = _b.currency, currency = _c === void 0 ? 'USD' : _c, name = _b.name, locales = _b.locales, _d = _b.options, options = _d === void 0 ? {} : _d;
61
- return __generator(this, function (_e) {
62
- switch (_e.label) {
63
- case 0:
64
- if (!!locales) return [3 /*break*/, 2];
65
- return [4 /*yield*/, (0, getLocale_1.default)()];
66
- case 1:
67
- locales = [_e.sent(), (0, getI18NConfig_1.default)().getDefaultLocale()];
68
- _e.label = 2;
69
- case 2:
70
- renderedValue = typeof children === 'string' ? parseFloat(children) : children;
71
- formattedValue = typeof renderedValue === 'number'
72
- ? (0, generaltranslation_1.formatCurrency)(renderedValue, currency, __assign({ locales: locales }, options))
73
- : renderedValue;
74
- return [2 /*return*/, (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue })];
75
- }
76
- });
77
- });
37
+ var children = _a.children, _b = _a.currency, currency = _b === void 0 ? 'USD' : _b, locales = _a.locales, _c = _a.options, options = _c === void 0 ? {} : _c;
38
+ if (!locales) {
39
+ locales = [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()];
40
+ }
41
+ var gt = (0, getI18NConfig_1.default)().getGTClass();
42
+ // Determine the value to be formatted
43
+ var renderedValue = typeof children === 'string' ? parseFloat(children) : children;
44
+ // Format the number as currency according to the locale
45
+ var formattedValue = typeof renderedValue === 'number'
46
+ ? gt.formatCurrency(renderedValue, currency, __assign({ locales: locales }, options))
47
+ : renderedValue;
48
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue });
78
49
  }
79
50
  Currency.gtTransformation = 'variable-currency';
80
51
  exports.default = Currency;
@@ -1 +1 @@
1
- {"version":3,"file":"Currency.js","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAoD;AACpD,8EAAwD;AACxD,mEAA6C;AAE7C,SAAe,QAAQ;wDAAC,EAYvB;;YAXC,QAAQ,cAAA,EACR,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;;;;yBAQR,CAAC,OAAO,EAAR,wBAAQ;oBACC,qBAAM,IAAA,mBAAS,GAAE,EAAA;;oBAA5B,OAAO,IAAI,SAAiB,EAAE,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;;;oBAI9D,aAAa,GACjB,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;oBAG3D,cAAc,GAClB,OAAO,aAAa,KAAK,QAAQ;wBAC/B,CAAC,CAAC,IAAA,mCAAc,EAAC,aAAa,EAAE,QAAQ,aAAI,OAAO,SAAA,IAAK,OAAO,EAAG;wBAClE,CAAC,CAAC,aAAa,CAAC;oBAEpB,sBAAO,2DAAG,cAAc,GAAI,EAAC;;;;CAC9B;AAED,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Currency.js","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8EAAwD;AACxD,kDAAiD;AAGjD;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ,CAAC,EAWjB;QAVC,QAAQ,cAAA,EACR,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IAQZ,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,IAAA,qBAAS,GAAE,EAAE,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAM,EAAE,GAAG,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;IAExC,sCAAsC;IACtC,IAAM,aAAa,GACjB,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEjE,wDAAwD;IACxD,IAAM,cAAc,GAClB,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,EAAE,QAAQ,aAAI,OAAO,SAAA,IAAK,OAAO,EAAG;QACrE,CAAC,CAAC,aAAa,CAAC;IAEpB,OAAO,2DAAG,cAAc,GAAI,CAAC;AAC/B,CAAC;AAED,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
@@ -1,9 +1,26 @@
1
- declare function DateTime({ children, name, locales, options, }: {
2
- children?: any;
1
+ import React from 'react';
2
+ /**
3
+ * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
4
+ * It utilizes the current locale and optional format settings to display the date.
5
+ *
6
+ * @example
7
+ * ```jsx
8
+ * <DateTime>
9
+ * {new Date()}
10
+ * </DateTime>
11
+ * ```
12
+ *
13
+ * @param {Date} [children] - Optional content to render inside the component.
14
+ * @param {string[]} [locales] - Optional locales to use for date formatting. If not provided, the library default locale (en-US) is used. If wrapped in a `<GTProvider>`, the user's locale is used.
15
+ * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
16
+ * @returns {JSX.Element} The formatted date or time component.
17
+ */
18
+ declare function DateTime({ children, locales, options, }: {
19
+ children: Date;
3
20
  name?: string;
4
21
  options?: Intl.DateTimeFormatOptions;
5
22
  locales?: string[];
6
- }): Promise<React.JSX.Element>;
23
+ }): React.JSX.Element;
7
24
  declare namespace DateTime {
8
25
  var gtTransformation: string;
9
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAIA,iBAAe,QAAQ,CAAC,EACtB,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CA6B7B;kBAvCc,QAAQ;;;AA2CvB,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAWpB;kBApBQ,QAAQ;;;AAwBjB,eAAe,QAAQ,CAAC"}
@@ -10,83 +10,39 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
15
  };
52
16
  Object.defineProperty(exports, "__esModule", { value: true });
53
17
  var jsx_runtime_1 = require("react/jsx-runtime");
54
- var generaltranslation_1 = require("generaltranslation");
55
18
  var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
56
- var getLocale_1 = __importDefault(require("../request/getLocale"));
19
+ var getLocale_1 = require("../request/getLocale");
20
+ /**
21
+ * The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
22
+ * It utilizes the current locale and optional format settings to display the date.
23
+ *
24
+ * @example
25
+ * ```jsx
26
+ * <DateTime>
27
+ * {new Date()}
28
+ * </DateTime>
29
+ * ```
30
+ *
31
+ * @param {Date} [children] - Optional content to render inside the component.
32
+ * @param {string[]} [locales] - Optional locales to use for date formatting. If not provided, the library default locale (en-US) is used. If wrapped in a `<GTProvider>`, the user's locale is used.
33
+ * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
34
+ * @returns {JSX.Element} The formatted date or time component.
35
+ */
57
36
  function DateTime(_a) {
58
- return __awaiter(this, arguments, void 0, function (_b) {
59
- var final, dateValue, defaultValue;
60
- var children = _b.children, name = _b.name, locales = _b.locales, _c = _b.options, options = _c === void 0 ? {} : _c;
61
- return __generator(this, function (_d) {
62
- switch (_d.label) {
63
- case 0:
64
- if (!!locales) return [3 /*break*/, 2];
65
- return [4 /*yield*/, (0, getLocale_1.default)()];
66
- case 1:
67
- locales = [_d.sent(), (0, getI18NConfig_1.default)().getDefaultLocale()];
68
- _d.label = 2;
69
- case 2:
70
- defaultValue = children;
71
- if (typeof defaultValue === 'number') {
72
- dateValue = new Date(defaultValue);
73
- }
74
- else if (typeof defaultValue === 'string') {
75
- dateValue = new Date(defaultValue);
76
- }
77
- else if (defaultValue instanceof Date) {
78
- dateValue = defaultValue;
79
- }
80
- if (typeof dateValue !== 'undefined' && isNaN(dateValue.getTime())) {
81
- throw new Error("DateTime Error -- Invalid date format: \"".concat(defaultValue, "\". Please use a Date object, valid date string, or number."));
82
- }
83
- if (typeof dateValue !== 'undefined') {
84
- final = (0, generaltranslation_1.formatDateTime)(dateValue, __assign({ locales: locales }, options)).replace(/[\u200F\u202B\u202E]/g, '');
85
- }
86
- return [2 /*return*/, (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: final })];
87
- }
88
- });
89
- });
37
+ var children = _a.children, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
38
+ if (!locales) {
39
+ locales = [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()];
40
+ }
41
+ var gt = (0, getI18NConfig_1.default)().getGTClass();
42
+ var result = gt
43
+ .formatDateTime(children, __assign({ locales: locales }, options))
44
+ .replace(/[\u200F\u202B\u202E]/g, '');
45
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: result });
90
46
  }
91
47
  DateTime.gtTransformation = 'variable-datetime';
92
48
  exports.default = DateTime;
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAoD;AACpD,8EAAwD;AACxD,mEAA6C;AAE7C,S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;;;;AAAA,8EAAwD;AACxD,kDAAiD;AAGjD;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ,CAAC,EASjB;QARC,QAAQ,cAAA,EACR,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IAOZ,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,IAAA,qBAAS,GAAE,EAAE,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAM,EAAE,GAAG,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;IAExC,IAAM,MAAM,GAAG,EAAE;SACd,cAAc,CAAC,QAAQ,aAAI,OAAO,SAAA,IAAK,OAAO,EAAG;SACjD,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,2DAAG,MAAM,GAAI,CAAC;AACvB,CAAC;AAED,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
3
4
  * It formats the number according to the current locale and optionally passed formatting options.
@@ -11,16 +12,17 @@
11
12
  * </Num>
12
13
  * ```
13
14
  *
14
- * @param {any} [children] - Optional content (typically a number) to render inside the component.
15
+ * @param {number | string} children - Content to render inside the number component.
16
+ * @param {string[]} [locales] - Optional locales to use for number formatting. If not provided, the library will default to the user's locale.
15
17
  * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
16
18
  * @returns {Promise<React.JSX.Element>} The formatted number component.
17
19
  */
18
- declare function Num({ children, name, locales, options, }: {
19
- children?: any;
20
+ declare function Num({ children, locales, options, }: {
21
+ children: number | string;
20
22
  name?: string;
21
23
  options?: Intl.NumberFormatOptions;
22
24
  locales?: string[];
23
- }): Promise<React.JSX.Element>;
25
+ }): React.JSX.Element;
24
26
  declare namespace Num {
25
27
  var gtTransformation: string;
26
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAe,GAAG,CAAC,EACjB,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAgB7B;kBA1Bc,GAAG;;;AA8BlB,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,GAAG,CAAC,EACX,QAAQ,EACR,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiBpB;kBA1BQ,GAAG;;;AA8BZ,eAAe,GAAG,CAAC"}