gt-react 3.1.23 → 3.1.25
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.d.ts +5 -0
- package/dist/client/ClientProvider.d.ts.map +1 -1
- package/dist/client/ClientProvider.js +12 -1
- package/dist/client/ClientProvider.js.map +1 -1
- package/dist/client/hooks/useDefaultLocale.d.ts +1 -1
- package/dist/client/hooks/useDefaultLocale.d.ts.map +1 -1
- package/dist/client/hooks/useDefaultLocale.js +4 -9
- package/dist/client/hooks/useDefaultLocale.js.map +1 -1
- package/dist/client/hooks/useGT.d.ts.map +1 -1
- package/dist/client/hooks/useGT.js +50 -14
- package/dist/client/hooks/useGT.js.map +1 -1
- package/dist/client/hooks/useLocale.d.ts +1 -1
- package/dist/client/hooks/useLocale.d.ts.map +1 -1
- package/dist/client/hooks/useLocale.js +4 -9
- package/dist/client/hooks/useLocale.js.map +1 -1
- package/dist/client/numeric/ClientNumeric.d.ts +11 -3
- package/dist/client/numeric/ClientNumeric.d.ts.map +1 -1
- package/dist/client/numeric/ClientNumeric.js +12 -8
- package/dist/client/numeric/ClientNumeric.js.map +1 -1
- package/dist/client/value/ClientValue.d.ts +3 -4
- package/dist/client/value/ClientValue.d.ts.map +1 -1
- package/dist/client/value/ClientValue.js +15 -15
- package/dist/client/value/ClientValue.js.map +1 -1
- package/dist/client/value/RenderClientVariable.js +5 -5
- package/dist/client/value/RenderClientVariable.js.map +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -2
- package/dist/client.js.map +1 -1
- package/dist/dictionary/createNumericValueMarkerComponents.d.ts +16 -0
- package/dist/dictionary/createNumericValueMarkerComponents.d.ts.map +1 -0
- package/dist/dictionary/createNumericValueMarkerComponents.js +12 -0
- package/dist/dictionary/createNumericValueMarkerComponents.js.map +1 -0
- package/dist/dictionary/createTFunction.d.ts.map +1 -1
- package/dist/dictionary/createTFunction.js +47 -0
- package/dist/dictionary/createTFunction.js.map +1 -1
- package/dist/next.d.ts +33 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +7 -1
- package/dist/next.js.map +1 -1
- package/dist/server/helpers/addGTIdentifier.d.ts.map +1 -1
- package/dist/server/helpers/addGTIdentifier.js +2 -16
- package/dist/server/helpers/addGTIdentifier.js.map +1 -1
- package/dist/server/helpers/writeChildrenAsObjects.d.ts.map +1 -1
- package/dist/server/helpers/writeChildrenAsObjects.js +0 -7
- package/dist/server/helpers/writeChildrenAsObjects.js.map +1 -1
- package/dist/server/numeric/InnerNumeric.d.ts +16 -17
- package/dist/server/numeric/InnerNumeric.d.ts.map +1 -1
- package/dist/server/numeric/InnerNumeric.js +5 -13
- package/dist/server/numeric/InnerNumeric.js.map +1 -1
- package/dist/server/provider/GTProvider.d.ts +2 -4
- package/dist/server/provider/GTProvider.d.ts.map +1 -1
- package/dist/server/provider/GTProvider.js +1 -17
- package/dist/server/provider/GTProvider.js.map +1 -1
- package/dist/server/renderChildren.d.ts.map +1 -1
- package/dist/server/renderChildren.js +2 -5
- package/dist/server/renderChildren.js.map +1 -1
- package/dist/server/value/InnerValue.d.ts +6 -17
- package/dist/server/value/InnerValue.d.ts.map +1 -1
- package/dist/server/value/InnerValue.js +4 -15
- package/dist/server/value/InnerValue.js.map +1 -1
- package/dist/server/value/createValueComponent.d.ts +3 -2
- package/dist/server/value/createValueComponent.d.ts.map +1 -1
- package/dist/server/value/createValueComponent.js +2 -3
- package/dist/server/value/createValueComponent.js.map +1 -1
- package/dist/server.d.ts +33 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12 -0
- package/dist/server.js.map +1 -1
- package/dist/types/GeneralTranslationInterface.d.ts +1 -4
- package/dist/types/GeneralTranslationInterface.d.ts.map +1 -1
- package/package.json +1 -1
- package/scratchpad.js +0 -78
- package/dist/client/T.d.ts +0 -10
- package/dist/client/T.d.ts.map +0 -1
- package/dist/client/T.js +0 -19
- package/dist/client/T.js.map +0 -1
- package/dist/primitives/generateHash.d.ts +0 -12
- package/dist/primitives/generateHash.d.ts.map +0 -1
- package/dist/primitives/generateHash.js +0 -31
- package/dist/primitives/generateHash.js.map +0 -1
- package/dist/server/helpers/calculateID.d.ts +0 -2
- package/dist/server/helpers/calculateID.d.ts.map +0 -1
- package/dist/server/helpers/calculateID.js +0 -43
- package/dist/server/helpers/calculateID.js.map +0 -1
- package/dist/server/value/processBranches.d.ts +0 -9
- package/dist/server/value/processBranches.d.ts.map +0 -1
- package/dist/server/value/processBranches.js +0 -38
- package/dist/server/value/processBranches.js.map +0 -1
|
@@ -10,5 +10,10 @@ type ClientProviderProps = {
|
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
12
|
export default function ClientProvider({ children, locale, defaultLocale, dictionary }: ClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Custom hook to use the GTContext
|
|
15
|
+
* @returns {GTContextType} The context value
|
|
16
|
+
*/
|
|
17
|
+
export declare function useGTContext(): GTContextType;
|
|
13
18
|
export {};
|
|
14
19
|
//# sourceMappingURL=ClientProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AACD,eAAO,MAAM,SAAS,oDAAsD,CAAC;AAE7E,KAAK,mBAAmB,GAAG;IACvB,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AACD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAC9C,EAAE,mBAAmB,2CAerB"}
|
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AACD,eAAO,MAAM,SAAS,oDAAsD,CAAC;AAE7E,KAAK,mBAAmB,GAAG;IACvB,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AACD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAC9C,EAAE,mBAAmB,2CAerB;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,aAAa,CAM5C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useCallback } from "react";
|
|
3
|
+
import { createContext, useCallback, useContext } from "react";
|
|
4
4
|
export const GTContext = createContext(undefined);
|
|
5
5
|
export default function ClientProvider({ children, locale, defaultLocale, dictionary }) {
|
|
6
6
|
const translate = useCallback((id) => {
|
|
@@ -10,4 +10,15 @@ export default function ClientProvider({ children, locale, defaultLocale, dictio
|
|
|
10
10
|
translate, locale, defaultLocale
|
|
11
11
|
}, children: children }));
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Custom hook to use the GTContext
|
|
15
|
+
* @returns {GTContextType} The context value
|
|
16
|
+
*/
|
|
17
|
+
export function useGTContext() {
|
|
18
|
+
const context = useContext(GTContext);
|
|
19
|
+
if (context === undefined) {
|
|
20
|
+
throw new Error('useGTContext must be used within a GTProvider');
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
13
24
|
//# sourceMappingURL=ClientProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.js","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"ClientProvider.js","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAK9D,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAA4B,SAAS,CAAC,CAAC;AAS7E,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EACzB;IAElB,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,EAAU,EAAE,EAAE;QACzC,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACH,KAAC,SAAS,CAAC,QAAQ,IACf,KAAK,EAAE;YACH,SAAS,EAAE,MAAM,EAAE,aAAa;SACnC,YAEA,QAAQ,GACQ,CACxB,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IACxB,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDefaultLocale.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useDefaultLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDefaultLocale.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useDefaultLocale.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,IAAI,MAAM,CAGjD"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { GTContext } from "../ClientProvider";
|
|
2
|
+
import { useGTContext } from "../ClientProvider";
|
|
4
3
|
/**
|
|
5
|
-
* @returns {string} The default locale
|
|
4
|
+
* @returns {string} The default locale.
|
|
6
5
|
*/
|
|
7
6
|
export default function useDefaultLocale() {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
console.error(`useDefaultLocale(): No context provided. useDefaultLocale() can only be used inside a GTProvider.`);
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
return ctx.defaultLocale || "";
|
|
7
|
+
const { defaultLocale } = useGTContext();
|
|
8
|
+
return defaultLocale;
|
|
14
9
|
}
|
|
15
10
|
//# sourceMappingURL=useDefaultLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDefaultLocale.js","sourceRoot":"","sources":["../../../src/client/hooks/useDefaultLocale.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useDefaultLocale.js","sourceRoot":"","sources":["../../../src/client/hooks/useDefaultLocale.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACpC,MAAM,EAAE,aAAa,EAAE,GAAG,YAAY,EAAE,CAAC;IACzC,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useGT.
|
|
1
|
+
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useGT.tsx"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,QAAQ,CAwEnD"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isValidElement, useMemo } from "react";
|
|
4
|
+
import { useGTContext } from "../ClientProvider";
|
|
5
|
+
import ClientValue from "../value/ClientValue";
|
|
6
|
+
import ClientNumeric from "../numeric/ClientNumeric";
|
|
4
7
|
/**
|
|
5
8
|
* Custom hook to provide a translation function using a given context.
|
|
6
9
|
*
|
|
@@ -15,19 +18,52 @@ export default function useGT(id) {
|
|
|
15
18
|
return id ? `${id}.` : '';
|
|
16
19
|
}, [id]);
|
|
17
20
|
// Get the translation context
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
let translate;
|
|
22
|
+
try {
|
|
23
|
+
({ translate } = useGTContext());
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return (id) => {
|
|
25
|
-
const translation = ctx.translate(`${prefix}${id}`);
|
|
26
|
-
if (!translation)
|
|
27
|
-
console.warn(`t('${id}') finding no translation for dictionary item ${prefix}${id} !`);
|
|
28
|
-
return translation;
|
|
29
|
-
};
|
|
25
|
+
catch (_a) {
|
|
26
|
+
throw new Error(`t('${id}'): No context provided. useGT() can only be used inside a GTProvider.`);
|
|
30
27
|
}
|
|
31
|
-
return
|
|
28
|
+
// Return a translation function if available, otherwise return a no-op function
|
|
29
|
+
return (id, options) => {
|
|
30
|
+
const translation = translate(`${prefix}${id}`);
|
|
31
|
+
if (isValidElement(translation)) {
|
|
32
|
+
const { type } = translation;
|
|
33
|
+
const transformation = typeof type === 'function' ? ((type === null || type === void 0 ? void 0 : type.gtTransformation) || '') : '';
|
|
34
|
+
if (transformation.startsWith("marker")) {
|
|
35
|
+
const markerType = transformation.split('-')[1];
|
|
36
|
+
if (markerType === "numeric" && (!options || typeof options.n !== 'number')) {
|
|
37
|
+
throw new Error(`No n value provided to dictionary entry with id ${id} marked as Numeric: ${JSON.stringify(translation)}`);
|
|
38
|
+
}
|
|
39
|
+
if (markerType === "value" && (!options || !options.values)) {
|
|
40
|
+
throw new Error(`No values provided to dictionary entry with id ${id} marked as Value: ${JSON.stringify(translation)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
;
|
|
45
|
+
// If a numeric or value is required
|
|
46
|
+
if (options) {
|
|
47
|
+
const { n, values, ranges, zero, one, two, few, many, other, singular, dual, plural } = options;
|
|
48
|
+
if (typeof n === 'number') {
|
|
49
|
+
const innerProps = { n, ranges, zero, one, two, few, many, other, singular, dual, plural };
|
|
50
|
+
if (values) {
|
|
51
|
+
// Numeric + Value
|
|
52
|
+
return (_jsx(ClientValue, { values: values, children: _jsx(ClientNumeric, Object.assign({ id: id }, innerProps, { children: translation })) }));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Numeric only
|
|
56
|
+
return (_jsx(ClientNumeric, Object.assign({ id: id }, innerProps, { children: translation })));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (values) {
|
|
60
|
+
// Value only
|
|
61
|
+
return (_jsx(ClientValue, { id: id, values: values, children: translation }));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!translation)
|
|
65
|
+
console.warn(`t('${id}') finding no translation for dictionary item ${prefix}${id} !`);
|
|
66
|
+
return translation;
|
|
67
|
+
};
|
|
32
68
|
}
|
|
33
69
|
//# sourceMappingURL=useGT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.js","sourceRoot":"","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ChC,WAAW,IACA,GACN,CACjB,CAAC;gBACN,CAAC;qBAAM,CAAC;oBACJ,eAAe;oBACf,OAAO,CACH,KAAC,aAAa,kBAAC,EAAE,EAAE,EAAE,IAAM,UAAU,cAChC,WAAW,IACA,CACnB,CAAA;gBACL,CAAC;YACL,CAAC;iBAAM,IAAI,MAAM,EAAE,CAAC;gBAChB,aAAa;gBACb,OAAO,CACH,KAAC,WAAW,IAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAC9B,WAAW,GACF,CACjB,CAAA;YACL,CAAC;QACL,CAAC;QAED,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,iDAAiD,MAAM,GAAG,EAAE,IAAI,CAAC,CAAA;QAExG,OAAO,WAAW,CAAC;IACvB,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useLocale.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI,MAAM,CAG1C"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { GTContext } from "../ClientProvider";
|
|
2
|
+
import { useGTContext } from "../ClientProvider";
|
|
4
3
|
/**
|
|
5
|
-
* @returns {string} The current locale
|
|
4
|
+
* @returns {string} The user's current locale.
|
|
6
5
|
*/
|
|
7
6
|
export default function useLocale() {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
console.error(`useLocale(): No context provided. useLocale() can only be used inside a GTProvider.`);
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
return ctx.locale || "";
|
|
7
|
+
const { locale } = useGTContext();
|
|
8
|
+
return locale;
|
|
14
9
|
}
|
|
15
10
|
//# sourceMappingURL=useLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../../src/client/hooks/useLocale.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../../src/client/hooks/useLocale.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS;IAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAAC;IAClC,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Range } from '../../primitives/getNumericBranch';
|
|
3
3
|
type NumericProps = {
|
|
4
|
-
|
|
4
|
+
children: any;
|
|
5
5
|
id?: string;
|
|
6
|
-
|
|
6
|
+
n?: number;
|
|
7
7
|
ranges?: Range[];
|
|
8
|
-
|
|
8
|
+
zero?: any;
|
|
9
|
+
one?: any;
|
|
10
|
+
two?: any;
|
|
11
|
+
few?: any;
|
|
12
|
+
many?: any;
|
|
13
|
+
other?: any;
|
|
14
|
+
singular?: any;
|
|
15
|
+
dual?: any;
|
|
16
|
+
plural?: any;
|
|
9
17
|
};
|
|
10
18
|
/**
|
|
11
19
|
* Numeric component that processes a given number and renders the appropriate branch or children.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientNumeric.d.ts","sourceRoot":"","sources":["../../../src/client/numeric/ClientNumeric.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"ClientNumeric.d.ts","sourceRoot":"","sources":["../../../src/client/numeric/ClientNumeric.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAClD,OAAyB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAO5E,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,GAAG,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,GAAG,CAAC;CAChB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,EAAE,YAAY,GAAG,SAAS,CAiDvG"}
|
|
@@ -11,12 +11,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
15
|
import getNumericBranch from '../../primitives/getNumericBranch';
|
|
16
16
|
import RenderClientVariable from '../value/RenderClientVariable';
|
|
17
17
|
import useLocale from '../hooks/useLocale';
|
|
18
18
|
import useDefaultLocale from '../hooks/useDefaultLocale';
|
|
19
|
-
import {
|
|
19
|
+
import { useGTContext } from '../ClientProvider';
|
|
20
20
|
/**
|
|
21
21
|
* Numeric component that processes a given number and renders the appropriate branch or children.
|
|
22
22
|
*
|
|
@@ -28,18 +28,22 @@ import { GTContext } from '../ClientProvider';
|
|
|
28
28
|
*/
|
|
29
29
|
export default function ClientNumeric(_a) {
|
|
30
30
|
var { children, id, n, ranges } = _a, branches = __rest(_a, ["children", "id", "n", "ranges"]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return _jsx(RenderClientVariable, { variables: (typeof n === 'number') ? { n } : undefined, children: children });
|
|
31
|
+
let translate;
|
|
32
|
+
try {
|
|
33
|
+
({ translate } = useGTContext());
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
catch (_b) {
|
|
36
|
+
throw new Error(`<ClientNumeric>, with children:\n\n${children}\n\nid: ${id}\n\nNo context provided. Did you mean to import the server component instead?`);
|
|
37
|
+
}
|
|
38
|
+
const defaultTranslation = useMemo(() => {
|
|
39
|
+
return translate(id) || children;
|
|
40
|
+
}, [children, id]);
|
|
37
41
|
const completeBranches = useMemo(() => {
|
|
38
42
|
if (!id) {
|
|
39
43
|
return Object.assign(Object.assign({}, branches), { ranges });
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
|
-
const t = (innerID) =>
|
|
46
|
+
const t = (innerID) => translate(`${id}.${innerID}`);
|
|
43
47
|
return {
|
|
44
48
|
zero: branches.zero || t('zero') || undefined,
|
|
45
49
|
one: branches.one || t('one') || undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientNumeric.js","sourceRoot":"","sources":["../../../src/client/numeric/ClientNumeric.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;AAEZ,OAAc,
|
|
1
|
+
{"version":3,"file":"ClientNumeric.js","sourceRoot":"","sources":["../../../src/client/numeric/ClientNumeric.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;AAEZ,OAAc,EAAa,OAAO,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,gBAA2B,MAAM,mCAAmC,CAAC;AAC5E,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,SA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AAM,GAAwB,CAAA;IACxH,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;IAEf,OAAO,CACH,yBACK,gBAAgB,GACd,CACV,CAAC;AAEN,CAAC;AAAA,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
type ValueProps = {
|
|
3
|
-
children
|
|
3
|
+
children: any;
|
|
4
4
|
id?: string;
|
|
5
|
-
|
|
6
|
-
values?: Record<string, any>;
|
|
5
|
+
values: Record<string, any>;
|
|
7
6
|
};
|
|
8
7
|
/**
|
|
9
8
|
* Client-side value variable component that processes the given values and branches,
|
|
@@ -14,6 +13,6 @@ type ValueProps = {
|
|
|
14
13
|
* @param {Record<string, any>} ...values - Values to branch and translate around.
|
|
15
14
|
* @returns {ReactNode}
|
|
16
15
|
*/
|
|
17
|
-
export default function ClientValue({ children, id,
|
|
16
|
+
export default function ClientValue({ children, id, values }: ValueProps): ReactNode;
|
|
18
17
|
export {};
|
|
19
18
|
//# sourceMappingURL=ClientValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientValue.d.ts","sourceRoot":"","sources":["../../../src/client/value/ClientValue.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAM9D,KAAK,UAAU,GAAG;IACd,QAAQ,
|
|
1
|
+
{"version":3,"file":"ClientValue.d.ts","sourceRoot":"","sources":["../../../src/client/value/ClientValue.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAM9D,KAAK,UAAU,GAAG;IACd,QAAQ,EAAE,GAAG,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,GAAG,SAAS,CA4BnF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import getValueBranch from '../../primitives/getValueBranch';
|
|
3
|
+
import { useMemo } from 'react';
|
|
5
4
|
import RenderClientVariable from './RenderClientVariable';
|
|
6
|
-
import {
|
|
5
|
+
import { useGTContext } from '../ClientProvider';
|
|
7
6
|
/**
|
|
8
7
|
* Client-side value variable component that processes the given values and branches,
|
|
9
8
|
* and renders the appropriate content based on the branch logic.
|
|
@@ -13,23 +12,24 @@ import { GTContext } from '../ClientProvider';
|
|
|
13
12
|
* @param {Record<string, any>} ...values - Values to branch and translate around.
|
|
14
13
|
* @returns {ReactNode}
|
|
15
14
|
*/
|
|
16
|
-
export default function ClientValue({ children, id,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return _jsx(RenderClientVariable, { variables: values ? values : undefined, children: children });
|
|
15
|
+
export default function ClientValue({ children, id, values }) {
|
|
16
|
+
let translate;
|
|
17
|
+
try {
|
|
18
|
+
({ translate } = useGTContext());
|
|
21
19
|
}
|
|
22
|
-
|
|
20
|
+
catch (_a) {
|
|
21
|
+
throw new Error(`No context provided to <ClientValue> with children: ${children} id: ${id}. Did you mean to import the server component instead?`);
|
|
22
|
+
}
|
|
23
|
+
const defaultTranslation = useMemo(() => {
|
|
24
|
+
return translate(id) || children;
|
|
25
|
+
}, [children, id]);
|
|
23
26
|
if (!defaultTranslation) {
|
|
24
|
-
console.warn(`<
|
|
27
|
+
console.warn(`<ClientValue>, with children: ${children} id: ${id} - No translation found.`);
|
|
25
28
|
return children;
|
|
26
29
|
}
|
|
27
|
-
const branch = useMemo(() => {
|
|
28
|
-
return ((typeof values !== 'undefined' && typeof branches !== 'undefined') ? getValueBranch(values, branches) : null) || defaultTranslation;
|
|
29
|
-
}, [values, branches, defaultTranslation]);
|
|
30
30
|
const renderedChildren = useMemo(() => {
|
|
31
|
-
return _jsx(RenderClientVariable, { variables: values ? values : undefined, children:
|
|
32
|
-
}, [
|
|
31
|
+
return _jsx(RenderClientVariable, { variables: values ? values : undefined, children: defaultTranslation });
|
|
32
|
+
}, [defaultTranslation, values]);
|
|
33
33
|
return (_jsx("span", { children: renderedChildren }));
|
|
34
34
|
}
|
|
35
35
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientValue.js","sourceRoot":"","sources":["../../../src/client/value/ClientValue.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,
|
|
1
|
+
{"version":3,"file":"ClientValue.js","sourceRoot":"","sources":["../../../src/client/value/ClientValue.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAyB,OAAO,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAc;IAEpE,IAAI,SAAS,CAAC;IACd,IAAI,CAAC;QACD,CAAC,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IACrC,CAAC;IAAC,WAAM,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,uDAAuD,QAAQ,QAAQ,EAAE,wDAAwD,CAAC,CAAA;IACtJ,CAAC;IAED,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,OAAO,SAAS,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC;IACrC,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IAEnB,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,iCAAiC,QAAQ,QAAQ,EAAE,0BAA0B,CAAC,CAAC;QAC5F,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,KAAC,oBAAoB,IAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAAG,kBAAkB,GAAwB,CAAA;IACpH,CAAC,EAAE,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAA;IAEhC,OAAO,CACH,yBACK,gBAAgB,GACd,CACV,CAAA;AAEL,CAAC;AAAA,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
4
|
import ClientVar from '../variables/ClientVar';
|
|
5
5
|
import ClientNum from '../variables/ClientNum';
|
|
6
6
|
import ClientDateTime from '../variables/ClientDateTime';
|
|
7
7
|
import ClientCurrency from '../variables/ClientCurrency';
|
|
8
8
|
import defaultVariableNames from '../../primitives/defaultVariableNames';
|
|
9
|
-
import {
|
|
9
|
+
import { useGTContext } from '../ClientProvider';
|
|
10
10
|
/**
|
|
11
11
|
* Handles a single child element by cloning it with new properties if it is a valid React element,
|
|
12
12
|
* or wrapping it in a React Fragment if it is a valid React node object.
|
|
@@ -16,15 +16,15 @@ import { GTContext } from '../ClientProvider';
|
|
|
16
16
|
*/
|
|
17
17
|
function SingleChild({ children, variables }) {
|
|
18
18
|
var _a;
|
|
19
|
-
|
|
19
|
+
let { translate } = useGTContext();
|
|
20
20
|
if (!children || typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean')
|
|
21
21
|
return children;
|
|
22
22
|
if (React.isValidElement(children)) {
|
|
23
23
|
const { props, type } = children;
|
|
24
24
|
const transformation = typeof type === 'function' ? ((type === null || type === void 0 ? void 0 : type.gtTransformation) || '') : '';
|
|
25
25
|
// handle any nested <T> components
|
|
26
|
-
if (
|
|
27
|
-
const translation =
|
|
26
|
+
if (transformation === null || transformation === void 0 ? void 0 : transformation.startsWith("translate")) {
|
|
27
|
+
const translation = translate(props.id);
|
|
28
28
|
return _jsx(RenderClientVariable, { variables: variables, children: translation });
|
|
29
29
|
}
|
|
30
30
|
// handle variables
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderClientVariable.js","sourceRoot":"","sources":["../../../src/client/value/RenderClientVariable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RenderClientVariable.js","sourceRoot":"","sources":["../../../src/client/value/RenderClientVariable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,EAAE,EAAyB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzE,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,oBAAoB,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;GAMG;AAEH,SAAS,WAAW,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAmD;;IAExF,IAAI,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAAC;IAEnC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAChI,IAAI,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,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AAA;IACjD,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAsD;IAEpH,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEnE,SAAS,CAAC,GAAG,EAAE;QACX,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAC,WAAW,IAAC,SAAS,EAAE,SAAS,YAAG,KAAK,GAAe,CAAC,CAAC,CAAA;IACxH,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAE1B,OAAO,CACH,4BACK,gBAAgB,GAClB,CACN,CAAA;AACL,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import T from "./client/T";
|
|
2
1
|
import useDefaultLocale from "./client/hooks/useDefaultLocale";
|
|
3
2
|
import useLocale from "./client/hooks/useLocale";
|
|
4
3
|
import useGT from "./client/hooks/useGT";
|
|
@@ -8,5 +7,5 @@ import ClientVar from "./client/variables/ClientVar";
|
|
|
8
7
|
import ClientNum from "./client/variables/ClientNum";
|
|
9
8
|
import ClientDateTime from "./client/variables/ClientDateTime";
|
|
10
9
|
import ClientCurrency from "./client/variables/ClientCurrency";
|
|
11
|
-
export {
|
|
10
|
+
export { useGT, useLocale, useDefaultLocale, ClientValue, ClientNumeric, ClientVar as Var, ClientNum as Num, ClientDateTime as DateTime, ClientCurrency as Currency };
|
|
12
11
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAC/D,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EACH,KAAK,EACL,SAAS,EAAE,gBAAgB,EAC3B,WAAW,EACX,aAAa,EACb,SAAS,IAAI,GAAG,EAChB,SAAS,IAAI,GAAG,EAChB,cAAc,IAAI,QAAQ,EAC1B,cAAc,IAAI,QAAQ,EAC7B,CAAA"}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import T from "./client/T";
|
|
2
1
|
import useDefaultLocale from "./client/hooks/useDefaultLocale";
|
|
3
2
|
import useLocale from "./client/hooks/useLocale";
|
|
4
3
|
import useGT from "./client/hooks/useGT";
|
|
@@ -8,5 +7,5 @@ import ClientVar from "./client/variables/ClientVar";
|
|
|
8
7
|
import ClientNum from "./client/variables/ClientNum";
|
|
9
8
|
import ClientDateTime from "./client/variables/ClientDateTime";
|
|
10
9
|
import ClientCurrency from "./client/variables/ClientCurrency";
|
|
11
|
-
export {
|
|
10
|
+
export { useGT, useLocale, useDefaultLocale, ClientValue, ClientNumeric, ClientVar as Var, ClientNum as Num, ClientDateTime as DateTime, ClientCurrency as Currency };
|
|
12
11
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAC/D,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EACH,KAAK,EACL,SAAS,EAAE,gBAAgB,EAC3B,WAAW,EACX,aAAa,EACb,SAAS,IAAI,GAAG,EAChB,SAAS,IAAI,GAAG,EAChB,cAAc,IAAI,QAAQ,EAC1B,cAAc,IAAI,QAAQ,EAC7B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export default function createNumericValueMarkerComponents(): {
|
|
3
|
+
NumericMarker: {
|
|
4
|
+
({ children }: {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}): React.ReactNode;
|
|
7
|
+
gtTransformation: string;
|
|
8
|
+
};
|
|
9
|
+
ValueMarker: {
|
|
10
|
+
({ children }: {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}): React.ReactNode;
|
|
13
|
+
gtTransformation: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=createNumericValueMarkerComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNumericValueMarkerComponents.d.ts","sourceRoot":"","sources":["../../src/dictionary/createNumericValueMarkerComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAExC,MAAM,CAAC,OAAO,UAAU,kCAAkC;;uBAEjB;YAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;SAAE;;;;uBAK1B;YAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;SAAE;;;EAM9D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function createNumericValueMarkerComponents() {
|
|
2
|
+
const NumericMarker = ({ children }) => {
|
|
3
|
+
return children;
|
|
4
|
+
};
|
|
5
|
+
NumericMarker.gtTransformation = "marker-numeric";
|
|
6
|
+
const ValueMarker = ({ children }) => {
|
|
7
|
+
return children;
|
|
8
|
+
};
|
|
9
|
+
ValueMarker.gtTransformation = "marker-numeric";
|
|
10
|
+
return ({ NumericMarker, ValueMarker });
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=createNumericValueMarkerComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNumericValueMarkerComponents.js","sourceRoot":"","sources":["../../src/dictionary/createNumericValueMarkerComponents.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,kCAAkC;IAEtD,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAA4B,EAAE,EAAE;QAC7D,OAAO,QAAQ,CAAC;IACpB,CAAC,CAAA;IACD,aAAa,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAElD,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAA4B,EAAE,EAAE;QAC3D,OAAO,QAAQ,CAAC;IACpB,CAAC,CAAA;IACD,WAAW,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAEhD,OAAO,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTFunction.d.ts","sourceRoot":"","sources":["../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"createTFunction.d.ts","sourceRoot":"","sources":["../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAI5D,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,CAAC,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,QACrG,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAiEpF"}
|
|
@@ -1,9 +1,56 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import Value from "../server/value/InnerValue";
|
|
14
|
+
import Numeric from "../server/numeric/InnerNumeric";
|
|
2
15
|
export default function createTFunction({ I18NConfig, T, intl }) {
|
|
3
16
|
return (id, options) => {
|
|
4
17
|
const entry = I18NConfig.getDictionaryEntry(id);
|
|
18
|
+
// Turn into an async function if the target is a string
|
|
5
19
|
if (typeof entry === 'string')
|
|
6
20
|
return intl(entry, Object.assign({ id }, options));
|
|
21
|
+
// If a numeric or value is required
|
|
22
|
+
if (options) {
|
|
23
|
+
const locales = [I18NConfig.getLocale(), I18NConfig.getDefaultLocale()];
|
|
24
|
+
const { n, values, ranges, zero, one, two, few, many, other, singular, dual, plural } = options, tOptions = __rest(options, ["n", "values", "ranges", "zero", "one", "two", "few", "many", "other", "singular", "dual", "plural"]);
|
|
25
|
+
if (typeof n === 'number') {
|
|
26
|
+
const innerProps = {
|
|
27
|
+
n,
|
|
28
|
+
ranges,
|
|
29
|
+
zero: zero || (entry === null || entry === void 0 ? void 0 : entry.zero),
|
|
30
|
+
one: one || (entry === null || entry === void 0 ? void 0 : entry.one),
|
|
31
|
+
two: two || (entry === null || entry === void 0 ? void 0 : entry.two),
|
|
32
|
+
few: few || (entry === null || entry === void 0 ? void 0 : entry.few),
|
|
33
|
+
many: many || (entry === null || entry === void 0 ? void 0 : entry.many),
|
|
34
|
+
other: other || (entry === null || entry === void 0 ? void 0 : entry.other),
|
|
35
|
+
singular: singular || (entry === null || entry === void 0 ? void 0 : entry.singular),
|
|
36
|
+
dual: dual || (entry === null || entry === void 0 ? void 0 : entry.dual),
|
|
37
|
+
plural: plural || (entry === null || entry === void 0 ? void 0 : entry.plural)
|
|
38
|
+
};
|
|
39
|
+
if (values) {
|
|
40
|
+
// Numeric + Value
|
|
41
|
+
return (_jsx(T, Object.assign({ id: id }, tOptions, { children: _jsx(Value, { values: values, locales: locales, children: _jsx(Numeric, Object.assign({ locales: locales }, innerProps, { children: entry })) }) })));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Numeric only
|
|
45
|
+
return (_jsx(T, Object.assign({ id: id }, tOptions, { children: _jsx(Numeric, Object.assign({ locales: locales }, innerProps, { children: entry })) })));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (values) {
|
|
49
|
+
// Value only
|
|
50
|
+
return (_jsx(T, Object.assign({ id: id }, tOptions, { children: _jsx(Value, { values: values, locales: locales, children: entry }) })));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// base case, just return T
|
|
7
54
|
return _jsx(T, Object.assign({ id: id }, options, { children: entry }));
|
|
8
55
|
};
|
|
9
56
|
}
|