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.
- package/CHANGELOG.md +0 -9
- package/LICENSE.md +1 -1
- package/dist/config-dir/I18NConfiguration.d.ts +26 -7
- package/dist/config-dir/I18NConfiguration.d.ts.map +1 -1
- package/dist/config-dir/I18NConfiguration.js +54 -28
- package/dist/config-dir/I18NConfiguration.js.map +1 -1
- package/dist/config-dir/TranslationManager.d.ts +26 -15
- package/dist/config-dir/TranslationManager.d.ts.map +1 -1
- package/dist/config-dir/TranslationManager.js +49 -18
- package/dist/config-dir/TranslationManager.js.map +1 -1
- package/dist/config-dir/loadTranslation.d.ts +3 -3
- package/dist/config-dir/loadTranslation.d.ts.map +1 -1
- package/dist/config-dir/loadTranslation.js +5 -22
- package/dist/config-dir/loadTranslation.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/dictionary/getDictionary.d.ts.map +1 -1
- package/dist/dictionary/getDictionary.js.map +1 -1
- package/dist/index.server.d.ts +1 -1
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.types.d.ts +1 -1
- package/dist/index.types.js +4 -4
- package/dist/index.types.js.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/server-dir/buildtime/T.d.ts.map +1 -1
- package/dist/server-dir/buildtime/T.js +11 -6
- package/dist/server-dir/buildtime/T.js.map +1 -1
- package/dist/server-dir/buildtime/getGT.d.ts +2 -2
- package/dist/server-dir/buildtime/getGT.d.ts.map +1 -1
- package/dist/server-dir/buildtime/getGT.js +26 -20
- package/dist/server-dir/buildtime/getGT.js.map +1 -1
- package/dist/server-dir/buildtime/getTranslations.d.ts.map +1 -1
- package/dist/server-dir/buildtime/getTranslations.js +25 -17
- package/dist/server-dir/buildtime/getTranslations.js.map +1 -1
- package/dist/server-dir/runtime/_Tx.d.ts +24 -1
- package/dist/server-dir/runtime/_Tx.d.ts.map +1 -1
- package/dist/server-dir/runtime/_Tx.js +36 -12
- package/dist/server-dir/runtime/_Tx.js.map +1 -1
- package/dist/server-dir/runtime/tx.d.ts +1 -2
- package/dist/server-dir/runtime/tx.d.ts.map +1 -1
- package/dist/server-dir/runtime/tx.js +19 -17
- package/dist/server-dir/runtime/tx.js.map +1 -1
- package/dist/utils/errors.d.ts +11 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +38 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/types.d.ts +0 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/variables/Currency.d.ts +19 -2
- package/dist/variables/Currency.d.ts.map +1 -1
- package/dist/variables/Currency.js +20 -2
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.d.ts +19 -3
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/DateTime.js +23 -20
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.d.ts +7 -5
- package/dist/variables/Num.d.ts.map +1 -1
- package/dist/variables/Num.js +8 -5
- package/dist/variables/Num.js.map +1 -1
- package/dist/variables/Var.d.ts +2 -3
- package/dist/variables/Var.d.ts.map +1 -1
- package/dist/variables/Var.js +1 -1
- package/dist/variables/Var.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslations.js","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslations.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getTranslations.js","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslations.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,0CA0JC;AAeD,0CAEC;AA5MD,8CAK2B;AAE3B,iFA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;wBACtB,UAAU,CAAC,YAAY,CAAC;4BACtB,MAAM,EAAE,KAAK;4BACb,YAAY,EAAE,MAAM;4BACpB,OAAO,wBACF,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,KAAI,EAAE,OAAO,EAAE,QAAQ,aAAR,QAAQ,uBAAR,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
|
-
|
|
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,
|
|
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,
|
|
77
|
-
return __generator(this, function (
|
|
78
|
-
switch (
|
|
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 =
|
|
86
|
-
|
|
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.
|
|
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 ((
|
|
120
|
-
return [2 /*return*/, renderTranslation(translationEntry
|
|
143
|
+
if ((translationsStatusEntry === null || translationsStatusEntry === void 0 ? void 0 : translationsStatusEntry.status) === 'success') {
|
|
144
|
+
return [2 /*return*/, renderTranslation(translationEntry)];
|
|
121
145
|
}
|
|
122
|
-
if ((
|
|
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(
|
|
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,
|
|
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,4CAAmD;AAGnD,SAAe,QAAQ;wDAAC,EAA2C;YAAzC,QAAQ,cAAA;;;wBACzB,qBAAM,QAAQ,EAAA;wBAArB,sBAAO,SAAc,EAAC;;;;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAe,EAAE;wDAAC,EAAsC;;;;YAApC,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA;;;;oBAGrC,UAAU,GAAG,IAAA,uBAAa,GAAE,CAAC;oBACnC,KAAA,MAAM,CAAA;4BAAN,wBAAM;oBAAK,qBAAM,IAAA,qBAAS,GAAE,EAAA;;0BAA5B,MAAM,GAAK,SAAiB;;;oBAA5B,GAA6B;oBACvB,aAAa,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;oBAC9C,KACJ,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,EADjC,mBAAmB,QAAA,EAAE,0BAA0B,QAAA,CACb;oBAInC,cAAc,GAAG,IAAA,0BAAe,EAAC,QAAQ,CAAC,CAAC;oBAK3C,aAAa,GAAG;wBACpB,OAAO,IAAA,gCAAqB,EAAC;4BAC3B,QAAQ,EAAE,cA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ationOptions } 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(
|
|
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":"
|
|
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(
|
|
92
|
-
return __awaiter(this, arguments, void 0, function (
|
|
93
|
-
var I18NConfig, locale, _a, defaultLocale, translationRequired,
|
|
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 (!
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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(
|
|
119
|
-
hash = (0, id_1.
|
|
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
|
-
|
|
122
|
-
|
|
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.
|
|
131
|
-
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)(
|
|
141
|
-
return [2 /*return*/, renderContent(
|
|
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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,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"}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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":"
|
|
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
|
-
?
|
|
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,
|
|
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
|
|
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":"
|
|
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
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8EAAwD;AACxD,kDAAiD;AAGjD;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ,CAAC,EAQjB;QAPC,QAAQ,cAAA,EACR,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IAMZ,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,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"}
|
package/dist/variables/Num.d.ts
CHANGED
|
@@ -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 {
|
|
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 {
|
|
18
|
+
* @returns {React.JSX.Element} The formatted number component.
|
|
17
19
|
*/
|
|
18
|
-
declare function Num({ children,
|
|
19
|
-
children
|
|
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":"
|
|
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"}
|
package/dist/variables/Num.js
CHANGED
|
@@ -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 {
|
|
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 {
|
|
36
|
+
* @returns {React.JSX.Element} The formatted number component.
|
|
37
37
|
*/
|
|
38
38
|
function Num(_a) {
|
|
39
|
-
var children = _a.children,
|
|
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
|
-
?
|
|
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
|
}
|