gt-next 5.2.39 → 6.0.0-alpha.14

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 (66) hide show
  1. package/CHANGELOG.md +0 -9
  2. package/LICENSE.md +1 -1
  3. package/dist/config-dir/I18NConfiguration.d.ts +26 -7
  4. package/dist/config-dir/I18NConfiguration.d.ts.map +1 -1
  5. package/dist/config-dir/I18NConfiguration.js +54 -28
  6. package/dist/config-dir/I18NConfiguration.js.map +1 -1
  7. package/dist/config-dir/TranslationManager.d.ts +26 -15
  8. package/dist/config-dir/TranslationManager.d.ts.map +1 -1
  9. package/dist/config-dir/TranslationManager.js +49 -18
  10. package/dist/config-dir/TranslationManager.js.map +1 -1
  11. package/dist/config-dir/loadTranslation.d.ts +3 -3
  12. package/dist/config-dir/loadTranslation.d.ts.map +1 -1
  13. package/dist/config-dir/loadTranslation.js +5 -22
  14. package/dist/config-dir/loadTranslation.js.map +1 -1
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js.map +1 -1
  17. package/dist/dictionary/getDictionary.d.ts.map +1 -1
  18. package/dist/dictionary/getDictionary.js.map +1 -1
  19. package/dist/index.server.d.ts +1 -1
  20. package/dist/index.server.d.ts.map +1 -1
  21. package/dist/index.types.d.ts +1 -1
  22. package/dist/index.types.js +4 -4
  23. package/dist/index.types.js.map +1 -1
  24. package/dist/provider/GTProvider.d.ts.map +1 -1
  25. package/dist/provider/GTProvider.js.map +1 -1
  26. package/dist/server-dir/buildtime/T.d.ts.map +1 -1
  27. package/dist/server-dir/buildtime/T.js +11 -6
  28. package/dist/server-dir/buildtime/T.js.map +1 -1
  29. package/dist/server-dir/buildtime/getGT.d.ts +2 -2
  30. package/dist/server-dir/buildtime/getGT.d.ts.map +1 -1
  31. package/dist/server-dir/buildtime/getGT.js +26 -20
  32. package/dist/server-dir/buildtime/getGT.js.map +1 -1
  33. package/dist/server-dir/buildtime/getTranslations.d.ts.map +1 -1
  34. package/dist/server-dir/buildtime/getTranslations.js +25 -17
  35. package/dist/server-dir/buildtime/getTranslations.js.map +1 -1
  36. package/dist/server-dir/runtime/_Tx.d.ts +24 -1
  37. package/dist/server-dir/runtime/_Tx.d.ts.map +1 -1
  38. package/dist/server-dir/runtime/_Tx.js +36 -12
  39. package/dist/server-dir/runtime/_Tx.js.map +1 -1
  40. package/dist/server-dir/runtime/tx.d.ts +1 -2
  41. package/dist/server-dir/runtime/tx.d.ts.map +1 -1
  42. package/dist/server-dir/runtime/tx.js +19 -17
  43. package/dist/server-dir/runtime/tx.js.map +1 -1
  44. package/dist/utils/errors.d.ts +11 -0
  45. package/dist/utils/errors.d.ts.map +1 -0
  46. package/dist/utils/errors.js +38 -0
  47. package/dist/utils/errors.js.map +1 -0
  48. package/dist/utils/types.d.ts +0 -1
  49. package/dist/utils/types.d.ts.map +1 -1
  50. package/dist/variables/Currency.d.ts +19 -2
  51. package/dist/variables/Currency.d.ts.map +1 -1
  52. package/dist/variables/Currency.js +20 -2
  53. package/dist/variables/Currency.js.map +1 -1
  54. package/dist/variables/DateTime.d.ts +19 -3
  55. package/dist/variables/DateTime.d.ts.map +1 -1
  56. package/dist/variables/DateTime.js +23 -20
  57. package/dist/variables/DateTime.js.map +1 -1
  58. package/dist/variables/Num.d.ts +7 -5
  59. package/dist/variables/Num.d.ts.map +1 -1
  60. package/dist/variables/Num.js +8 -5
  61. package/dist/variables/Num.js.map +1 -1
  62. package/dist/variables/Var.d.ts +2 -3
  63. package/dist/variables/Var.d.ts.map +1 -1
  64. package/dist/variables/Var.js +1 -1
  65. package/dist/variables/Var.js.map +1 -1
  66. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslations.js","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslations.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,0CA8JC;AAeD,0CAEC;AAnND,8CAK2B;AAE3B,iF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,QAAQ,CAAE,OAAO,EAAE,CAAC,KACxD,EAAE,IAAA,EACF,IAAI,MAAA,GACL;yBACF,CAAC,CAAC,KAAK,CAAC,cAAO,CAAC,CAAC,CAAC,CAAC,6BAA6B;wBAEjD,8BAA8B;wBAC9B,OAAO,CAAC,IAAI,CAAC,wCAAyB,CAAC,CAAC;wBAExC,mBAAmB;wBACnB,IAAI,cAAc,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;4BACxC,OAAO,aAAa,CAAC,KAAK,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;wBAC/C,CAAC;6BAAM,IAAI,cAAc,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;4BAChD,OAAO,EAAE,CAAC;wBACZ,CAAC;wBAED,qEAAqE;wBACrE,OAAO,aAAa,CAAC,KAAK,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;oBAC/C,CAAC,CAAC;oBAEF,sBAAO,CAAC,EAAC;;;;CACV;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAC,EAAW;IACzC,OAAO,IAAA,aAAG,EAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC"}
@@ -1,5 +1,28 @@
1
1
  import { TxProps } from '../../utils/types';
2
- declare function Tx({ children, id, context, locale }: TxProps): Promise<any>;
2
+ /**
3
+ * Runtime translation component that renders its children in the user's given locale.
4
+ *
5
+ * @example
6
+ * ```jsx
7
+ * // Basic usage:
8
+ * <Tx>
9
+ * Hello, {name}!
10
+ * </Tx>
11
+ * ```
12
+ *
13
+ * @example
14
+ * ```jsx
15
+ * // With a context:
16
+ * <Tx context="greeting">
17
+ * Hello, {name}!
18
+ * </Tx>
19
+ * ```
20
+ *
21
+ * @param {string} [context] - A context for the translation.
22
+ * @param {string} [locale] - The locale to use for the translation.
23
+ * @returns {Promise<any>} The translated content.
24
+ */
25
+ declare function Tx({ children, context, locale }: TxProps): Promise<any>;
3
26
  declare namespace Tx {
4
27
  var gtTransformation: string;
5
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"_Tx.d.ts","sourceRoot":"","sources":["../../../src/server-dir/runtime/_Tx.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM5C,iBAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAyH1E;kBAzHc,EAAE;;;AA6HjB,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"_Tx.d.ts","sourceRoot":"","sources":["../../../src/server-dir/runtime/_Tx.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAyHtE;kBAzHc,EAAE;;;AA6HjB,eAAe,EAAE,CAAC"}
@@ -68,22 +68,45 @@ function Resolver(_a) {
68
68
  });
69
69
  });
70
70
  }
71
+ /**
72
+ * Runtime translation component that renders its children in the user's given locale.
73
+ *
74
+ * @example
75
+ * ```jsx
76
+ * // Basic usage:
77
+ * <Tx>
78
+ * Hello, {name}!
79
+ * </Tx>
80
+ * ```
81
+ *
82
+ * @example
83
+ * ```jsx
84
+ * // With a context:
85
+ * <Tx context="greeting">
86
+ * Hello, {name}!
87
+ * </Tx>
88
+ * ```
89
+ *
90
+ * @param {string} [context] - A context for the translation.
91
+ * @param {string} [locale] - The locale to use for the translation.
92
+ * @returns {Promise<any>} The translated content.
93
+ */
71
94
  function Tx(_a) {
72
95
  return __awaiter(this, arguments, void 0, function (_b) {
73
- var I18NConfig, _c, defaultLocale, _d, translationRequired, dialectTranslationRequired, taggedChildren, renderDefault, childrenAsObjects, hash, translationEntry, renderTranslation, renderSettings, translationPromise, loadingFallback;
96
+ var I18NConfig, _c, defaultLocale, _d, translationRequired, dialectTranslationRequired, taggedChildren, renderDefault, childrenAsObjects, hash, translationEntry, translationsStatusEntry, renderTranslation, renderSettings, translationPromise, loadingFallback;
74
97
  var _this = this;
75
- var _e;
76
- var children = _b.children, id = _b.id, context = _b.context, locale = _b.locale;
77
- return __generator(this, function (_f) {
78
- switch (_f.label) {
98
+ var _e, _f;
99
+ var children = _b.children, context = _b.context, locale = _b.locale;
100
+ return __generator(this, function (_g) {
101
+ switch (_g.label) {
79
102
  case 0:
80
103
  I18NConfig = (0, getI18NConfig_1.default)();
81
104
  _c = locale;
82
105
  if (_c) return [3 /*break*/, 2];
83
106
  return [4 /*yield*/, (0, getLocale_1.getLocale)()];
84
107
  case 1:
85
- _c = (locale = _f.sent());
86
- _f.label = 2;
108
+ _c = (locale = _g.sent());
109
+ _g.label = 2;
87
110
  case 2:
88
111
  _c;
89
112
  defaultLocale = I18NConfig.getDefaultLocale();
@@ -104,8 +127,9 @@ function Tx(_a) {
104
127
  return [2 /*return*/, renderDefault()];
105
128
  }
106
129
  childrenAsObjects = (0, internal_1.writeChildrenAsObjects)(taggedChildren);
107
- hash = (0, id_1.hashJsxChildren)(__assign(__assign(__assign({ source: childrenAsObjects }, (context && { context: context })), (id && { id: id })), { dataFormat: 'JSX' }));
130
+ hash = (0, id_1.hashSource)(__assign(__assign({ source: childrenAsObjects }, (context && { context: context })), { dataFormat: 'JSX' }));
108
131
  translationEntry = (_e = I18NConfig.getRecentTranslations(locale)) === null || _e === void 0 ? void 0 : _e[hash];
132
+ translationsStatusEntry = (_f = I18NConfig.getCachedTranslationsStatus(locale)) === null || _f === void 0 ? void 0 : _f[hash];
109
133
  renderTranslation = function (target) {
110
134
  return (0, internal_1.renderTranslatedChildren)({
111
135
  source: taggedChildren,
@@ -116,10 +140,10 @@ function Tx(_a) {
116
140
  };
117
141
  // ----- RENDER CACHED TRANSLATIONS ----- //
118
142
  // if we have a cached translation, render it
119
- if ((translationEntry === null || translationEntry === void 0 ? void 0 : translationEntry.state) === 'success') {
120
- return [2 /*return*/, renderTranslation(translationEntry.target)];
143
+ if ((translationsStatusEntry === null || translationsStatusEntry === void 0 ? void 0 : translationsStatusEntry.status) === 'success') {
144
+ return [2 /*return*/, renderTranslation(translationEntry)];
121
145
  }
122
- if ((translationEntry === null || translationEntry === void 0 ? void 0 : translationEntry.state) === 'error') {
146
+ if ((translationsStatusEntry === null || translationsStatusEntry === void 0 ? void 0 : translationsStatusEntry.status) === 'error') {
123
147
  return [2 /*return*/, renderDefault()];
124
148
  }
125
149
  // ----- TRANSLATE ON DEMAND ----- //
@@ -138,7 +162,7 @@ function Tx(_a) {
138
162
  // do on demand translation
139
163
  source: childrenAsObjects,
140
164
  targetLocale: locale,
141
- options: __assign(__assign(__assign(__assign({}, (id && { id: id })), { hash: hash }), (context && { context: context })), (renderSettings.timeout && { timeout: renderSettings.timeout })),
165
+ options: __assign(__assign({ hash: hash }, (context && { context: context })), (renderSettings.timeout && { timeout: renderSettings.timeout })),
142
166
  })];
143
167
  case 1:
144
168
  target = _b.sent();
@@ -1 +1 @@
1
- {"version":3,"file":"_Tx.js","sourceRoot":"","sources":["../../../src/server-dir/runtime/_Tx.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iFAA2D;AAC3D,qDAAoD;AACpD,+BAAiC;AACjC,8CAO2B;AAC3B,+EAAyD;AAEzD,4CAAwD;AAGxD,SAAe,QAAQ;wDAAC,EAA2C;YAAzC,QAAQ,cAAA;;;wBACzB,qBAAM,QAAQ,EAAA;wBAArB,sBAAO,SAAc,EAAC;;;;CACvB;AAED,SAAe,EAAE;wDAAC,EAA0C;;;;YAAxC,QAAQ,cAAA,EAAE,EAAE,QAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA;;;;oBAGzC,UAAU,GAAG,IAAA,uBAAa,GAAE,CAAC;oBACnC,KAAA,MAA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,EAAE,CAAC,gBAAgB,GAAG,kBAAkB,CAAC;AAEzC,kBAAe,EAAE,CAAC"}
@@ -9,7 +9,6 @@ import { RuntimeTranslationOptions } from 'gt-react/internal';
9
9
  *
10
10
  * @param {string} content - The content string that needs to be translated.
11
11
  * @param {Object} [options] - Translation options.
12
- * @param {string} [options.id] - A unique identifier for the content, used for caching and fetching translations.
13
12
  * @param {string} [options.locale] - The target locale for translation. Defaults to the current locale if not provided.
14
13
  * @param {string} [options.context] - Additional context for the translation process, which may influence the translation's outcome.
15
14
  * @param {Object} [options.variables] - An optional map of variables to be injected into the translated content.
@@ -31,5 +30,5 @@ import { RuntimeTranslationOptions } from 'gt-react/internal';
31
30
  * // Using variables in the content string
32
31
  * const translation = await tx("The price is {price}", { locale: 'es-MX', variables: { price: 29.99 } });
33
32
  */
34
- export default function tx(string: string, options?: RuntimeTranslationOptions): Promise<string>;
33
+ export default function tx(message: string, options?: RuntimeTranslationOptions): Promise<string>;
35
34
  //# sourceMappingURL=tx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/server-dir/runtime/tx.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAA8B,EAAE,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,MAAM,CAAC,CA2DjB"}
1
+ {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/server-dir/runtime/tx.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAA8B,EAAE,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,MAAM,CAAC,CAwDjB"}
@@ -66,7 +66,6 @@ var id_1 = require("generaltranslation/id");
66
66
  *
67
67
  * @param {string} content - The content string that needs to be translated.
68
68
  * @param {Object} [options] - Translation options.
69
- * @param {string} [options.id] - A unique identifier for the content, used for caching and fetching translations.
70
69
  * @param {string} [options.locale] - The target locale for translation. Defaults to the current locale if not provided.
71
70
  * @param {string} [options.context] - Additional context for the translation process, which may influence the translation's outcome.
72
71
  * @param {Object} [options.variables] - An optional map of variables to be injected into the translated content.
@@ -88,15 +87,15 @@ var id_1 = require("generaltranslation/id");
88
87
  * // Using variables in the content string
89
88
  * const translation = await tx("The price is {price}", { locale: 'es-MX', variables: { price: 29.99 } });
90
89
  */
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;
90
+ function tx(message_1) {
91
+ return __awaiter(this, arguments, void 0, function (message, options) {
92
+ var I18NConfig, locale, _a, defaultLocale, translationRequired, renderContent, hash, recentTranslations, translationsStatus, target, error_1;
94
93
  var _b;
95
94
  if (options === void 0) { options = {}; }
96
95
  return __generator(this, function (_c) {
97
96
  switch (_c.label) {
98
97
  case 0:
99
- if (!string || typeof string !== 'string')
98
+ if (!message || typeof message !== 'string')
100
99
  return [2 /*return*/, ''];
101
100
  I18NConfig = (0, getI18NConfig_1.default)();
102
101
  _a = options.locale;
@@ -109,17 +108,20 @@ function tx(string_1) {
109
108
  locale = _a;
110
109
  defaultLocale = I18NConfig.getDefaultLocale();
111
110
  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);
111
+ renderContent = function (message, locales) {
112
+ return (0, generaltranslation_1.formatMessage)(message, {
113
+ locales: locales,
114
+ variables: options.variables,
115
+ });
115
116
  };
116
117
  // ----- CHECK IF TRANSLATION REQUIRED ----- //
117
118
  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' }));
119
+ return [2 /*return*/, renderContent(message, [defaultLocale])];
120
+ hash = (0, id_1.hashSource)(__assign(__assign({ source: message }, ((options === null || options === void 0 ? void 0 : options.context) && { context: options.context })), { dataFormat: 'ICU' }));
120
121
  recentTranslations = I18NConfig.getRecentTranslations(locale);
121
- if (((_b = recentTranslations === null || recentTranslations === void 0 ? void 0 : recentTranslations[hash]) === null || _b === void 0 ? void 0 : _b.state) === 'success') {
122
- return [2 /*return*/, renderContent(recentTranslations[hash].target, [
122
+ translationsStatus = I18NConfig.getCachedTranslationsStatus(locale);
123
+ if (((_b = translationsStatus === null || translationsStatus === void 0 ? void 0 : translationsStatus[hash]) === null || _b === void 0 ? void 0 : _b.status) === 'success') {
124
+ return [2 /*return*/, renderContent(recentTranslations[hash], [
123
125
  locale,
124
126
  defaultLocale,
125
127
  ])];
@@ -127,18 +129,18 @@ function tx(string_1) {
127
129
  _c.label = 3;
128
130
  case 3:
129
131
  _c.trys.push([3, 5, , 6]);
130
- return [4 /*yield*/, I18NConfig.translateContent({
131
- source: source,
132
+ return [4 /*yield*/, I18NConfig.translateIcu({
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), 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,qDAAoD;AACpD,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,qBAAS,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,EAAE,OAAiB;wBACpD,OAAO,IAAA,0CAAqB,EAC1B,OAAO,EACP,OAAO,EACP,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,gBAAgB,CACzB,CAAC;oBACJ,CAAC,CAAC;oBAEF,+CAA+C;oBAE/C,IAAI,CAAC,mBAAmB;wBAAE,sBAAO,aAAa,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,CAAC,EAAC;oBAIlE,IAAI,GAAG,IAAA,oBAAe,+BAC1B,MAAM,QAAA,IAC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AAI,CAAA,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,IAAI,CAAC,0CAAE,MAAM,MAAK,SAAS,EAAE,CAAC;wBACrD,sBAAO,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAW,EAAE;gCACvD,MAAM;gCACN,aAAa;6BACd,CAAC,EAAC;oBACL,CAAC;;;;oBAMiB,qBAAM,UAAU,CAAC,YAAY,CAAC;4BAC5C,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,CAAC,EAAE,OAAK,CAAC,CAAC;oBAC5D,sBAAO,aAAa,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,EAAC;;;;;CAElD"}
@@ -0,0 +1,11 @@
1
+ export declare class GTTranslationError extends Error {
2
+ error: string;
3
+ code: number;
4
+ constructor(error: string, code: number);
5
+ toTranslationError(): {
6
+ state: string;
7
+ error: string;
8
+ code: number;
9
+ };
10
+ }
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;IAElC,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;gBADZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM;IAMrB,kBAAkB;;;;;CAOnB"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.GTTranslationError = void 0;
19
+ var GTTranslationError = /** @class */ (function (_super) {
20
+ __extends(GTTranslationError, _super);
21
+ function GTTranslationError(error, code) {
22
+ var _this = _super.call(this, error) || this;
23
+ _this.error = error;
24
+ _this.code = code;
25
+ _this.code = code;
26
+ return _this;
27
+ }
28
+ GTTranslationError.prototype.toTranslationError = function () {
29
+ return {
30
+ state: 'error',
31
+ error: this.error,
32
+ code: this.code,
33
+ };
34
+ };
35
+ return GTTranslationError;
36
+ }(Error));
37
+ exports.GTTranslationError = GTTranslationError;
38
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;IAAwC,sCAAK;IAC3C,4BACS,KAAa,EACb,IAAY;QAEnB,YAAA,MAAK,YAAC,KAAK,CAAC,SAAC;QAHN,WAAK,GAAL,KAAK,CAAQ;QACb,UAAI,GAAJ,IAAI,CAAQ;QAGnB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IAED,+CAAkB,GAAlB;QACE,OAAO;YACL,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;IACH,yBAAC;AAAD,CAAC,AAhBD,CAAwC,KAAK,GAgB5C;AAhBY,gDAAkB"}
@@ -6,7 +6,6 @@ export type GTProviderProps = {
6
6
  };
7
7
  export type TxProps = {
8
8
  children: any;
9
- id?: string;
10
9
  context?: string;
11
10
  locale?: string;
12
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -1,10 +1,27 @@
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 | null | undefined} 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
+ */
1
18
  declare function Currency({ children, currency, locales, options, }: {
2
- children?: React.ReactNode;
19
+ children: number | string | null | undefined;
3
20
  currency?: string;
4
21
  name?: string;
5
22
  options?: Intl.NumberFormatOptions;
6
23
  locales?: string[];
7
- }): React.JSX.Element;
24
+ }): React.JSX.Element | null;
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,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,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,CAgBpB;kBA3BQ,QAAQ;;;AA+BjB,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,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,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,GAAG,IAAI,CAmB3B;kBA9BQ,QAAQ;;;AAkCjB,eAAe,QAAQ,CAAC"}
@@ -15,19 +15,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var jsx_runtime_1 = require("react/jsx-runtime");
18
- var generaltranslation_1 = require("generaltranslation");
19
18
  var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
20
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 | null | undefined} 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
+ */
21
36
  function Currency(_a) {
22
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 (!children)
39
+ return null;
23
40
  if (!locales) {
24
41
  locales = [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()];
25
42
  }
43
+ var gt = (0, getI18NConfig_1.default)().getGTClass();
26
44
  // Determine the value to be formatted
27
45
  var renderedValue = typeof children === 'string' ? parseFloat(children) : children;
28
46
  // Format the number as currency according to the locale
29
47
  var formattedValue = typeof renderedValue === 'number'
30
- ? (0, generaltranslation_1.formatCurrency)(renderedValue, currency, __assign({ locales: locales }, options))
48
+ ? gt.formatCurrency(renderedValue, currency, __assign({ locales: locales }, options))
31
49
  : renderedValue;
32
50
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue });
33
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Currency.js","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAoD;AACpD,8EAAwD;AACxD,kDAAiD;AAEjD,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,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,IAAA,mCAAc,EAAC,aAAa,EAAE,QAAQ,aAAI,OAAO,SAAA,IAAK,OAAO,EAAG;QAClE,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
+ {"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,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,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,25 @@
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 | null | undefined} 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
+ */
1
18
  declare function DateTime({ children, locales, options, }: {
2
- children?: React.ReactNode;
3
- name?: string;
19
+ children: Date | null | undefined;
4
20
  options?: Intl.DateTimeFormatOptions;
5
21
  locales?: string[];
6
- }): React.JSX.Element;
22
+ }): React.JSX.Element | null;
7
23
  declare namespace DateTime {
8
24
  var gtTransformation: string;
9
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAIA,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,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,CA6BpB;kBAtCQ,QAAQ;;;AA0CjB,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,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAY3B;kBApBQ,QAAQ;;;AAwBjB,eAAe,QAAQ,CAAC"}
@@ -15,33 +15,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var jsx_runtime_1 = require("react/jsx-runtime");
18
- var generaltranslation_1 = require("generaltranslation");
19
18
  var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
20
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 | null | undefined} 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
+ */
21
36
  function DateTime(_a) {
22
37
  var children = _a.children, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
38
+ if (!children)
39
+ return null;
23
40
  if (!locales) {
24
41
  locales = [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()];
25
42
  }
26
- var final;
27
- var dateValue;
28
- var defaultValue = children;
29
- if (typeof defaultValue === 'number') {
30
- dateValue = new Date(defaultValue);
31
- }
32
- else if (typeof defaultValue === 'string') {
33
- dateValue = new Date(defaultValue);
34
- }
35
- else if (defaultValue instanceof Date) {
36
- dateValue = defaultValue;
37
- }
38
- if (typeof dateValue !== 'undefined' && isNaN(dateValue.getTime())) {
39
- throw new Error("DateTime Error -- Invalid date format: \"".concat(defaultValue, "\". Please use a Date object, valid date string, or number."));
40
- }
41
- if (typeof dateValue !== 'undefined') {
42
- final = (0, generaltranslation_1.formatDateTime)(dateValue, __assign({ locales: locales }, options)).replace(/[\u200F\u202B\u202E]/g, '');
43
- }
44
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: final });
43
+ var gt = (0, getI18NConfig_1.default)().getGTClass();
44
+ var result = gt
45
+ .formatDateTime(children, __assign({ locales: locales }, options))
46
+ .replace(/[\u200F\u202B\u202E]/g, '');
47
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: result });
45
48
  }
46
49
  DateTime.gtTransformation = 'variable-datetime';
47
50
  exports.default = DateTime;
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAoD;AACpD,8EAAwD;AACxD,kDAA4D;AAE5D,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,IAAI,KAAK,CAAC;IACV,IAAI,SAA2B,CAAC;IAChC,IAAM,YAAY,GAAG,QAAQ,CAAC;IAC9B,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACrC,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;SAAM,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC5C,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;SAAM,IAAI,YAAY,YAAY,IAAI,EAAE,CAAC;QACxC,SAAS,GAAG,YAAY,CAAC;IAC3B,C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gB,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 | null | undefined} 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
- * @returns {Promise<React.JSX.Element>} The formatted number component.
18
+ * @returns {React.JSX.Element} The formatted number component.
17
19
  */
18
- declare function Num({ children, name, locales, options, }: {
19
- children?: React.ReactNode;
20
+ declare function Num({ children, locales, options, }: {
21
+ children: number | string | null | undefined;
20
22
  name?: string;
21
23
  options?: Intl.NumberFormatOptions;
22
24
  locales?: string[];
23
- }): React.JSX.Element;
25
+ }): React.JSX.Element | null;
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,iBAAS,GAAG,CAAC,EACX,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,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,CAgBpB;kBA1BQ,GAAG;;;AA8BZ,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,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,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,GAAG,IAAI,CAkB3B;kBA3BQ,GAAG;;;AA+BZ,eAAe,GAAG,CAAC"}
@@ -15,7 +15,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var jsx_runtime_1 = require("react/jsx-runtime");
18
- var generaltranslation_1 = require("generaltranslation");
19
18
  var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
20
19
  var getLocale_1 = require("../request/getLocale");
21
20
  /**
@@ -31,20 +30,24 @@ var getLocale_1 = require("../request/getLocale");
31
30
  * </Num>
32
31
  * ```
33
32
  *
34
- * @param {any} [children] - Optional content (typically a number) to render inside the component.
33
+ * @param {number | string | null | undefined} children - Content to render inside the number component.
34
+ * @param {string[]} [locales] - Optional locales to use for number formatting. If not provided, the library will default to the user's locale.
35
35
  * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
36
- * @returns {Promise<React.JSX.Element>} The formatted number component.
36
+ * @returns {React.JSX.Element} The formatted number component.
37
37
  */
38
38
  function Num(_a) {
39
- var children = _a.children, name = _a.name, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
39
+ var children = _a.children, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
40
+ if (!children)
41
+ return null;
40
42
  if (!locales) {
41
43
  locales = [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()];
42
44
  }
45
+ var gt = (0, getI18NConfig_1.default)().getGTClass();
43
46
  // Determine the value to be used
44
47
  var renderedValue = typeof children === 'string' ? parseFloat(children) : children;
45
48
  // Format the number according to the locale
46
49
  var formattedValue = typeof renderedValue === 'number'
47
- ? (0, generaltranslation_1.formatNum)(renderedValue, __assign({ locales: locales }, options))
50
+ ? gt.formatNum(renderedValue, __assign({ locales: locales }, options))
48
51
  : renderedValue;
49
52
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue });
50
53
  }