gt-next 2.0.2 → 2.0.4
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/dist/branches/Plural.d.ts +3 -2
- package/dist/branches/Plural.d.ts.map +1 -1
- package/dist/branches/Plural.js +4 -53
- package/dist/branches/Plural.js.map +1 -1
- package/dist/config/I18NConfiguration.d.ts.map +1 -1
- package/dist/config/I18NConfiguration.js +3 -4
- package/dist/config/I18NConfiguration.js.map +1 -1
- package/dist/index.client.d.ts +2 -2
- package/dist/index.client.d.ts.map +1 -1
- package/dist/index.client.js +2 -2
- package/dist/index.client.js.map +1 -1
- package/dist/index.server.d.ts +2 -2
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +2 -3
- package/dist/index.server.js.map +1 -1
- package/dist/provider/ClientProvider.js +5 -4
- package/dist/provider/ClientProvider.js.map +1 -1
- package/dist/provider/GTProvider.js +83 -79
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/server/getGT.d.ts +12 -11
- package/dist/server/getGT.d.ts.map +1 -1
- package/dist/server/getGT.js +212 -48
- package/dist/server/getGT.js.map +1 -1
- package/dist/server/rendering/renderVariable.d.ts +2 -1
- package/dist/server/rendering/renderVariable.d.ts.map +1 -1
- package/dist/server/rendering/renderVariable.js +4 -4
- package/dist/server/rendering/renderVariable.js.map +1 -1
- package/dist/server.d.ts +2 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/variables/Currency.d.ts +3 -2
- package/dist/variables/Currency.d.ts.map +1 -1
- package/dist/variables/Currency.js +10 -57
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.d.ts +3 -2
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/DateTime.js +26 -71
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.d.ts +3 -2
- package/dist/variables/Num.d.ts.map +1 -1
- package/dist/variables/Num.js +10 -57
- package/dist/variables/Num.js.map +1 -1
- 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 +2 -2
- package/dist/server/createServerTFunction.d.ts +0 -2
- package/dist/server/createServerTFunction.d.ts.map +0 -1
- package/dist/server/createServerTFunction.js +0 -62
- package/dist/server/createServerTFunction.js.map +0 -1
- package/dist/server/rendering/renderDefaultChildren.d.ts +0 -1
- package/dist/server/rendering/renderDefaultChildren.d.ts.map +0 -1
- package/dist/server/rendering/renderDefaultChildren.js +0 -91
- package/dist/server/rendering/renderDefaultChildren.js.map +0 -1
- package/dist/server/rendering/renderTranslatedChildren.d.ts +0 -1
- package/dist/server/rendering/renderTranslatedChildren.d.ts.map +0 -1
- package/dist/server/rendering/renderTranslatedChildren.js +0 -233
- package/dist/server/rendering/renderTranslatedChildren.js.map +0 -1
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
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);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
39
3
|
var t = {};
|
|
40
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -53,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
18
|
var generaltranslation_1 = require("generaltranslation");
|
|
55
19
|
var getI18NConfig_1 = __importDefault(require("../utils/getI18NConfig"));
|
|
56
|
-
var getLocale_1 = __importDefault(require("../request/getLocale"));
|
|
57
20
|
/**
|
|
58
21
|
* The `<DateTime>` component renders a formatted date or time string, allowing customization of the name, default value, and formatting options.
|
|
59
22
|
* It utilizes the current locale and optional format settings to display the date.
|
|
@@ -74,40 +37,32 @@ var getLocale_1 = __importDefault(require("../request/getLocale"));
|
|
|
74
37
|
* @returns {Promise<JSX.Element>} The formatted date or time component.
|
|
75
38
|
*/
|
|
76
39
|
function DateTime(_a) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
dateString = dateValue ? (0, generaltranslation_1.formatDateTime)({ value: dateValue, locales: locales, options: options }) : '';
|
|
105
|
-
formattedValue = dateString.replace(/[\u200F\u202B\u202E]/g, '');
|
|
106
|
-
// Render the formatted date within a span element
|
|
107
|
-
return [2 /*return*/, ((0, jsx_runtime_1.jsx)("span", { "data-_gt": generaltranslation, "data-_gt-variable-name": name, "data-_gt-variable-type": "date", "data-_gt-variable-options": JSON.stringify(options), "data-_gt-unformatted-value": isValidDate(dateValue) ? dateValue : undefined, style: { display: 'contents' }, children: formattedValue }))];
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
40
|
+
var children = _a.children, name = _a.name, value = _a.value, _b = _a.options, options = _b === void 0 ? {} : _b, _c = _a.locales, locales = _c === void 0 ? [(0, getI18NConfig_1.default)().getDefaultLocale()] : _c, props = __rest(_a, ["children", "name", "value", "options", "locales"]);
|
|
41
|
+
// Extract general translation data from props
|
|
42
|
+
var generaltranslation = props["data-_gt"];
|
|
43
|
+
// Determine the default value to use
|
|
44
|
+
if (typeof children !== 'undefined' && typeof value === 'undefined') {
|
|
45
|
+
value = children;
|
|
46
|
+
}
|
|
47
|
+
if (!value) {
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt": generaltranslation, "data-_gt-variable-name": name, "data-_gt-variable-type": "date", "data-_gt-variable-options": options, style: { display: 'contents' } }));
|
|
49
|
+
}
|
|
50
|
+
// Convert value to a Date object if it's a Unix time, string, or Date object
|
|
51
|
+
var dateValue;
|
|
52
|
+
if (typeof value === 'number') {
|
|
53
|
+
dateValue = new Date(value * 1000); // Assuming Unix time is in seconds
|
|
54
|
+
}
|
|
55
|
+
else if (typeof value === 'string') {
|
|
56
|
+
dateValue = new Date(value);
|
|
57
|
+
}
|
|
58
|
+
else if (value instanceof Date) {
|
|
59
|
+
dateValue = value;
|
|
60
|
+
}
|
|
61
|
+
// Format the date according to the locale and options
|
|
62
|
+
var dateString = dateValue ? (0, generaltranslation_1.formatDateTime)({ value: dateValue, locales: locales, options: options }) : '';
|
|
63
|
+
var formattedValue = dateString.replace(/[\u200F\u202B\u202E]/g, '');
|
|
64
|
+
// Render the formatted date within a span element
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt": generaltranslation, "data-_gt-variable-name": name, "data-_gt-variable-type": "date", "data-_gt-variable-options": JSON.stringify(options), "data-_gt-unformatted-value": isValidDate(dateValue) ? dateValue : undefined, style: { display: 'contents' }, children: formattedValue }));
|
|
111
66
|
}
|
|
112
67
|
;
|
|
113
68
|
DateTime.gtTransformation = "variable-datetime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"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GAAG,SAAS,CAAC,CAAC,CAAC,IAAA,mCAAc,EAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3F,IAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAA;IAEtE,kDAAkD;IAClD,OAAO,CACH,6CACc,kBAAkB,4BACJ,IAAI,4BACJ,MAAM,+BACH,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gCACtB,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAC1E,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE7B,cAAc,GACZ,CACV,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAA;AAE/C,kBAAe,QAAQ,CAAC;AAExB;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAU;IAC3B,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/variables/Num.d.ts
CHANGED
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
* @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
|
|
19
19
|
* @returns {Promise<JSX.Element>} The formatted number component.
|
|
20
20
|
*/
|
|
21
|
-
declare function Num({ children, name, value, options, ...props }: {
|
|
21
|
+
declare function Num({ children, name, value, options, locales, ...props }: {
|
|
22
22
|
children?: any;
|
|
23
23
|
name?: string;
|
|
24
24
|
value?: any;
|
|
25
25
|
options?: Intl.NumberFormatOptions;
|
|
26
|
+
locales?: string[];
|
|
26
27
|
'data-_gt'?: any;
|
|
27
|
-
}):
|
|
28
|
+
}): JSX.Element;
|
|
28
29
|
declare namespace Num {
|
|
29
30
|
var gtTransformation: string;
|
|
30
31
|
}
|
|
@@ -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":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,GAAG,CAAC,EACT,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,OAAY,EACZ,OAA8C,EAC9C,GAAG,KAAK,EACX,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,CAAC,EAAE,GAAG,CAAA;CACnB,GAAG,GAAG,CAAC,OAAO,CA0Bd;kBAxCQ,GAAG;;;AA4CZ,eAAe,GAAG,CAAC"}
|
package/dist/variables/Num.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
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);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
39
3
|
var t = {};
|
|
40
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -53,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
18
|
var generaltranslation_1 = require("generaltranslation");
|
|
55
19
|
var getI18NConfig_1 = __importDefault(require("../utils/getI18NConfig"));
|
|
56
|
-
var getLocale_1 = __importDefault(require("../request/getLocale"));
|
|
57
20
|
/**
|
|
58
21
|
* The `<Num>` component renders a formatted number string, allowing customization of the name, default value, and formatting options.
|
|
59
22
|
* It formats the number according to the current locale and optionally passed formatting options.
|
|
@@ -75,26 +38,16 @@ var getLocale_1 = __importDefault(require("../request/getLocale"));
|
|
|
75
38
|
* @returns {Promise<JSX.Element>} The formatted number component.
|
|
76
39
|
*/
|
|
77
40
|
function Num(_a) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
generaltranslation = props["data-_gt"];
|
|
89
|
-
renderedValue = (typeof children !== 'undefined' && typeof value === 'undefined') ? children : value;
|
|
90
|
-
renderedValue = (typeof renderedValue === 'string') ? parseFloat(renderedValue) : renderedValue;
|
|
91
|
-
formattedValue = (typeof renderedValue === 'number') ?
|
|
92
|
-
(0, generaltranslation_1.formatNum)({ value: renderedValue, locales: locales, options: options }) :
|
|
93
|
-
renderedValue;
|
|
94
|
-
return [2 /*return*/, ((0, jsx_runtime_1.jsx)("span", { "data-_gt": generaltranslation, "data-_gt-variable-name": name, "data-_gt-variable-type": "number", "data-_gt-variable-options": JSON.stringify(options), "data-_gt-unformatted-value": typeof renderedValue === 'number' && !isNaN(renderedValue) ? renderedValue : undefined, style: { display: 'contents' }, children: formattedValue }))];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
41
|
+
var children = _a.children, name = _a.name, value = _a.value, _b = _a.options, options = _b === void 0 ? {} : _b, _c = _a.locales, locales = _c === void 0 ? [(0, getI18NConfig_1.default)().getDefaultLocale()] : _c, props = __rest(_a, ["children", "name", "value", "options", "locales"]);
|
|
42
|
+
var generaltranslation = props["data-_gt"];
|
|
43
|
+
// Determine the value to be used
|
|
44
|
+
var renderedValue = (typeof children !== 'undefined' && typeof value === 'undefined') ? children : value;
|
|
45
|
+
renderedValue = (typeof renderedValue === 'string') ? parseFloat(renderedValue) : renderedValue;
|
|
46
|
+
// Format the number according to the locale
|
|
47
|
+
var formattedValue = (typeof renderedValue === 'number') ?
|
|
48
|
+
(0, generaltranslation_1.formatNum)({ value: renderedValue, locales: locales, options: options }) :
|
|
49
|
+
renderedValue;
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt": generaltranslation, "data-_gt-variable-name": name, "data-_gt-variable-type": "number", "data-_gt-variable-options": JSON.stringify(options), "data-_gt-unformatted-value": typeof renderedValue === 'number' && !isNaN(renderedValue) ? renderedValue : undefined, style: { display: 'contents' }, children: formattedValue }));
|
|
98
51
|
}
|
|
99
52
|
;
|
|
100
53
|
Num.gtTransformation = "variable-number";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAA+C;AAC/C,yEAAmD;AAEnD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,GAAG,CAAC,EAcZ;IAbG,IAAA,QAAQ,cAAA,EACR,IAAI,UAAA,EACJ,KAAK,WAAA,EACL,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EACZ,eAA8C,EAA9C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"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,GAAG,CAAC,EACT,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,GAAG,KAAK,EACX,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,GAAG,CAAA;CACnB,GAAG,GAAG,CAAC,OAAO,CAiBd;kBA3BQ,GAAG;;;AA+BZ,eAAe,GAAG,CAAC"}
|
package/dist/variables/Var.js
CHANGED
|
@@ -31,7 +31,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
31
31
|
* @returns {JSX.Element} The rendered variable component with either `children` or `value`.
|
|
32
32
|
*/
|
|
33
33
|
function Var(_a) {
|
|
34
|
-
var children = _a.children,
|
|
34
|
+
var children = _a.children, name = _a.name, value = _a.value, props = __rest(_a, ["children", "name", "value"]);
|
|
35
35
|
var generaltranslation = props["data-_gt"];
|
|
36
36
|
if (typeof children !== 'undefined' && typeof value === 'undefined')
|
|
37
37
|
value = children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Var.js","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Var.js","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,GAAG,CAAC,EAUZ;IATG,IAAA,QAAQ,cAAA,EACR,IAAI,UAAA,EACJ,KAAK,WAAA,EACF,KAAK,cAJC,6BAKZ,CADW;IAQA,IAAY,kBAAkB,GAAK,KAAK,YAAV,CAAW;IAEjD,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,KAAK,KAAK,WAAW;QAAE,KAAK,GAAG,QAAQ,CAAC;IAEtF,OAAO,CACH,6CACc,kBAAkB,4BACJ,IAAI,4BACJ,UAAU,EAClC,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE7B,KAAK,GACH,CACV,CAAC;AAEN,CAAC;AAAA,CAAC;AAEF,GAAG,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,CAAC,uDAAuD;AAEnG,kBAAe,GAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-next",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "A Next.js library for automatic internationalization.",
|
|
5
5
|
"main": "dist/index.server.js",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -121,6 +121,6 @@
|
|
|
121
121
|
"i18n"
|
|
122
122
|
],
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"gt-react": "^6.0.
|
|
124
|
+
"gt-react": "^6.0.9"
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createServerTFunction.d.ts","sourceRoot":"","sources":["../../src/server/createServerTFunction.tsx"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CACzC,QAAQ,CAAC,EAAE,MAAM,QAUT,MAAM,YACA,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MACzB,QAAQ,KACb,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,SAAS,CAiDtE"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.default = createServerTFunction;
|
|
18
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
var internal_1 = require("gt-react/internal");
|
|
20
|
-
var T_1 = __importDefault(require("./inline/T"));
|
|
21
|
-
var getDictionary_1 = __importDefault(require("../dictionary/getDictionary"));
|
|
22
|
-
var tx_1 = __importDefault(require("./strings/tx"));
|
|
23
|
-
function createServerTFunction(prefixID) {
|
|
24
|
-
var getID = function (id) {
|
|
25
|
-
return prefixID ? "".concat(prefixID, ".").concat(id) : id;
|
|
26
|
-
};
|
|
27
|
-
var dictionary = (0, getDictionary_1.default)();
|
|
28
|
-
return function (id, options, f) {
|
|
29
|
-
id = getID(id);
|
|
30
|
-
// Get entry
|
|
31
|
-
var _a = (0, internal_1.extractEntryMetadata)((0, internal_1.getDictionaryEntry)(dictionary, id)), entry = _a.entry, metadata = _a.metadata;
|
|
32
|
-
// Get variables and variable options
|
|
33
|
-
var variables;
|
|
34
|
-
var variablesOptions;
|
|
35
|
-
if (options) {
|
|
36
|
-
variables = options;
|
|
37
|
-
if (metadata === null || metadata === void 0 ? void 0 : metadata.variablesOptions) {
|
|
38
|
-
variablesOptions = metadata.variablesOptions;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Handle if the entry is a function
|
|
42
|
-
if (typeof f === 'function') {
|
|
43
|
-
entry = f(options);
|
|
44
|
-
}
|
|
45
|
-
else if (typeof entry === 'function') {
|
|
46
|
-
entry = entry(options);
|
|
47
|
-
}
|
|
48
|
-
if (!entry) {
|
|
49
|
-
console.warn("No entry found for id: \"".concat(id, "\""));
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
if (typeof entry === 'string') {
|
|
53
|
-
return (0, tx_1.default)(entry, {
|
|
54
|
-
id: id,
|
|
55
|
-
variables: variables,
|
|
56
|
-
variablesOptions: variablesOptions
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(T_1.default, __assign({ id: id, variables: variables, variablesOptions: variablesOptions }, metadata, { children: entry })));
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=createServerTFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createServerTFunction.js","sourceRoot":"","sources":["../../src/server/createServerTFunction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,wCA+DC;;AApED,8CAA6E;AAC7E,iDAA2B;AAC3B,8EAAwD;AACxD,oDAA8B;AAE9B,SAAwB,qBAAqB,CACzC,QAAiB;IAGjB,IAAM,KAAK,GAAG,UAAC,EAAU;QACrB,OAAO,QAAQ,CAAC,CAAC,CAAC,UAAG,QAAQ,cAAI,EAAE,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,CAAC,CAAA;IAED,IAAM,UAAU,GAAG,IAAA,uBAAa,GAAE,CAAC;IAEnC,OAAO,UACH,EAAU,EACV,OAA6B,EAC7B,CAAY;QAGZ,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QAEf,YAAY;QACR,IAAA,KAAsB,IAAA,+BAAoB,EAC1C,IAAA,6BAAkB,EAAC,UAAU,EAAE,EAAE,CAAC,CACrC,EAFK,KAAK,WAAA,EAAE,QAAQ,cAEpB,CAAC;QAEF,qCAAqC;QACrC,IAAI,SAAS,CAAC;QAAC,IAAI,gBAAgB,CAAC;QACpC,IAAI,OAAO,EAAE,CAAC;YACV,SAAS,GAAG,OAAO,CAAC;YACpB,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,EAAE,CAAC;gBAC7B,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;YACjD,CAAC;QACL,CAAC;QAED,oCAAoC;QACpC,IAAI,OAAO,CAAC,KAAK,UAAU,EAAE,CAAC;YAC1B,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YACrC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,OAAO,CAAC,IAAI,CAAC,mCAA2B,EAAE,OAAG,CAAC,CAAC;YAC/C,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,IAAA,YAAE,EAAC,KAAK,EAAE;gBACb,EAAE,IAAA;gBAAE,SAAS,WAAA;gBAAE,gBAAgB,kBAAA;aAClC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,CACH,uBAAC,WAAC,aACE,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,IAC9B,QAAQ,cAEX,KAAK,IACN,CACP,CAAA;IAEL,CAAC,CAAA;AAEL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=renderDefaultChildren.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderDefaultChildren.d.ts","sourceRoot":"","sources":["../../../src/server/rendering/renderDefaultChildren.tsx"],"names":[],"mappings":""}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*import React, { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import renderVariable from './renderVariable';
|
|
4
|
-
import { getFallbackVariableName, getPluralBranch, getVariableProps } from 'gt-react/internal';
|
|
5
|
-
import { libraryDefaultLocale } from 'generaltranslation/internal';
|
|
6
|
-
|
|
7
|
-
// Renders the children in the default locale, as they are supplied
|
|
8
|
-
// with variables substituted (for use by the dictionary)
|
|
9
|
-
export default function renderDefaultChildren({
|
|
10
|
-
children,
|
|
11
|
-
variables = {},
|
|
12
|
-
variablesOptions = {},
|
|
13
|
-
defaultLocale = libraryDefaultLocale,
|
|
14
|
-
}: {
|
|
15
|
-
children: ReactElement;
|
|
16
|
-
variables?: Record<string, any>;
|
|
17
|
-
variablesOptions?: Record<string, any>;
|
|
18
|
-
defaultLocale: string;
|
|
19
|
-
}) {
|
|
20
|
-
const handleSingleChild = (child: ReactNode) => {
|
|
21
|
-
if (React.isValidElement(child)) {
|
|
22
|
-
const { 'data-_gt': generaltranslation, ...props } = child.props;
|
|
23
|
-
if (generaltranslation?.transformation === 'variable') {
|
|
24
|
-
let {
|
|
25
|
-
variableName,
|
|
26
|
-
variableType,
|
|
27
|
-
variableValue,
|
|
28
|
-
variableOptions
|
|
29
|
-
} = getVariableProps(child.props);
|
|
30
|
-
variableValue = (() => {
|
|
31
|
-
if (typeof variables[variableName] !== 'undefined') {
|
|
32
|
-
return variables[variableName]
|
|
33
|
-
}
|
|
34
|
-
const fallbackVariableName = getFallbackVariableName(variableType);
|
|
35
|
-
if (typeof variables[fallbackVariableName] !== 'undefined') {
|
|
36
|
-
return variables[fallbackVariableName];
|
|
37
|
-
}
|
|
38
|
-
return undefined;
|
|
39
|
-
})();
|
|
40
|
-
variableOptions = {
|
|
41
|
-
...variablesOptions[variableName],
|
|
42
|
-
...variableOptions
|
|
43
|
-
} as Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
|
|
44
|
-
return renderVariable({
|
|
45
|
-
variableName, variableType, variableValue, variableOptions
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
if (generaltranslation?.transformation === 'plural') {
|
|
49
|
-
const n =
|
|
50
|
-
typeof variables.n === 'number'
|
|
51
|
-
? variables.n
|
|
52
|
-
: typeof props.n === 'number'
|
|
53
|
-
? props.n
|
|
54
|
-
: props['data-_gt-n'];
|
|
55
|
-
const branches = generaltranslation.branches || {};
|
|
56
|
-
return handleChildren(
|
|
57
|
-
getPluralBranch(n, [defaultLocale], branches) || child.props.children
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
if (generaltranslation?.transformation === 'branch') {
|
|
61
|
-
let { children, name, branch, 'data-_gt': _gt, ...branches } = props;
|
|
62
|
-
name = name || props['data-_gt-name'] || 'branch';
|
|
63
|
-
branch =
|
|
64
|
-
variables[name] || branch || child.props['data-_gt-branch-name'];
|
|
65
|
-
branches = generaltranslation.branches || {};
|
|
66
|
-
return handleChildren(
|
|
67
|
-
branches[branch] !== undefined ? branches[branch] : children
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
if (child.props.children) {
|
|
71
|
-
return React.cloneElement(child, {
|
|
72
|
-
...props,
|
|
73
|
-
'data-_gt': undefined,
|
|
74
|
-
children: handleChildren(child.props.children),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return React.cloneElement(child, { ...props, 'data-_gt': undefined });
|
|
78
|
-
}
|
|
79
|
-
return child;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const handleChildren = (children: ReactNode): ReactNode => {
|
|
83
|
-
return Array.isArray(children)
|
|
84
|
-
? React.Children.map(children, handleSingleChild)
|
|
85
|
-
: handleSingleChild(children);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
return handleChildren(children);
|
|
89
|
-
}
|
|
90
|
-
*/
|
|
91
|
-
//# sourceMappingURL=renderDefaultChildren.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderDefaultChildren.js","sourceRoot":"","sources":["../../../src/server/rendering/renderDefaultChildren.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwFE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=renderTranslatedChildren.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../../src/server/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":""}
|