gt-react 3.0.11 → 3.0.12
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/client/ClientProvider.js +6 -10
- package/dist/client/ClientProvider.js.map +1 -1
- package/dist/client/GTProvider.js +9 -15
- package/dist/client/GTProvider.js.map +1 -1
- package/dist/client/createGTProviderComponent.js +4 -10
- package/dist/client/createGTProviderComponent.js.map +1 -1
- package/dist/client/hooks/useDefaultLocale.js +4 -7
- package/dist/client/hooks/useDefaultLocale.js.map +1 -1
- package/dist/client/hooks/useGT.js +5 -8
- package/dist/client/hooks/useGT.js.map +1 -1
- package/dist/client/hooks/useLocale.js +4 -7
- package/dist/client/hooks/useLocale.js.map +1 -1
- package/dist/client/primitives/numeric/ClientNumeric.d.ts.map +1 -1
- package/dist/client/primitives/numeric/ClientNumeric.js +15 -20
- package/dist/client/primitives/numeric/ClientNumeric.js.map +1 -1
- package/dist/client/primitives/value/ClientValue.js +10 -16
- package/dist/client/primitives/value/ClientValue.js.map +1 -1
- package/dist/client/primitives/value/RenderClientVariable.js +20 -49
- package/dist/client/primitives/value/RenderClientVariable.js.map +1 -1
- package/dist/client/primitives/variables/ClientCurrencyVariable.d.ts.map +1 -1
- package/dist/client/primitives/variables/ClientCurrencyVariable.js +11 -15
- package/dist/client/primitives/variables/ClientCurrencyVariable.js.map +1 -1
- package/dist/client/primitives/variables/ClientDateVariable.d.ts.map +1 -1
- package/dist/client/primitives/variables/ClientDateVariable.js +11 -16
- package/dist/client/primitives/variables/ClientDateVariable.js.map +1 -1
- package/dist/client/primitives/variables/ClientNumberVariable.d.ts.map +1 -1
- package/dist/client/primitives/variables/ClientNumberVariable.js +11 -15
- package/dist/client/primitives/variables/ClientNumberVariable.js.map +1 -1
- package/dist/client/primitives/variables/ClientVariable.js +5 -7
- package/dist/client/primitives/variables/ClientVariable.js.map +1 -1
- package/dist/client.js +10 -24
- package/dist/client.js.map +1 -1
- package/dist/config/I18NConfiguration.js +11 -40
- package/dist/config/I18NConfiguration.js.map +1 -1
- package/dist/config/LocalDictionaryManager.js +3 -6
- package/dist/config/LocalDictionaryManager.js.map +1 -1
- package/dist/config/RemoteDictionaryManager.js +1 -4
- package/dist/config/RemoteDictionaryManager.js.map +1 -1
- package/dist/config/determineLocale.js +3 -6
- package/dist/config/determineLocale.js.map +1 -1
- package/dist/dictionary/createDictFunction.js +1 -4
- package/dist/dictionary/createDictFunction.js.map +1 -1
- package/dist/dictionary/createTFunction.js +3 -6
- package/dist/dictionary/createTFunction.js.map +1 -1
- package/dist/dictionary/getDictionaryEntry.js +1 -4
- package/dist/dictionary/getDictionaryEntry.js.map +1 -1
- package/dist/index.js +38 -45
- package/dist/index.js.map +1 -1
- package/dist/intl/createIntlFunction.js +1 -4
- package/dist/intl/createIntlFunction.js.map +1 -1
- package/dist/local/getDefaultFromEnv.js +1 -4
- package/dist/local/getDefaultFromEnv.js.map +1 -1
- package/dist/middleware/createNextMiddleware.js +13 -16
- package/dist/middleware/createNextMiddleware.js.map +1 -1
- package/dist/middleware.js +2 -8
- package/dist/middleware.js.map +1 -1
- package/dist/next/imports/imports.js +5 -12
- package/dist/next/imports/imports.js.map +1 -1
- package/dist/next/requestFunctions.js +8 -15
- package/dist/next/requestFunctions.js.map +1 -1
- package/dist/next.js +9 -13
- package/dist/next.js.map +1 -1
- package/dist/primitives/helpers/defaultVariableNames.js +1 -3
- package/dist/primitives/helpers/defaultVariableNames.js.map +1 -1
- package/dist/primitives/helpers/getNumericBranch.d.ts +1 -1
- package/dist/primitives/helpers/getNumericBranch.d.ts.map +1 -1
- package/dist/primitives/helpers/getNumericBranch.js +4 -7
- package/dist/primitives/helpers/getNumericBranch.js.map +1 -1
- package/dist/primitives/helpers/getValueBranch.js +4 -10
- package/dist/primitives/helpers/getValueBranch.js.map +1 -1
- package/dist/primitives/helpers/isValidReactNode.js +3 -9
- package/dist/primitives/helpers/isValidReactNode.js.map +1 -1
- package/dist/primitives/numeric/Numeric.d.ts +2 -2
- package/dist/primitives/numeric/Numeric.d.ts.map +1 -1
- package/dist/primitives/numeric/Numeric.js +9 -15
- package/dist/primitives/numeric/Numeric.js.map +1 -1
- package/dist/primitives/numeric/createNumericComponent.d.ts +1 -1
- package/dist/primitives/numeric/createNumericComponent.d.ts.map +1 -1
- package/dist/primitives/numeric/createNumericComponent.js +5 -11
- package/dist/primitives/numeric/createNumericComponent.js.map +1 -1
- package/dist/primitives/private/Private.js +3 -5
- package/dist/primitives/private/Private.js.map +1 -1
- package/dist/primitives/private/createPrivateComponent.js +3 -9
- package/dist/primitives/private/createPrivateComponent.js.map +1 -1
- package/dist/primitives/value/Value.d.ts +2 -2
- package/dist/primitives/value/Value.d.ts.map +1 -1
- package/dist/primitives/value/Value.js +9 -14
- package/dist/primitives/value/Value.js.map +1 -1
- package/dist/primitives/value/createValueComponent.d.ts +1 -1
- package/dist/primitives/value/createValueComponent.d.ts.map +1 -1
- package/dist/primitives/value/createValueComponent.js +5 -11
- package/dist/primitives/value/createValueComponent.js.map +1 -1
- package/dist/primitives/value/processBranches.js +4 -10
- package/dist/primitives/value/processBranches.js.map +1 -1
- package/dist/primitives/value/renderVariable.d.ts +1 -1
- package/dist/primitives/value/renderVariable.d.ts.map +1 -1
- package/dist/primitives/value/renderVariable.js +21 -27
- package/dist/primitives/value/renderVariable.js.map +1 -1
- package/dist/primitives/variables/CurrencyVariable/CurrencyVariable.d.ts +2 -2
- package/dist/primitives/variables/CurrencyVariable/CurrencyVariable.d.ts.map +1 -1
- package/dist/primitives/variables/CurrencyVariable/CurrencyVariable.js +5 -7
- package/dist/primitives/variables/CurrencyVariable/CurrencyVariable.js.map +1 -1
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.d.ts +1 -1
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.d.ts.map +1 -1
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.js +5 -11
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.js.map +1 -1
- package/dist/primitives/variables/DateVariable/DateVariable.d.ts +2 -2
- package/dist/primitives/variables/DateVariable/DateVariable.d.ts.map +1 -1
- package/dist/primitives/variables/DateVariable/DateVariable.js +6 -8
- package/dist/primitives/variables/DateVariable/DateVariable.js.map +1 -1
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.d.ts +1 -1
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.d.ts.map +1 -1
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.js +5 -11
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.js.map +1 -1
- package/dist/primitives/variables/NumberVariable/NumberVariable.d.ts +2 -2
- package/dist/primitives/variables/NumberVariable/NumberVariable.d.ts.map +1 -1
- package/dist/primitives/variables/NumberVariable/NumberVariable.js +5 -7
- package/dist/primitives/variables/NumberVariable/NumberVariable.js.map +1 -1
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.d.ts +1 -1
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.d.ts.map +1 -1
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.js +5 -11
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.js.map +1 -1
- package/dist/primitives/variables/Variable/Variable.js +3 -5
- package/dist/primitives/variables/Variable/Variable.js.map +1 -1
- package/dist/primitives/variables/Variable/createVariableComponent.js +4 -10
- package/dist/primitives/variables/Variable/createVariableComponent.js.map +1 -1
- package/dist/server/ServerI18N.d.ts +1 -1
- package/dist/server/ServerI18N.d.ts.map +1 -1
- package/dist/server/ServerI18N.js +26 -31
- package/dist/server/ServerI18N.js.map +1 -1
- package/dist/server/createI18NComponent.js +4 -10
- package/dist/server/createI18NComponent.js.map +1 -1
- package/dist/server/helpers/addGTIdentifier.js +6 -12
- package/dist/server/helpers/addGTIdentifier.js.map +1 -1
- package/dist/server/helpers/generateHash.js +1 -4
- package/dist/server/helpers/generateHash.js.map +1 -1
- package/dist/server/helpers/writeChildrenAsObjects.js +7 -13
- package/dist/server/helpers/writeChildrenAsObjects.js.map +1 -1
- package/dist/server/renderChildren.js +32 -38
- package/dist/server/renderChildren.js.map +1 -1
- package/dist/server/resolvers/ReplaceResolver.js +9 -12
- package/dist/server/resolvers/ReplaceResolver.js.map +1 -1
- package/dist/server/resolvers/SkeletonResolver.d.ts.map +1 -1
- package/dist/server/resolvers/SkeletonResolver.js +9 -52
- package/dist/server/resolvers/SkeletonResolver.js.map +1 -1
- package/dist/types/CreateGTProps.js +1 -2
- package/dist/types/GeneralTranslationInterface.js +1 -2
- package/dist/types/VariableInterface.js +1 -2
- package/package.json +2 -2
- package/tsconfig.json +1 -1
- package/dist/server/resolvers/I18NResolver.d.ts +0 -16
- package/dist/server/resolvers/I18NResolver.d.ts.map +0 -1
- package/dist/server/resolvers/I18NResolver.js +0 -59
- package/dist/server/resolvers/I18NResolver.js.map +0 -1
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = getValueBranch;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const isValidReactNode_1 = __importDefault(require("./isValidReactNode"));
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isValidReactNode from './isValidReactNode';
|
|
9
3
|
/*
|
|
10
4
|
{
|
|
11
5
|
"gender": {
|
|
@@ -32,7 +26,7 @@ const isValidReactNode_1 = __importDefault(require("./isValidReactNode"));
|
|
|
32
26
|
* @param {Record<string, any>} branches - An object representing the branches to be navigated based on the values.
|
|
33
27
|
* @returns {any} - Returns the matched React node or undefined if no match is found.
|
|
34
28
|
*/
|
|
35
|
-
function getValueBranch(values, branches) {
|
|
29
|
+
export default function getValueBranch(values, branches) {
|
|
36
30
|
let currentDefault = null;
|
|
37
31
|
/**
|
|
38
32
|
* Handles the navigation through a given branch object.
|
|
@@ -52,7 +46,7 @@ function getValueBranch(values, branches) {
|
|
|
52
46
|
return branch[key][value];
|
|
53
47
|
}
|
|
54
48
|
/* @ts-expect-error Lazy components are meant to return a promise */
|
|
55
|
-
if ((
|
|
49
|
+
if (isValidReactNode(branch[key][value]) || branch[key][value].$$typeof === React.lazy(() => { }).$$typeof) {
|
|
56
50
|
return branch[key][value];
|
|
57
51
|
}
|
|
58
52
|
return handleBranch(branch[key][value]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValueBranch.js","sourceRoot":"","sources":["../../../src/primitives/helpers/getValueBranch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getValueBranch.js","sourceRoot":"","sources":["../../../src/primitives/helpers/getValueBranch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;EAkBE;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,MAA2B,EAAE,QAA6B;IAE7F,IAAI,cAAc,GAAQ,IAAI,CAAC;IAE/B;;;;;OAKG;IACH,MAAM,YAAY,GAAG,CAAC,MAAW,EAAO,EAAE;;QACtC,cAAc,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,GAAG,CAAC,KAAI,cAAc,CAAC;QACjD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,KAAK,EAAE,CAAC;gBACR,qCAAqC;gBACrC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBACrB,IAAI,OAAO,CAAA,MAAA,MAAA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,0CAAG,yBAAyB,CAAC,0CAAE,EAAE,CAAA,KAAK,QAAQ,EAAE,CAAC;wBAChF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;oBAC9B,CAAC;oBACD,oEAAoE;oBACpE,IAAI,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;wBACxG,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;oBAC9B,CAAC;oBACD,OAAO,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;gBAC3C,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,cAAc,CAAC;IAC1B,CAAC,CAAA;IAED,wDAAwD;IACxD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = isValidReactNode;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
1
|
+
import React from "react";
|
|
8
2
|
/**
|
|
9
3
|
* Type guard to determine if a given node is a valid ReactNode. Excludes null and undefined nodes.
|
|
10
4
|
* A ReactNode can be:
|
|
@@ -17,11 +11,11 @@ const react_1 = __importDefault(require("react"));
|
|
|
17
11
|
* @param {any} node - The node to check.
|
|
18
12
|
* @returns {node is ReactNode} - True if the node is a valid ReactNode, false otherwise.
|
|
19
13
|
*/
|
|
20
|
-
function isValidReactNode(node) {
|
|
14
|
+
export default function isValidReactNode(node) {
|
|
21
15
|
return (typeof node === 'string' ||
|
|
22
16
|
typeof node === 'number' ||
|
|
23
17
|
typeof node === 'boolean' ||
|
|
24
|
-
|
|
18
|
+
React.isValidElement(node) ||
|
|
25
19
|
(Array.isArray(node) && node.every(isValidReactNode)));
|
|
26
20
|
}
|
|
27
21
|
//# sourceMappingURL=isValidReactNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidReactNode.js","sourceRoot":"","sources":["../../../src/primitives/helpers/isValidReactNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isValidReactNode.js","sourceRoot":"","sources":["../../../src/primitives/helpers/isValidReactNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,IAAS;IAC9C,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,IAAI,KAAK,SAAS;QACzB,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;QAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CACtD,CAAC;AACN,CAAC"}
|
|
@@ -5,7 +5,7 @@ type NumericProps = {
|
|
|
5
5
|
n?: number;
|
|
6
6
|
children?: any;
|
|
7
7
|
ranges?: Range[];
|
|
8
|
-
|
|
8
|
+
locales: string[];
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -17,6 +17,6 @@ type NumericProps = {
|
|
|
17
17
|
* @param {Record<string, any>} ...branches - Named branches, e.g. "singular", "plural" and their associated branches.
|
|
18
18
|
* @returns {JSX.Element}
|
|
19
19
|
*/
|
|
20
|
-
export default function Numeric({ children, n, ranges,
|
|
20
|
+
export default function Numeric({ children, n, ranges, locales, ...branches }: NumericProps): ReactNode;
|
|
21
21
|
export {};
|
|
22
22
|
//# sourceMappingURL=Numeric.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Numeric.d.ts","sourceRoot":"","sources":["../../../src/primitives/numeric/Numeric.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAyB,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEtE,KAAK,YAAY,GAAG;IAChB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"Numeric.d.ts","sourceRoot":"","sources":["../../../src/primitives/numeric/Numeric.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAyB,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEtE,KAAK,YAAY,GAAG;IAChB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,EAAE,YAAY,GAAG,SAAS,CAoBtG"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,15 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.default = Numeric;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
require("server-only");
|
|
20
|
-
const renderVariable_1 = __importDefault(require("../value/renderVariable"));
|
|
21
|
-
const getNumericBranch_1 = __importDefault(require("../helpers/getNumericBranch"));
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import 'server-only';
|
|
14
|
+
import renderNumeric from '../value/renderVariable';
|
|
15
|
+
import getNumericBranch from '../helpers/getNumericBranch';
|
|
22
16
|
/**
|
|
23
17
|
* Numeric component that processes a given number and renders the appropriate branch or children.
|
|
24
18
|
*
|
|
@@ -28,16 +22,16 @@ const getNumericBranch_1 = __importDefault(require("../helpers/getNumericBranch"
|
|
|
28
22
|
* @param {Record<string, any>} ...branches - Named branches, e.g. "singular", "plural" and their associated branches.
|
|
29
23
|
* @returns {JSX.Element}
|
|
30
24
|
*/
|
|
31
|
-
function Numeric(_a) {
|
|
32
|
-
var { children, n, ranges,
|
|
25
|
+
export default function Numeric(_a) {
|
|
26
|
+
var { children, n, ranges, locales } = _a, branches = __rest(_a, ["children", "n", "ranges", "locales"]);
|
|
33
27
|
if (typeof n !== 'number') {
|
|
34
28
|
console.warn(`WARNING: No values provided to <Numeric> component with children ${JSON.stringify(children)}.`);
|
|
35
29
|
}
|
|
36
30
|
let { 'data-generaltranslation': generaltranslation } = branches, otherParams = __rest(branches, ['data-generaltranslation']);
|
|
37
31
|
branches = Object.assign(Object.assign({}, otherParams), { ranges: ranges });
|
|
38
|
-
let branch = ((typeof n === 'number' && branches) ? (
|
|
39
|
-
const renderedChildren = (
|
|
40
|
-
return ((
|
|
32
|
+
let branch = ((typeof n === 'number' && branches) ? getNumericBranch(n, locales, branches) : null) || children;
|
|
33
|
+
const renderedChildren = renderNumeric(branch, locales, (typeof n === 'number') ? { n } : undefined);
|
|
34
|
+
return (_jsx("span", { "data-n": n, "data-unrendered-branches": branches, "data-generaltranslation": generaltranslation, children: renderedChildren }));
|
|
41
35
|
}
|
|
42
36
|
;
|
|
43
37
|
//# sourceMappingURL=Numeric.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Numeric.js","sourceRoot":"","sources":["../../../src/primitives/numeric/Numeric.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Numeric.js","sourceRoot":"","sources":["../../../src/primitives/numeric/Numeric.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,gBAA2B,MAAM,6BAA6B,CAAC;AAUtE;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAA2D;QAA3D,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,OAA6B,EAAxB,QAAQ,cAA3C,sCAA6C,CAAF;IAEvE,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,oEAAoE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IACjH,CAAC;IAED,IAAI,EAAE,yBAAyB,EAAE,kBAAkB,KAA0B,QAAQ,EAA7B,WAAW,UAAU,QAAQ,EAAjF,2BAAiE,CAAgB,CAAC;IAEtF,QAAQ,mCAAQ,WAAW,KAAE,MAAM,EAAE,MAAM,GAAE,CAAC;IAE9C,IAAI,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;IAE/G,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAErG,OAAO,CACH,yBAAc,CAAC,8BAA4B,QAAQ,6BAA2B,kBAAkB,YAC3F,gBAAgB,GACd,CACV,CAAC;AAEN,CAAC;AAAA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNumericComponent.d.ts","sourceRoot":"","sources":["../../../src/primitives/numeric/createNumericComponent.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,SAAS,EAAE,MAAM,MAAM;
|
|
1
|
+
{"version":3,"file":"createNumericComponent.d.ts","sourceRoot":"","sources":["../../../src/primitives/numeric/createNumericComponent.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,SAAS,EAAE,MAAM,MAAM,EAAE,aAAa,EAAE,MAAM;6BACvC;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;;EAM3F"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,18 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.default = createNumericComponent;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const Numeric_1 = __importDefault(require("./Numeric"));
|
|
20
|
-
function createNumericComponent(getLocale) {
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import Numeric from "./Numeric";
|
|
14
|
+
export default function createNumericComponent(getLocale, defaultLocale) {
|
|
21
15
|
const NumericComponent = (_a) => {
|
|
22
16
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
23
|
-
const
|
|
24
|
-
return (
|
|
17
|
+
const locales = [getLocale(), defaultLocale];
|
|
18
|
+
return _jsx(Numeric, Object.assign({ locales: locales }, props, { children: children }));
|
|
25
19
|
};
|
|
26
20
|
NumericComponent.gtTransformation = "numeric";
|
|
27
21
|
return NumericComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNumericComponent.js","sourceRoot":"","sources":["../../../src/primitives/numeric/createNumericComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createNumericComponent.js","sourceRoot":"","sources":["../../../src/primitives/numeric/createNumericComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,SAAuB,EAAE,aAAqB;IACzF,MAAM,gBAAgB,GAAG,CAAC,EAA8D,EAAE,EAAE;YAAlE,EAAE,QAAQ,OAAoD,EAA/C,KAAK,cAApB,YAAsB,CAAF;QAC1C,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;QAC7C,OAAO,KAAC,OAAO,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,cAAG,QAAQ,IAAW,CAAA;IACrE,CAAC,CAAC;IACF,gBAAgB,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAC9C,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,8 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
13
|
/**
|
|
16
14
|
* Marks any children as private, excluding them from translation.
|
|
17
15
|
*
|
|
@@ -22,8 +20,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
22
20
|
const Private = (_a) => {
|
|
23
21
|
var { children, label = '' } = _a, params = __rest(_a, ["children", "label"]);
|
|
24
22
|
const { 'data-generaltranslation': generaltranslation } = params;
|
|
25
|
-
return ((
|
|
23
|
+
return (_jsx("span", { "data-label": label, "data-generaltranslation": generaltranslation, children: children }));
|
|
26
24
|
};
|
|
27
25
|
Private.gtTransformation = "private";
|
|
28
|
-
|
|
26
|
+
export default Private;
|
|
29
27
|
//# sourceMappingURL=Private.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Private.js","sourceRoot":"","sources":["../../../src/primitives/private/Private.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Private.js","sourceRoot":"","sources":["../../../src/primitives/private/Private.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAQA;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,CAAC,EAAiD,EAAO,EAAE;QAA1D,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,OAA2B,EAAtB,MAAM,cAAjC,qBAAmC,CAAF;IAE9C,MAAM,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,GAAQ,MAAM,CAAC;IAEtE,OAAO,CACH,6BAAkB,KAAK,6BAA2B,kBAAkB,YAC/D,QAAQ,GACN,CACV,CAAC;AACN,CAAC,CAAA;AAED,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;AAErC,eAAe,OAAO,CAAC"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = createPrivateComponent;
|
|
7
|
-
const Private_1 = __importDefault(require("./Private"));
|
|
8
|
-
function createPrivateComponent() {
|
|
9
|
-
return Private_1.default;
|
|
1
|
+
import Private from "./Private";
|
|
2
|
+
export default function createPrivateComponent() {
|
|
3
|
+
return Private;
|
|
10
4
|
}
|
|
11
5
|
//# sourceMappingURL=createPrivateComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrivateComponent.js","sourceRoot":"","sources":["../../../src/primitives/private/createPrivateComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPrivateComponent.js","sourceRoot":"","sources":["../../../src/primitives/private/createPrivateComponent.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,MAAM,CAAC,OAAO,UAAU,sBAAsB;IAC1C,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
type ValueProps = {
|
|
4
|
-
|
|
4
|
+
locales: string[];
|
|
5
5
|
children?: any;
|
|
6
6
|
branches?: Record<string, any>;
|
|
7
7
|
values?: Record<string, any>;
|
|
@@ -17,7 +17,7 @@ type ValueProps = {
|
|
|
17
17
|
* @returns {JSX.Element}
|
|
18
18
|
*/
|
|
19
19
|
declare const Value: {
|
|
20
|
-
({ children, branches, values,
|
|
20
|
+
({ children, branches, values, locales, ...props }: ValueProps): ReactNode;
|
|
21
21
|
gtTransformation: string;
|
|
22
22
|
};
|
|
23
23
|
export default Value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Value.d.ts","sourceRoot":"","sources":["../../../src/primitives/value/Value.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKzC,KAAK,UAAU,GAAG;IACd,
|
|
1
|
+
{"version":3,"file":"Value.d.ts","sourceRoot":"","sources":["../../../src/primitives/value/Value.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKzC,KAAK,UAAU,GAAG;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,KAAK;wDAAuD,UAAU,GAAG,SAAS;;CAkBvF,CAAC;AAIF,eAAe,KAAK,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,14 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
-
require("server-only");
|
|
19
|
-
const renderVariable_1 = __importDefault(require("./renderVariable"));
|
|
20
|
-
const getValueBranch_1 = __importDefault(require("../helpers/getValueBranch"));
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import 'server-only';
|
|
14
|
+
import renderVariable from './renderVariable';
|
|
15
|
+
import getValueBranch from '../helpers/getValueBranch';
|
|
21
16
|
/**
|
|
22
17
|
* Value variable component that processes the given values and branches,
|
|
23
18
|
* and renders the appropriate content based on the branch logic.
|
|
@@ -28,15 +23,15 @@ const getValueBranch_1 = __importDefault(require("../helpers/getValueBranch"));
|
|
|
28
23
|
* @returns {JSX.Element}
|
|
29
24
|
*/
|
|
30
25
|
const Value = (_a) => {
|
|
31
|
-
var { children, branches, values,
|
|
26
|
+
var { children, branches, values, locales } = _a, props = __rest(_a, ["children", "branches", "values", "locales"]);
|
|
32
27
|
let { 'data-generaltranslation': generaltranslation } = props;
|
|
33
28
|
if (!values || Object.keys(values).length < 1) {
|
|
34
29
|
console.warn(`WARNING: No values provided to <Value> component with children ${JSON.stringify(children)}.`);
|
|
35
30
|
}
|
|
36
|
-
let branch = ((typeof values !== 'undefined' && typeof branches !== 'undefined') ? (
|
|
37
|
-
let renderedChildren = (
|
|
38
|
-
return ((
|
|
31
|
+
let branch = ((typeof values !== 'undefined' && typeof branches !== 'undefined') ? getValueBranch(values, branches) : null) || children;
|
|
32
|
+
let renderedChildren = renderVariable(branch, locales, values ? values : undefined);
|
|
33
|
+
return (_jsx("span", { "data-values": values, "data-unrendered-branches": branches, "data-generaltranslation": generaltranslation, children: renderedChildren }));
|
|
39
34
|
};
|
|
40
35
|
Value.gtTransformation = "value";
|
|
41
|
-
|
|
36
|
+
export default Value;
|
|
42
37
|
//# sourceMappingURL=Value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Value.js","sourceRoot":"","sources":["../../../src/primitives/value/Value.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Value.js","sourceRoot":"","sources":["../../../src/primitives/value/Value.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,cAAc,MAAM,2BAA2B,CAAC;AAWvD;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG,CAAC,EAA6D,EAAa,EAAE;QAA5E,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,OAAwB,EAAnB,KAAK,cAA/C,6CAAiD,CAAF;IAE1D,IAAI,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,GAAQ,KAAK,CAAC;IAEnE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,kEAAkE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC/G,CAAC;IAED,IAAI,MAAM,GAAG,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;IAExI,IAAI,gBAAgB,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEpF,OAAO,CACH,8BAAmB,MAAM,8BAA4B,QAAQ,6BAA2B,kBAAkB,YACrG,gBAAgB,GACd,CACV,CAAA;AAEL,CAAC,CAAC;AAEF,KAAK,CAAC,gBAAgB,GAAG,OAAO,CAAC;AAEjC,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createValueComponent.d.ts","sourceRoot":"","sources":["../../../src/primitives/value/createValueComponent.tsx"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,SAAS,EAAE,MAAM,MAAM;
|
|
1
|
+
{"version":3,"file":"createValueComponent.d.ts","sourceRoot":"","sources":["../../../src/primitives/value/createValueComponent.tsx"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,SAAS,EAAE,MAAM,MAAM,EAAE,aAAa,EAAE,MAAM;6BACvC;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;;EAMzF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,18 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.default = createValueComponent;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const Value_1 = __importDefault(require("./Value"));
|
|
20
|
-
function createValueComponent(getLocale) {
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import Value from "./Value";
|
|
14
|
+
export default function createValueComponent(getLocale, defaultLocale) {
|
|
21
15
|
const ValueComponent = (_a) => {
|
|
22
16
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
23
|
-
const
|
|
24
|
-
return (
|
|
17
|
+
const locales = [getLocale(), defaultLocale];
|
|
18
|
+
return _jsx(Value, Object.assign({ locales: locales }, props, { children: children }));
|
|
25
19
|
};
|
|
26
20
|
ValueComponent.gtTransformation = "value";
|
|
27
21
|
return ValueComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createValueComponent.js","sourceRoot":"","sources":["../../../src/primitives/value/createValueComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createValueComponent.js","sourceRoot":"","sources":["../../../src/primitives/value/createValueComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,KAAK,MAAM,SAAS,CAAA;AAG3B,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,SAAuB,EAAE,aAAqB;IACvF,MAAM,cAAc,GAAG,CAAC,EAA8D,EAAE,EAAE;YAAlE,EAAE,QAAQ,OAAoD,EAA/C,KAAK,cAApB,YAAsB,CAAF;QACxC,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;QAC7C,OAAO,KAAC,KAAK,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,cAAG,QAAQ,IAAS,CAAA;IACjE,CAAC,CAAA;IACD,cAAc,CAAC,gBAAgB,GAAG,OAAO,CAAC;IAC1C,OAAO,cAAc,CAAC;AAC1B,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = processBranches;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
1
|
+
import React from "react";
|
|
8
2
|
function isValidNestedGTNode(node) {
|
|
9
3
|
return (node === null ||
|
|
10
4
|
typeof node === 'undefined' ||
|
|
@@ -12,7 +6,7 @@ function isValidNestedGTNode(node) {
|
|
|
12
6
|
typeof node === 'string' ||
|
|
13
7
|
typeof node === 'number' ||
|
|
14
8
|
typeof node === 'boolean' ||
|
|
15
|
-
|
|
9
|
+
React.isValidElement(node) ||
|
|
16
10
|
(Array.isArray(node) && node.every(isValidNestedGTNode)));
|
|
17
11
|
}
|
|
18
12
|
function isValidGTNode(node) {
|
|
@@ -21,7 +15,7 @@ function isValidGTNode(node) {
|
|
|
21
15
|
typeof node === 'string' ||
|
|
22
16
|
typeof node === 'number' ||
|
|
23
17
|
typeof node === 'boolean' ||
|
|
24
|
-
|
|
18
|
+
React.isValidElement(node) ||
|
|
25
19
|
(Array.isArray(node) && node.every(isValidNestedGTNode)));
|
|
26
20
|
}
|
|
27
21
|
/**
|
|
@@ -31,7 +25,7 @@ function isValidGTNode(node) {
|
|
|
31
25
|
* @param {Function} f The function to apply to each leaf node of the tree.
|
|
32
26
|
* @returns {any} The processed tree structure with the function applied to each leaf node.
|
|
33
27
|
*/
|
|
34
|
-
function processBranches(branches, f) {
|
|
28
|
+
export default function processBranches(branches, f) {
|
|
35
29
|
if (isValidGTNode(branches)) {
|
|
36
30
|
return f(branches);
|
|
37
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processBranches.js","sourceRoot":"","sources":["../../../src/primitives/value/processBranches.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processBranches.js","sourceRoot":"","sources":["../../../src/primitives/value/processBranches.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,SAAS,mBAAmB,CAAC,IAAS;IAClC,OAAO,CACH,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,WAAW;QAC3B,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;QAChG,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,IAAI,KAAK,SAAS;QACzB,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;QAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAC3D,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,IAAS;IAC5B,OAAO,CACH,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,WAAW;QAC3B,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,IAAI,KAAK,SAAS;QACzB,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;QAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAC3D,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAa,EAAE,CAAW;IAC9D,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,iBAAiB,GAAQ,EAAE,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,iBAAiB,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC7B,CAAC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param {string} locale - The user's locale.
|
|
6
6
|
* @returns {any} The rendered children elements.
|
|
7
7
|
*/
|
|
8
|
-
export default function renderVariable(children: any,
|
|
8
|
+
export default function renderVariable(children: any, locales: string[], variables?: Record<string, any>): any;
|
|
9
9
|
//# sourceMappingURL=renderVariable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderVariable.d.ts","sourceRoot":"","sources":["../../../src/primitives/value/renderVariable.tsx"],"names":[],"mappings":"AA8CA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"renderVariable.d.ts","sourceRoot":"","sources":["../../../src/primitives/value/renderVariable.tsx"],"names":[],"mappings":"AA8CA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAG7G"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const isValidReactNode_1 = __importDefault(require("../helpers/isValidReactNode"));
|
|
10
|
-
const Variable_1 = __importDefault(require("../variables/Variable/Variable"));
|
|
11
|
-
const CurrencyVariable_1 = __importDefault(require("../variables/CurrencyVariable/CurrencyVariable"));
|
|
12
|
-
const NumberVariable_1 = __importDefault(require("../variables/NumberVariable/NumberVariable"));
|
|
13
|
-
const DateVariable_1 = __importDefault(require("../variables/DateVariable/DateVariable"));
|
|
14
|
-
const defaultVariableNames_1 = __importDefault(require("../helpers/defaultVariableNames"));
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import isValidReactNode from '../helpers/isValidReactNode';
|
|
4
|
+
import Variable from '../variables/Variable/Variable';
|
|
5
|
+
import CurrencyVariable from '../variables/CurrencyVariable/CurrencyVariable';
|
|
6
|
+
import NumberVariable from '../variables/NumberVariable/NumberVariable';
|
|
7
|
+
import DateVariable from '../variables/DateVariable/DateVariable';
|
|
8
|
+
import defaultVariableNames from '../helpers/defaultVariableNames';
|
|
15
9
|
/**
|
|
16
10
|
* Handles a single child element by cloning it with new properties if it is a valid React element,
|
|
17
11
|
* or wrapping it in a React Fragment if it is a valid React node object.
|
|
@@ -19,35 +13,35 @@ const defaultVariableNames_1 = __importDefault(require("../helpers/defaultVariab
|
|
|
19
13
|
* @param {any} child - The child element to handle.
|
|
20
14
|
* @returns {any} The handled child element.
|
|
21
15
|
*/
|
|
22
|
-
const handleSingleChild = (child,
|
|
16
|
+
const handleSingleChild = (child, locales, variables) => {
|
|
23
17
|
var _a;
|
|
24
|
-
if (
|
|
18
|
+
if (React.isValidElement(child)) {
|
|
25
19
|
const { props, type } = child;
|
|
26
20
|
// Check if a variable component
|
|
27
21
|
const transformation = typeof type === 'function' ? ((type === null || type === void 0 ? void 0 : type.gtTransformation) || '') : '';
|
|
28
22
|
if (variables && (transformation === null || transformation === void 0 ? void 0 : transformation.startsWith("variable"))) {
|
|
29
23
|
const variableType = ((_a = transformation.split('-')) === null || _a === void 0 ? void 0 : _a[1]) || "variable";
|
|
30
|
-
const name = props.name ||
|
|
24
|
+
const name = props.name || defaultVariableNames[variableType];
|
|
31
25
|
const value = variables[name];
|
|
32
26
|
const options = (props === null || props === void 0 ? void 0 : props.options) || {};
|
|
33
27
|
if (variableType === "number") {
|
|
34
|
-
return (
|
|
28
|
+
return _jsx(NumberVariable, { locales: locales, defaultValue: value, name: name, options: options });
|
|
35
29
|
}
|
|
36
30
|
if (variableType === "date") {
|
|
37
|
-
return (
|
|
31
|
+
return _jsx(DateVariable, { locales: locales, defaultValue: value, name: name, options: options });
|
|
38
32
|
}
|
|
39
33
|
if (variableType === "currency") {
|
|
40
|
-
return (
|
|
34
|
+
return _jsx(CurrencyVariable, { locales: locales, defaultValue: value, name: name, options: options });
|
|
41
35
|
}
|
|
42
|
-
return (
|
|
36
|
+
return _jsx(Variable, { defaultValue: value, name: name });
|
|
43
37
|
}
|
|
44
38
|
let newProps = Object.assign({}, props);
|
|
45
39
|
if (props === null || props === void 0 ? void 0 : props.children) {
|
|
46
|
-
newProps.children = renderVariable(props.children,
|
|
40
|
+
newProps.children = renderVariable(props.children, locales, variables);
|
|
47
41
|
}
|
|
48
|
-
return
|
|
42
|
+
return React.cloneElement(child, newProps);
|
|
49
43
|
}
|
|
50
|
-
if ((
|
|
44
|
+
if (isValidReactNode(child))
|
|
51
45
|
return child;
|
|
52
46
|
};
|
|
53
47
|
/**
|
|
@@ -57,10 +51,10 @@ const handleSingleChild = (child, locale, variables) => {
|
|
|
57
51
|
* @param {string} locale - The user's locale.
|
|
58
52
|
* @returns {any} The rendered children elements.
|
|
59
53
|
*/
|
|
60
|
-
function renderVariable(children,
|
|
54
|
+
export default function renderVariable(children, locales, variables) {
|
|
61
55
|
if (Array.isArray(children))
|
|
62
|
-
return children.map((child, index) => (
|
|
56
|
+
return children.map((child, index) => _jsx(React.Fragment, { children: handleSingleChild(child, locales, variables) }, index));
|
|
63
57
|
else
|
|
64
|
-
return handleSingleChild(children,
|
|
58
|
+
return handleSingleChild(children, locales, variables);
|
|
65
59
|
}
|
|
66
60
|
//# sourceMappingURL=renderVariable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderVariable.js","sourceRoot":"","sources":["../../../src/primitives/value/renderVariable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderVariable.js","sourceRoot":"","sources":["../../../src/primitives/value/renderVariable.tsx"],"names":[],"mappings":"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"}
|
|
@@ -14,7 +14,7 @@ type VariableProps = {
|
|
|
14
14
|
children?: any;
|
|
15
15
|
name?: string;
|
|
16
16
|
defaultValue?: any;
|
|
17
|
-
|
|
17
|
+
locales: string[];
|
|
18
18
|
currency?: string;
|
|
19
19
|
"data-generaltranslation"?: Record<string, any>;
|
|
20
20
|
options?: Record<string, any>;
|
|
@@ -32,7 +32,7 @@ type VariableProps = {
|
|
|
32
32
|
* @returns {JSX.Element} A span element containing the formatted currency with specific data attributes
|
|
33
33
|
*/
|
|
34
34
|
declare const CurrencyVariable: {
|
|
35
|
-
({ children,
|
|
35
|
+
({ children, locales, name, defaultValue, currency, options, ...props }: VariableProps): ReactNode;
|
|
36
36
|
gtTransformation: string;
|
|
37
37
|
};
|
|
38
38
|
export default CurrencyVariable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyVariable.d.ts","sourceRoot":"","sources":["../../../../src/primitives/variables/CurrencyVariable/CurrencyVariable.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,KAAK,aAAa,GAAG;IACjB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"CurrencyVariable.d.ts","sourceRoot":"","sources":["../../../../src/primitives/variables/CurrencyVariable/CurrencyVariable.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,KAAK,aAAa,GAAG;IACjB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,gBAAgB;6EAAkG,aAAa,GAAG,SAAS;;CAuBhJ,CAAC;AAIF,eAAe,gBAAgB,CAAC"}
|