@tolgee/react 5.4.3 → 5.4.4-prerelease.9b022cf1.0

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.
@@ -0,0 +1,2 @@
1
+ import e,{useState as n,useEffect as t,Suspense as r,useContext as o,useCallback as s,useRef as i}from"react";import{getFallback as c,getFallbackArray as l,getTranslateProps as a}from"@tolgee/web";export*from"@tolgee/web";const u={useSuspense:!0},d=e.createContext(void 0),p=({tolgee:o,options:s,children:i,fallback:c})=>{const[l,a]=n(!o.isLoaded());t((()=>(o.run().finally((()=>{a(!1)})),()=>{o.stop()})),[o]);const p=Object.assign(Object.assign({},u),s);return p.useSuspense?e.createElement(d.Provider,{value:{tolgee:o,options:p}},l?c:e.createElement(r,{fallback:c||null},i)):e.createElement(d.Provider,{value:{tolgee:o,options:p}},l?c:i)};let b;const g=e=>n=>(b={tolgee:n,options:Object.assign(Object.assign({},u),e)},n);const f=()=>{const e=o(d)||b;if(!e)throw new Error("Couldn't find tolgee instance, did you forgot to use `TolgeeProvider`?");return e},m=()=>{const[e,t]=n(0);return{instance:e,rerender:s((()=>{t((e=>e+1))}),[t])}},v=(e,n)=>{const{tolgee:r,options:o}=f(),a=c(e),u=l(a).join(":"),d=Object.assign(Object.assign({},o),n),{rerender:p,instance:b}=m(),g=i(),v=i([]);v.current=[];const h=r.isLoaded(a);t((()=>{const e=r.onNsUpdate(p);return g.current=e,h||e.subscribeNs(a),v.current.forEach((n=>{e.subscribeNs(n)})),()=>{e.unsubscribe()}}),[h,u,r]),t((()=>(r.addActiveNs(a),()=>r.removeActiveNs(a))),[u,r]);const j=s((e=>{var n;const t=null!==(n=e.ns)&&void 0!==n?n:null==a?void 0:a[0];return(e=>{var n;v.current.push(e),null===(n=g.current)||void 0===n||n.subscribeNs(e)})(t),r.t(Object.assign(Object.assign({},e),{ns:t}))}),[r,b]);if(d.useSuspense&&!h)throw r.addActiveNs(a,!0);return{t:j,isLoading:!h}},h=(e,n)=>{const{t:t,isLoading:r}=v(e,n);return{t:s(((...e)=>{const n=a(...e);return t(n)}),[t]),isLoading:r}},j=n=>{if(!n)return;const t={};return Object.entries(n||{}).forEach((([n,r])=>{if("function"==typeof r)t[n]=e=>r(E(e));else if(e.isValidElement(r)){const o=r;t[n]=n=>void 0!==o.props.children?e.cloneElement(o):e.cloneElement(o,{},E(n))}else t[n]=r})),t},E=n=>Array.isArray(n)?e.Children.toArray(n):n,y=n=>{const t=n.keyName||n.children;void 0===t&&console.error("T component: keyName not defined");const r=n.defaultValue||(n.keyName?n.children:void 0),{t:o}=v(),s=E(o({key:t,params:j(n.params),defaultValue:r,noWrap:n.noWrap,ns:n.ns}));return e.createElement(e.Fragment,null,s)},N=e=>{const{tolgee:n}=f(),{rerender:r}=m();return t((()=>{const t=null==e?void 0:e.map((e=>n.on(e,r)));return()=>{null==t||t.forEach((e=>e.unsubscribe()))}}),[null==e?void 0:e.join(":")]),n};export{g as GlobalContextPlugin,y as T,p as TolgeeProvider,d as TolgeeProviderContext,N as useTolgee,h as useTranslate};
2
+ //# sourceMappingURL=tolgee-react.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tolgee-react.esm.min.js","sources":["../src/TolgeeProvider.tsx","../src/GlobalContextPlugin.tsx","../src/useTolgeeContext.ts","../src/hooks.ts","../src/useTranslateInternal.ts","../src/useTranslate.ts","../src/tagsTools.tsx","../src/T.tsx","../src/useTolgee.ts"],"sourcesContent":["import React, { Suspense, useEffect, useState } from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\nimport { ReactOptions, TolgeeReactContext } from './types';\n\nexport const DEFAULT_REACT_OPTIONS: ReactOptions = {\n useSuspense: true,\n};\n\nexport const TolgeeProviderContext = React.createContext<\n TolgeeReactContext | undefined\n>(undefined);\n\ntype Props = {\n children?: React.ReactNode;\n tolgee: TolgeeInstance;\n options?: ReactOptions;\n fallback?: React.ReactNode;\n};\n\nexport const TolgeeProvider: React.FC<Props> = ({\n tolgee,\n options,\n children,\n fallback,\n}) => {\n const [loading, setLoading] = useState(!tolgee.isLoaded());\n\n useEffect(() => {\n tolgee.run().finally(() => {\n setLoading(false);\n });\n return () => {\n tolgee.stop();\n };\n }, [tolgee]);\n\n const optionsWithDefault = { ...DEFAULT_REACT_OPTIONS, ...options };\n\n if (optionsWithDefault.useSuspense) {\n return (\n <TolgeeProviderContext.Provider\n value={{ tolgee, options: optionsWithDefault }}\n >\n {loading ? (\n fallback\n ) : (\n <Suspense fallback={fallback || null}>{children}</Suspense>\n )}\n </TolgeeProviderContext.Provider>\n );\n }\n\n return (\n <TolgeeProviderContext.Provider\n value={{ tolgee, options: optionsWithDefault }}\n >\n {loading ? fallback : children}\n </TolgeeProviderContext.Provider>\n );\n};\n","import type { TolgeePlugin } from '@tolgee/web';\nimport { DEFAULT_REACT_OPTIONS } from './TolgeeProvider';\nimport type { ReactOptions, TolgeeReactContext } from './types';\n\nlet globalContext: TolgeeReactContext | undefined;\n\nexport const GlobalContextPlugin =\n (options?: Partial<ReactOptions>): TolgeePlugin =>\n (tolgee) => {\n globalContext = {\n tolgee,\n options: { ...DEFAULT_REACT_OPTIONS, ...options },\n };\n return tolgee;\n };\n\nexport function getGlobalContext() {\n return globalContext;\n}\n","import { useContext } from 'react';\nimport { getGlobalContext } from './GlobalContextPlugin';\nimport { TolgeeProviderContext } from './TolgeeProvider';\n\nexport const useTolgeeContext = () => {\n const context = useContext(TolgeeProviderContext) || getGlobalContext();\n if (!context) {\n throw new Error(\n \"Couldn't find tolgee instance, did you forgot to use `TolgeeProvider`?\"\n );\n }\n return context;\n};\n","import { useCallback, useState } from 'react';\n\nexport const useRerender = () => {\n const [instance, setCounter] = useState(0);\n\n const rerender = useCallback(() => {\n setCounter((num) => num + 1);\n }, [setCounter]);\n return { instance, rerender };\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport {\n SubscriptionSelective,\n TranslateProps,\n NsFallback,\n getFallbackArray,\n getFallback,\n} from '@tolgee/web';\n\nimport { useTolgeeContext } from './useTolgeeContext';\nimport { ReactOptions } from './types';\nimport { useRerender } from './hooks';\n\nexport const useTranslateInternal = (\n ns?: NsFallback,\n options?: ReactOptions\n) => {\n const { tolgee, options: defaultOptions } = useTolgeeContext();\n const namespaces = getFallback(ns);\n const namespacesJoined = getFallbackArray(namespaces).join(':');\n\n const currentOptions = {\n ...defaultOptions,\n ...options,\n };\n\n // dummy state to enable re-rendering\n const { rerender, instance } = useRerender();\n\n const subscriptionRef = useRef<SubscriptionSelective>();\n\n const subscriptionQueue = useRef([] as NsFallback[]);\n subscriptionQueue.current = [];\n\n const subscribeToNs = (ns: NsFallback) => {\n subscriptionQueue.current.push(ns);\n subscriptionRef.current?.subscribeNs(ns);\n };\n\n const isLoaded = tolgee.isLoaded(namespaces);\n\n useEffect(() => {\n const subscription = tolgee.onNsUpdate(rerender);\n subscriptionRef.current = subscription;\n if (!isLoaded) {\n subscription.subscribeNs(namespaces);\n }\n subscriptionQueue.current.forEach((ns) => {\n subscription!.subscribeNs(ns);\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [isLoaded, namespacesJoined, tolgee]);\n\n useEffect(() => {\n tolgee.addActiveNs(namespaces);\n return () => tolgee.removeActiveNs(namespaces);\n }, [namespacesJoined, tolgee]);\n\n const t = useCallback(\n (props: TranslateProps<any>) => {\n const fallbackNs = props.ns ?? namespaces?.[0];\n subscribeToNs(fallbackNs);\n return tolgee.t({ ...props, ns: fallbackNs }) as any;\n },\n [tolgee, instance]\n );\n\n if (currentOptions.useSuspense && !isLoaded) {\n throw tolgee.addActiveNs(namespaces, true);\n }\n\n return { t, isLoading: !isLoaded };\n};\n","import { useCallback } from 'react';\nimport { TFnType, getTranslateProps, DefaultParamType } from '@tolgee/web';\n\nimport { useTranslateInternal } from './useTranslateInternal';\nimport { ReactOptions } from './types';\n\nexport const useTranslate = (\n ns?: string[] | string,\n options?: ReactOptions\n) => {\n const { t: tInternal, isLoading } = useTranslateInternal(ns, options);\n\n const t: TFnType<DefaultParamType, string> = useCallback(\n (...params: any) => {\n // @ts-ignore\n const props = getTranslateProps(...params);\n return tInternal(props);\n },\n [tInternal]\n );\n\n return { t, isLoading };\n};\n","import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children !== undefined\n ? React.cloneElement(el)\n : React.cloneElement(el, {}, addReactKeys(chunk));\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import { NsType, TranslateParams } from '@tolgee/web';\nimport React, { FunctionComponent } from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\n\nimport { ParamsTags } from './types';\nimport { useTranslateInternal } from './useTranslateInternal';\n\ntype TProps = {\n params?: TranslateParams<ParamsTags>;\n children?: string;\n noWrap?: boolean;\n keyName?: string;\n ns?: NsType;\n defaultValue?: string;\n};\n\nexport const T: FunctionComponent<TProps> = (props: TProps) => {\n const key = props.keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue || (props.keyName ? props.children : undefined);\n\n const { t } = useTranslateInternal();\n\n const translation = addReactKeys(\n t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n })\n );\n\n return <>{translation}</>;\n};\n","import { TolgeeEvent, TolgeeInstance } from '@tolgee/web';\nimport { useEffect } from 'react';\nimport { useRerender } from './hooks';\nimport { useTolgeeContext } from './useTolgeeContext';\n\nexport const useTolgee = (events?: TolgeeEvent[]): TolgeeInstance => {\n const { tolgee } = useTolgeeContext();\n\n const { rerender } = useRerender();\n\n useEffect(() => {\n const listeners = events?.map((e) => tolgee.on(e, rerender));\n return () => {\n listeners?.forEach((listener) => listener.unsubscribe());\n };\n }, [events?.join(':')]);\n\n return tolgee;\n};\n"],"names":["DEFAULT_REACT_OPTIONS","useSuspense","TolgeeProviderContext","React","createContext","undefined","TolgeeProvider","tolgee","options","children","fallback","loading","setLoading","useState","isLoaded","useEffect","run","finally","stop","optionsWithDefault","Object","assign","createElement","Provider","value","Suspense","globalContext","GlobalContextPlugin","useTolgeeContext","context","useContext","Error","useRerender","instance","setCounter","rerender","useCallback","num","useTranslateInternal","ns","defaultOptions","namespaces","getFallback","namespacesJoined","getFallbackArray","join","currentOptions","subscriptionRef","useRef","subscriptionQueue","current","subscription","onNsUpdate","subscribeNs","forEach","unsubscribe","addActiveNs","removeActiveNs","t","props","fallbackNs","_a","push","subscribeToNs","isLoading","useTranslate","tInternal","params","getTranslateProps","wrapTagHandlers","result","entries","key","chunk","addReactKeys","isValidElement","el","cloneElement","val","Array","isArray","Children","toArray","T","keyName","console","error","defaultValue","translation","noWrap","Fragment","useTolgee","events","listeners","map","e","on","listener"],"mappings":"8NAIO,MAAMA,EAAsC,CACjDC,aAAa,GAGFC,EAAwBC,EAAMC,mBAEzCC,GASWC,EAAkC,EAC7CC,SACAC,UACAC,WACAC,eAEA,MAAOC,EAASC,GAAcC,GAAUN,EAAOO,YAE/CC,GAAU,KACRR,EAAOS,MAAMC,SAAQ,KACnBL,GAAW,EAAM,IAEZ,KACLL,EAAOW,MAAM,IAEd,CAACX,IAEJ,MAAMY,EAA0BC,OAAAC,OAAAD,OAAAC,OAAA,GAAArB,GAA0BQ,GAE1D,OAAIW,EAAmBlB,YAEnBE,EAACmB,cAAApB,EAAsBqB,SAAQ,CAC7BC,MAAO,CAAEjB,SAAQC,QAASW,I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AMa,EAAMb,EAAMyB,SAAWzB,EAAMlD,cACvBJ,IAARmE,GAEFa,QAAQC,MAAM,oCAEhB,MAAMC,EACJ5B,EAAM4B,eAAiB5B,EAAMyB,QAAUzB,EAAMlD,cAAWJ,IAEpDqD,EAAEA,GAAMpB,IAERkD,EAAcd,EAClBhB,EAAE,CACAc,IAAKA,EACLL,OAAQE,EAAgBV,EAAMQ,QAC9BoB,eACAE,OAAQ9B,EAAM8B,OACdlD,GAAIoB,EAAMpB,MAId,OAAOpC,EAAAmB,cAAAnB,EAAAuF,SAAA,KAAGF,EAAe,EChCdG,EAAaC,IACxB,MAAMrF,OAAEA,GAAWqB,KAEbO,SAAEA,GAAaH,IASrB,OAPAjB,GAAU,KACR,MAAM8E,EAAYD,eAAAA,EAAQE,KAAKC,GAAMxF,EAAOyF,GAAGD,EAAG5D,KAClD,MAAO,KACL0D,SAAAA,EAAWvC,SAAS2C,GAAaA,EAAS1C,eAAc,CACzD,GACA,CAACqC,aAAA,EAAAA,EAAQ/C,KAAK,OAEVtC,CAAM"}
@@ -0,0 +1,174 @@
1
+ import React, { useState, useEffect, Suspense, useContext, useCallback, useRef } from 'react';
2
+ import { getFallback, getFallbackArray, getTranslateProps } from '@tolgee/web';
3
+ export * from '@tolgee/web';
4
+
5
+ const DEFAULT_REACT_OPTIONS = {
6
+ useSuspense: true,
7
+ };
8
+ const TolgeeProviderContext = React.createContext(undefined);
9
+ const TolgeeProvider = ({ tolgee, options, children, fallback, }) => {
10
+ const [loading, setLoading] = useState(!tolgee.isLoaded());
11
+ useEffect(() => {
12
+ tolgee.run().finally(() => {
13
+ setLoading(false);
14
+ });
15
+ return () => {
16
+ tolgee.stop();
17
+ };
18
+ }, [tolgee]);
19
+ const optionsWithDefault = Object.assign(Object.assign({}, DEFAULT_REACT_OPTIONS), options);
20
+ if (optionsWithDefault.useSuspense) {
21
+ return (React.createElement(TolgeeProviderContext.Provider, { value: { tolgee, options: optionsWithDefault } }, loading ? (fallback) : (React.createElement(Suspense, { fallback: fallback || null }, children))));
22
+ }
23
+ return (React.createElement(TolgeeProviderContext.Provider, { value: { tolgee, options: optionsWithDefault } }, loading ? fallback : children));
24
+ };
25
+
26
+ let globalContext;
27
+ const GlobalContextPlugin = (options) => (tolgee) => {
28
+ globalContext = {
29
+ tolgee,
30
+ options: Object.assign(Object.assign({}, DEFAULT_REACT_OPTIONS), options),
31
+ };
32
+ return tolgee;
33
+ };
34
+ function getGlobalContext() {
35
+ return globalContext;
36
+ }
37
+
38
+ const useTolgeeContext = () => {
39
+ const context = useContext(TolgeeProviderContext) || getGlobalContext();
40
+ if (!context) {
41
+ throw new Error("Couldn't find tolgee instance, did you forgot to use `TolgeeProvider`?");
42
+ }
43
+ return context;
44
+ };
45
+
46
+ const useRerender = () => {
47
+ const [instance, setCounter] = useState(0);
48
+ const rerender = useCallback(() => {
49
+ setCounter((num) => num + 1);
50
+ }, [setCounter]);
51
+ return { instance, rerender };
52
+ };
53
+
54
+ const useTranslateInternal = (ns, options) => {
55
+ const { tolgee, options: defaultOptions } = useTolgeeContext();
56
+ const namespaces = getFallback(ns);
57
+ const namespacesJoined = getFallbackArray(namespaces).join(':');
58
+ const currentOptions = Object.assign(Object.assign({}, defaultOptions), options);
59
+ // dummy state to enable re-rendering
60
+ const { rerender, instance } = useRerender();
61
+ const subscriptionRef = useRef();
62
+ const subscriptionQueue = useRef([]);
63
+ subscriptionQueue.current = [];
64
+ const subscribeToNs = (ns) => {
65
+ var _a;
66
+ subscriptionQueue.current.push(ns);
67
+ (_a = subscriptionRef.current) === null || _a === void 0 ? void 0 : _a.subscribeNs(ns);
68
+ };
69
+ const isLoaded = tolgee.isLoaded(namespaces);
70
+ useEffect(() => {
71
+ const subscription = tolgee.onNsUpdate(rerender);
72
+ subscriptionRef.current = subscription;
73
+ if (!isLoaded) {
74
+ subscription.subscribeNs(namespaces);
75
+ }
76
+ subscriptionQueue.current.forEach((ns) => {
77
+ subscription.subscribeNs(ns);
78
+ });
79
+ return () => {
80
+ subscription.unsubscribe();
81
+ };
82
+ }, [isLoaded, namespacesJoined, tolgee]);
83
+ useEffect(() => {
84
+ tolgee.addActiveNs(namespaces);
85
+ return () => tolgee.removeActiveNs(namespaces);
86
+ }, [namespacesJoined, tolgee]);
87
+ const t = useCallback((props) => {
88
+ var _a;
89
+ const fallbackNs = (_a = props.ns) !== null && _a !== void 0 ? _a : namespaces === null || namespaces === void 0 ? void 0 : namespaces[0];
90
+ subscribeToNs(fallbackNs);
91
+ return tolgee.t(Object.assign(Object.assign({}, props), { ns: fallbackNs }));
92
+ }, [tolgee, instance]);
93
+ if (currentOptions.useSuspense && !isLoaded) {
94
+ throw tolgee.addActiveNs(namespaces, true);
95
+ }
96
+ return { t, isLoading: !isLoaded };
97
+ };
98
+
99
+ const useTranslate = (ns, options) => {
100
+ const { t: tInternal, isLoading } = useTranslateInternal(ns, options);
101
+ const t = useCallback((...params) => {
102
+ // @ts-ignore
103
+ const props = getTranslateProps(...params);
104
+ return tInternal(props);
105
+ }, [tInternal]);
106
+ return { t, isLoading };
107
+ };
108
+
109
+ const wrapTagHandlers = (params) => {
110
+ if (!params) {
111
+ return undefined;
112
+ }
113
+ const result = {};
114
+ Object.entries(params || {}).forEach(([key, value]) => {
115
+ if (typeof value === 'function') {
116
+ result[key] = (chunk) => {
117
+ return value(addReactKeys(chunk));
118
+ };
119
+ }
120
+ else if (React.isValidElement(value)) {
121
+ const el = value;
122
+ result[key] = (chunk) => {
123
+ return el.props.children !== undefined
124
+ ? React.cloneElement(el)
125
+ : React.cloneElement(el, {}, addReactKeys(chunk));
126
+ };
127
+ }
128
+ else {
129
+ result[key] = value;
130
+ }
131
+ });
132
+ return result;
133
+ };
134
+ const addReactKeys = (val) => {
135
+ if (Array.isArray(val)) {
136
+ return React.Children.toArray(val);
137
+ }
138
+ else {
139
+ return val;
140
+ }
141
+ };
142
+
143
+ const T = (props) => {
144
+ const key = props.keyName || props.children;
145
+ if (key === undefined) {
146
+ // eslint-disable-next-line no-console
147
+ console.error('T component: keyName not defined');
148
+ }
149
+ const defaultValue = props.defaultValue || (props.keyName ? props.children : undefined);
150
+ const { t } = useTranslateInternal();
151
+ const translation = addReactKeys(t({
152
+ key: key,
153
+ params: wrapTagHandlers(props.params),
154
+ defaultValue,
155
+ noWrap: props.noWrap,
156
+ ns: props.ns,
157
+ }));
158
+ return React.createElement(React.Fragment, null, translation);
159
+ };
160
+
161
+ const useTolgee = (events) => {
162
+ const { tolgee } = useTolgeeContext();
163
+ const { rerender } = useRerender();
164
+ useEffect(() => {
165
+ const listeners = events === null || events === void 0 ? void 0 : events.map((e) => tolgee.on(e, rerender));
166
+ return () => {
167
+ listeners === null || listeners === void 0 ? void 0 : listeners.forEach((listener) => listener.unsubscribe());
168
+ };
169
+ }, [events === null || events === void 0 ? void 0 : events.join(':')]);
170
+ return tolgee;
171
+ };
172
+
173
+ export { GlobalContextPlugin, T, TolgeeProvider, TolgeeProviderContext, useTolgee, useTranslate };
174
+ //# sourceMappingURL=tolgee-react.esm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tolgee-react.esm.mjs","sources":["../src/TolgeeProvider.tsx","../src/GlobalContextPlugin.tsx","../src/useTolgeeContext.ts","../src/hooks.ts","../src/useTranslateInternal.ts","../src/useTranslate.ts","../src/tagsTools.tsx","../src/T.tsx","../src/useTolgee.ts"],"sourcesContent":["import React, { Suspense, useEffect, useState } from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\nimport { ReactOptions, TolgeeReactContext } from './types';\n\nexport const DEFAULT_REACT_OPTIONS: ReactOptions = {\n useSuspense: true,\n};\n\nexport const TolgeeProviderContext = React.createContext<\n TolgeeReactContext | undefined\n>(undefined);\n\ntype Props = {\n children?: React.ReactNode;\n tolgee: TolgeeInstance;\n options?: ReactOptions;\n fallback?: React.ReactNode;\n};\n\nexport const TolgeeProvider: React.FC<Props> = ({\n tolgee,\n options,\n children,\n fallback,\n}) => {\n const [loading, setLoading] = useState(!tolgee.isLoaded());\n\n useEffect(() => {\n tolgee.run().finally(() => {\n setLoading(false);\n });\n return () => {\n tolgee.stop();\n };\n }, [tolgee]);\n\n const optionsWithDefault = { ...DEFAULT_REACT_OPTIONS, ...options };\n\n if (optionsWithDefault.useSuspense) {\n return (\n <TolgeeProviderContext.Provider\n value={{ tolgee, options: optionsWithDefault }}\n >\n {loading ? (\n fallback\n ) : (\n <Suspense fallback={fallback || null}>{children}</Suspense>\n )}\n </TolgeeProviderContext.Provider>\n );\n }\n\n return (\n <TolgeeProviderContext.Provider\n value={{ tolgee, options: optionsWithDefault }}\n >\n {loading ? fallback : children}\n </TolgeeProviderContext.Provider>\n );\n};\n","import type { TolgeePlugin } from '@tolgee/web';\nimport { DEFAULT_REACT_OPTIONS } from './TolgeeProvider';\nimport type { ReactOptions, TolgeeReactContext } from './types';\n\nlet globalContext: TolgeeReactContext | undefined;\n\nexport const GlobalContextPlugin =\n (options?: Partial<ReactOptions>): TolgeePlugin =>\n (tolgee) => {\n globalContext = {\n tolgee,\n options: { ...DEFAULT_REACT_OPTIONS, ...options },\n };\n return tolgee;\n };\n\nexport function getGlobalContext() {\n return globalContext;\n}\n","import { useContext } from 'react';\nimport { getGlobalContext } from './GlobalContextPlugin';\nimport { TolgeeProviderContext } from './TolgeeProvider';\n\nexport const useTolgeeContext = () => {\n const context = useContext(TolgeeProviderContext) || getGlobalContext();\n if (!context) {\n throw new Error(\n \"Couldn't find tolgee instance, did you forgot to use `TolgeeProvider`?\"\n );\n }\n return context;\n};\n","import { useCallback, useState } from 'react';\n\nexport const useRerender = () => {\n const [instance, setCounter] = useState(0);\n\n const rerender = useCallback(() => {\n setCounter((num) => num + 1);\n }, [setCounter]);\n return { instance, rerender };\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport {\n SubscriptionSelective,\n TranslateProps,\n NsFallback,\n getFallbackArray,\n getFallback,\n} from '@tolgee/web';\n\nimport { useTolgeeContext } from './useTolgeeContext';\nimport { ReactOptions } from './types';\nimport { useRerender } from './hooks';\n\nexport const useTranslateInternal = (\n ns?: NsFallback,\n options?: ReactOptions\n) => {\n const { tolgee, options: defaultOptions } = useTolgeeContext();\n const namespaces = getFallback(ns);\n const namespacesJoined = getFallbackArray(namespaces).join(':');\n\n const currentOptions = {\n ...defaultOptions,\n ...options,\n };\n\n // dummy state to enable re-rendering\n const { rerender, instance } = useRerender();\n\n const subscriptionRef = useRef<SubscriptionSelective>();\n\n const subscriptionQueue = useRef([] as NsFallback[]);\n subscriptionQueue.current = [];\n\n const subscribeToNs = (ns: NsFallback) => {\n subscriptionQueue.current.push(ns);\n subscriptionRef.current?.subscribeNs(ns);\n };\n\n const isLoaded = tolgee.isLoaded(namespaces);\n\n useEffect(() => {\n const subscription = tolgee.onNsUpdate(rerender);\n subscriptionRef.current = subscription;\n if (!isLoaded) {\n subscription.subscribeNs(namespaces);\n }\n subscriptionQueue.current.forEach((ns) => {\n subscription!.subscribeNs(ns);\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [isLoaded, namespacesJoined, tolgee]);\n\n useEffect(() => {\n tolgee.addActiveNs(namespaces);\n return () => tolgee.removeActiveNs(namespaces);\n }, [namespacesJoined, tolgee]);\n\n const t = useCallback(\n (props: TranslateProps<any>) => {\n const fallbackNs = props.ns ?? namespaces?.[0];\n subscribeToNs(fallbackNs);\n return tolgee.t({ ...props, ns: fallbackNs }) as any;\n },\n [tolgee, instance]\n );\n\n if (currentOptions.useSuspense && !isLoaded) {\n throw tolgee.addActiveNs(namespaces, true);\n }\n\n return { t, isLoading: !isLoaded };\n};\n","import { useCallback } from 'react';\nimport { TFnType, getTranslateProps, DefaultParamType } from '@tolgee/web';\n\nimport { useTranslateInternal } from './useTranslateInternal';\nimport { ReactOptions } from './types';\n\nexport const useTranslate = (\n ns?: string[] | string,\n options?: ReactOptions\n) => {\n const { t: tInternal, isLoading } = useTranslateInternal(ns, options);\n\n const t: TFnType<DefaultParamType, string> = useCallback(\n (...params: any) => {\n // @ts-ignore\n const props = getTranslateProps(...params);\n return tInternal(props);\n },\n [tInternal]\n );\n\n return { t, isLoading };\n};\n","import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children !== undefined\n ? React.cloneElement(el)\n : React.cloneElement(el, {}, addReactKeys(chunk));\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import { NsType, TranslateParams } from '@tolgee/web';\nimport React, { FunctionComponent } from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\n\nimport { ParamsTags } from './types';\nimport { useTranslateInternal } from './useTranslateInternal';\n\ntype TProps = {\n params?: TranslateParams<ParamsTags>;\n children?: string;\n noWrap?: boolean;\n keyName?: string;\n ns?: NsType;\n defaultValue?: string;\n};\n\nexport const T: FunctionComponent<TProps> = (props: TProps) => {\n const key = props.keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue || (props.keyName ? props.children : undefined);\n\n const { t } = useTranslateInternal();\n\n const translation = addReactKeys(\n t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n })\n );\n\n return <>{translation}</>;\n};\n","import { TolgeeEvent, TolgeeInstance } from '@tolgee/web';\nimport { useEffect } from 'react';\nimport { useRerender } from './hooks';\nimport { useTolgeeContext } from './useTolgeeContext';\n\nexport const useTolgee = (events?: TolgeeEvent[]): TolgeeInstance => {\n const { tolgee } = useTolgeeContext();\n\n const { rerender } = useRerender();\n\n useEffect(() => {\n const listeners = events?.map((e) => tolgee.on(e, rerender));\n return () => {\n listeners?.forEach((listener) => listener.unsubscribe());\n };\n }, [events?.join(':')]);\n\n return tolgee;\n};\n"],"names":[],"mappings":";;;;AAIO,MAAM,qBAAqB,GAAiB;AACjD,IAAA,WAAW,EAAE,IAAI;CAClB,CAAC;AAEW,MAAA,qBAAqB,GAAG,KAAK,CAAC,aAAa,CAEtD,SAAS,EAAE;AASN,MAAM,cAAc,GAAoB,CAAC,EAC9C,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,KAAI;AACH,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE3D,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAK;YACxB,UAAU,CAAC,KAAK,CAAC,CAAC;AACpB,SAAC,CAAC,CAAC;AACH,QAAA,OAAO,MAAK;YACV,MAAM,CAAC,IAAI,EAAE,CAAC;AAChB,SAAC,CAAC;AACJ,KAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEb,IAAA,MAAM,kBAAkB,GAAQ,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,qBAAqB,CAAK,EAAA,OAAO,CAAE,CAAC;IAEpE,IAAI,kBAAkB,CAAC,WAAW,EAAE;AAClC,QAAA,QACE,KAAC,CAAA,aAAA,CAAA,qBAAqB,CAAC,QAAQ,EAAA,EAC7B,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAE7C,EAAA,OAAO,IACN,QAAQ,KAER,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAC,EAAA,QAAQ,EAAE,QAAQ,IAAI,IAAI,EAAG,EAAA,QAAQ,C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MAAA,SAAS,GAAG,CAAC,MAAsB,KAAoB;AAClE,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;AAEtC,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;IAEnC,SAAS,CAAC,MAAK;QACb,MAAM,SAAS,GAAG,MAAM,KAAN,IAAA,IAAA,MAAM,uBAAN,MAAM,CAAE,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7D,QAAA,OAAO,MAAK;AACV,YAAA,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3D,SAAC,CAAC;AACJ,KAAC,EAAE,CAAC,MAAM,KAAA,IAAA,IAAN,MAAM,KAAN,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,MAAM,CAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAExB,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@tolgee/react",
3
- "version": "5.4.3",
3
+ "version": "5.4.4-prerelease.9b022cf1.0",
4
4
  "description": "React implementation for tolgee localization framework",
5
5
  "main": "./dist/tolgee-react.cjs.js",
6
6
  "module": "./dist/tolgee-react.esm.js",
7
7
  "types": "lib/index.d.ts",
8
- "type": "module",
9
8
  "repository": "https://github.com/tolgee/tolgee-js",
10
9
  "homepage": "https://tolgee.io",
11
10
  "keywords": [
@@ -39,7 +38,7 @@
39
38
  "react": "^16.14.0 || ^17.0.1 || ^18.1.0"
40
39
  },
41
40
  "dependencies": {
42
- "@tolgee/web": "5.4.2"
41
+ "@tolgee/web": "5.4.4-prerelease.9b022cf1.0"
43
42
  },
44
43
  "devDependencies": {
45
44
  "@rollup/plugin-node-resolve": "^14.1.0",
@@ -47,8 +46,8 @@
47
46
  "@testing-library/dom": "^8.7.2",
48
47
  "@testing-library/jest-dom": "^5.11.4",
49
48
  "@testing-library/react": "^12.1.2",
50
- "@tolgee/format-icu": "5.4.0",
51
- "@tolgee/testing": "5.4.1",
49
+ "@tolgee/format-icu": "5.4.4-prerelease.9b022cf1.0",
50
+ "@tolgee/testing": "5.4.4-prerelease.9b022cf1.0",
52
51
  "@types/jest": "^27.0.2",
53
52
  "@types/node": "^17.0.8",
54
53
  "@types/react": "^17.0.1",
@@ -73,7 +72,7 @@
73
72
  "exports": {
74
73
  ".": {
75
74
  "require": "./dist/tolgee-react.cjs.js",
76
- "import": "./dist/tolgee-react.esm.js"
75
+ "import": "./dist/tolgee-react.esm.mjs"
77
76
  },
78
77
  "./package.json": "./package.json"
79
78
  },
@@ -81,5 +80,5 @@
81
80
  "access": "public"
82
81
  },
83
82
  "sideEffects": false,
84
- "gitHead": "6e93df044989489b2edbba8370027469ca850565"
83
+ "gitHead": "ec81b6197e2d33b4bd7403d5af9a7d3a7b2b5e42"
85
84
  }