react-i18next 15.5.1 → 15.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 15.5.3
2
+
3
+ chore: update `@babel/runtime` [1851](https://github.com/i18next/react-i18next/pull/1851)
4
+
5
+ ### 15.5.2
6
+
7
+ fix element.ref access issue with react 19 [1846](https://github.com/i18next/react-i18next/pull/1846)
8
+
1
9
  ### 15.5.1
2
10
 
3
11
  add typescript as optional peer dependency [1843](https://github.com/i18next/react-i18next/pull/1843)
@@ -159,8 +159,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
159
159
  });
160
160
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
161
161
  };
162
- const hasLoadedNamespace = function (ns, i18n) {
163
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
162
+ const hasLoadedNamespace = (ns, i18n, options = {}) => {
164
163
  if (!i18n.languages || !i18n.languages.length) {
165
164
  warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
166
165
  languages: i18n.languages
@@ -214,8 +213,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
214
213
  useSuspense: true,
215
214
  unescape
216
215
  };
217
- const setDefaults = function () {
218
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
216
+ const setDefaults = (options = {}) => {
219
217
  defaultOptions = {
220
218
  ...defaultOptions,
221
219
  ...options
@@ -352,7 +350,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
352
350
  return react.createElement(c.type, {
353
351
  ...props,
354
352
  key: i,
355
- ref: c.ref
353
+ ref: c.props.ref ?? c.ref
356
354
  }, isVoid ? null : inner);
357
355
  }));
358
356
  }
@@ -467,23 +465,22 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
467
465
  });
468
466
  return null;
469
467
  };
470
- function Trans$1(_ref) {
471
- let {
472
- children,
473
- count,
474
- parent,
475
- i18nKey,
476
- context,
477
- tOptions = {},
478
- values,
479
- defaults,
480
- components,
481
- ns,
482
- i18n: i18nFromProps,
483
- t: tFromProps,
484
- shouldUnescape,
485
- ...additionalProps
486
- } = _ref;
468
+ function Trans$1({
469
+ children,
470
+ count,
471
+ parent,
472
+ i18nKey,
473
+ context,
474
+ tOptions = {},
475
+ values,
476
+ defaults,
477
+ components,
478
+ ns,
479
+ i18n: i18nFromProps,
480
+ t: tFromProps,
481
+ shouldUnescape,
482
+ ...additionalProps
483
+ }) {
487
484
  const i18n = i18nFromProps || getI18n();
488
485
  if (!i18n) {
489
486
  warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -581,23 +578,22 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
581
578
  return ret;
582
579
  };
583
580
 
584
- function Trans(_ref) {
585
- let {
586
- children,
587
- count,
588
- parent,
589
- i18nKey,
590
- context,
591
- tOptions = {},
592
- values,
593
- defaults,
594
- components,
595
- ns,
596
- i18n: i18nFromProps,
597
- t: tFromProps,
598
- shouldUnescape,
599
- ...additionalProps
600
- } = _ref;
581
+ function Trans({
582
+ children,
583
+ count,
584
+ parent,
585
+ i18nKey,
586
+ context,
587
+ tOptions = {},
588
+ values,
589
+ defaults,
590
+ components,
591
+ ns,
592
+ i18n: i18nFromProps,
593
+ t: tFromProps,
594
+ shouldUnescape,
595
+ ...additionalProps
596
+ }) {
601
597
  const {
602
598
  i18n: i18nFromContext,
603
599
  defaultNS: defaultNSFromContext
@@ -631,8 +627,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
631
627
  };
632
628
  const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
633
629
  const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
634
- const useTranslation = function (ns) {
635
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
630
+ const useTranslation = (ns, props = {}) => {
636
631
  const {
637
632
  i18n: i18nFromProps
638
633
  } = props;
@@ -728,46 +723,41 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
728
723
  });
729
724
  };
730
725
 
731
- const withTranslation = function (ns) {
732
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
733
- return function Extend(WrappedComponent) {
734
- function I18nextWithTranslation(_ref) {
735
- let {
736
- forwardedRef,
737
- ...rest
738
- } = _ref;
739
- const [t, i18n, ready] = useTranslation(ns, {
740
- ...rest,
741
- keyPrefix: options.keyPrefix
742
- });
743
- const passDownProps = {
744
- ...rest,
745
- t,
746
- i18n,
747
- tReady: ready
748
- };
749
- if (options.withRef && forwardedRef) {
750
- passDownProps.ref = forwardedRef;
751
- } else if (!options.withRef && forwardedRef) {
752
- passDownProps.forwardedRef = forwardedRef;
753
- }
754
- return react.createElement(WrappedComponent, passDownProps);
726
+ const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
727
+ function I18nextWithTranslation({
728
+ forwardedRef,
729
+ ...rest
730
+ }) {
731
+ const [t, i18n, ready] = useTranslation(ns, {
732
+ ...rest,
733
+ keyPrefix: options.keyPrefix
734
+ });
735
+ const passDownProps = {
736
+ ...rest,
737
+ t,
738
+ i18n,
739
+ tReady: ready
740
+ };
741
+ if (options.withRef && forwardedRef) {
742
+ passDownProps.ref = forwardedRef;
743
+ } else if (!options.withRef && forwardedRef) {
744
+ passDownProps.forwardedRef = forwardedRef;
755
745
  }
756
- I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
757
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
758
- const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
759
- forwardedRef: ref
760
- }));
761
- return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
762
- };
746
+ return react.createElement(WrappedComponent, passDownProps);
747
+ }
748
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
749
+ I18nextWithTranslation.WrappedComponent = WrappedComponent;
750
+ const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
751
+ forwardedRef: ref
752
+ }));
753
+ return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
763
754
  };
764
755
 
765
- const Translation = _ref => {
766
- let {
767
- ns,
768
- children,
769
- ...options
770
- } = _ref;
756
+ const Translation = ({
757
+ ns,
758
+ children,
759
+ ...options
760
+ }) => {
771
761
  const [t, i18n, ready] = useTranslation(ns, options);
772
762
  return children(t, {
773
763
  i18n,
@@ -775,12 +765,11 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
775
765
  }, ready);
776
766
  };
777
767
 
778
- function I18nextProvider(_ref) {
779
- let {
780
- i18n,
781
- defaultNS,
782
- children
783
- } = _ref;
768
+ function I18nextProvider({
769
+ i18n,
770
+ defaultNS,
771
+ children
772
+ }) {
784
773
  const value = react.useMemo(() => ({
785
774
  i18n,
786
775
  defaultNS
@@ -790,8 +779,7 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
790
779
  }, children);
791
780
  }
792
781
 
793
- const useSSR = function (initialI18nStore, initialLanguage) {
794
- let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
782
+ const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
795
783
  const {
796
784
  i18n: i18nFromProps
797
785
  } = props;
@@ -818,12 +806,11 @@ define(['exports', 'react'], (function (exports, react) { 'use strict';
818
806
  };
819
807
 
820
808
  const withSSR = () => function Extend(WrappedComponent) {
821
- function I18nextWithSSR(_ref) {
822
- let {
823
- initialI18nStore,
824
- initialLanguage,
825
- ...rest
826
- } = _ref;
809
+ function I18nextWithSSR({
810
+ initialI18nStore,
811
+ initialLanguage,
812
+ ...rest
813
+ }) {
827
814
  useSSR(initialI18nStore, initialLanguage);
828
815
  return react.createElement(WrappedComponent, {
829
816
  ...rest
@@ -1 +1 @@
1
- define(["exports","react"],(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=t({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),r=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function a(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var a=e.indexOf("--\x3e");return{type:"comment",comment:-1!==a?e.slice(4,a):""}}for(var i=new RegExp(r),o=null;null!==(o=i.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],i.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var i=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],r=[],c=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(i,(function(i,l){if(u){if(i!=="</"+t.name+">")return;u=!1}var p,d="/"!==i.charAt(1),f=i.startsWith("\x3c!--"),g=l+i.length,m=e.charAt(g);if(f){var h=a(i);return c<0?(s.push(h),s):((p=r[c]).children.push(h),s)}if(d&&(c++,"tag"===(t=a(i)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!m||"<"===m||t.children.push({type:"text",content:e.slice(g,e.indexOf("<",g))}),0===c&&s.push(t),(p=r[c-1])&&p.children.push(t),r[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===i.slice(2,-1))&&(c--,t=-1===c?s:r[c]),!u&&"<"!==m&&m)){p=-1===c?s:r[c].children;var y=e.indexOf("<",g),v=e.slice(g,-1===y?void 0:y);o.test(v)&&(v=" "),(y>-1&&c+p.length>=0||" "!==v)&&p.push({type:"text",content:v})}})),s};const u=(e,n,t,s)=>{const r=[t,{code:n,...s||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(r,"warn","react-i18next::",!0);y(r[0])&&(r[0]=`react-i18next:: ${r[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...r):console?.warn&&console.warn(...r)},p={},d=(e,n,t,s)=>{y(t)&&p[t]||(y(t)&&(p[t]=new Date),u(e,n,t,s))},f=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}},g=(e,n,t)=>{e.loadNamespaces(n,f(e,t))},m=(e,n,t,s)=>{if(y(t)&&(t=[t]),e.options.preload&&e.options.preload.indexOf(n)>-1)return g(e,t,s);t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,f(e,s))},h=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,v=e=>"object"==typeof e&&null!==e,N=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,x={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},E=e=>x[e];let b={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(N,E)};const O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b={...b,...e}},I=()=>b;let S;const w=e=>{S=e},$=()=>S,k=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},T=e=>{if(!e)return[];const n=e.props?.children??e.children;return e.props?.i18nIsDynamicList?A(n):n},A=e=>Array.isArray(e)?e:[e],R=(e,t,s,r)=>{if(!e)return"";let a="";const i=A(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return i.forEach(((e,i)=>{if(y(e))a+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:l}=e,c=Object.keys(n).length,u=o.indexOf(l)>-1,p=n.children;if(!p&&u&&!c)return void(a+=`<${l}/>`);if(!p&&(!u||c)||n.i18nIsDynamicList)return void(a+=`<${i}></${i}>`);if(u&&1===c&&y(p))return void(a+=`<${l}>${p}</${l}>`);const d=R(p,t,s,r);a+=`<${i}>${d}</${i}>`}else if(null!==e)if(v(e)){const{format:n,...t}=e,i=Object.keys(t);if(1===i.length){const e=n?`${i[0]}, ${n}`:i[0];return void(a+=`{{${e}}}`)}u(s,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:r,child:e})}else u(s,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:r,child:e});else u(s,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:r})})),a},j=(e,t,s,r,a,i)=>{if(""===t)return[];const o=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!i)return[t];const u={},p=e=>{A(e).forEach((e=>{y(e)||(k(e)?p(T(e)):v(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...a},g=(e,t,s)=>{const r=T(e),a=h(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===a.length||e.props?.i18nIsDynamicList?r:a},m=(e,t,s,r,a)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:r},a?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:r,ref:e.ref},a?null:t)})))},h=(t,a,c)=>{const u=A(t);return A(a).reduce(((t,a,p)=>{const d=a.children?.[0]?.content&&s.services.interpolator.interpolate(a.children[0].content,f,s.language);if("tag"===a.type){let i=u[parseInt(a.name,10)];1!==c.length||i||(i=c[0][a.name]),i||(i={});const N=0!==Object.keys(a.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:a.attrs},i):i,x=n.isValidElement(N),E=x&&k(a,!0)&&!a.voidElement,b=l&&v(N)&&N.dummy&&!x,O=v(e)&&Object.hasOwnProperty.call(e,a.name);if(y(N)){const e=s.services.interpolator.interpolate(N,f,s.language);t.push(e)}else if(k(N)||E){const e=g(N,a,c);m(N,e,t,p)}else if(b){const e=h(u,a.children,c);m(N,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=g(N,a,c);m(N,e,t,p,a.voidElement)}else if(r.transSupportBasicHtmlNodes&&o.indexOf(a.name)>-1)if(a.voidElement)t.push(n.createElement(a.name,{key:`${a.name}-${p}`}));else{const e=h(u,a.children,c);t.push(n.createElement(a.name,{key:`${a.name}-${p}`},e))}else if(a.voidElement)t.push(`<${a.name} />`);else{const e=h(u,a.children,c);t.push(`<${a.name}>${e}</${a.name}>`)}else if(v(N)&&!x){const e=a.children[0]?d:null;e&&t.push(e)}else m(N,d,t,p,1!==a.children.length||!d)}else if("text"===a.type){const e=r.transWrapTextNodes,o=i?r.unescape(s.services.interpolator.interpolate(a.content,f,s.language)):s.services.interpolator.interpolate(a.content,f,s.language);e?t.push(n.createElement(e,{key:`${a.name}-${p}`},o)):t.push(o)}return t}),[])},N=h([{dummy:!0,children:e||[]}],d,A(e||[]));return T(N[0])},C=(e,t,s)=>{const r=e.key||t,a=n.cloneElement(e,{key:r});if(!a.props||!a.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return a;return n.createElement((function(){return n.createElement(n.Fragment,null,a)}),{key:r})},L=(e,n,t,s)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>C(e,t,n))))(e,n):v(e)?((e,n)=>{const t={};return Object.keys(e).forEach((s=>{Object.assign(t,{[s]:C(e[s],s,n)})})),t})(e,n):(d(t,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:s}),null):null;function P(e){let{children:t,count:s,parent:r,i18nKey:a,context:i,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:f,t:g,shouldUnescape:m,...h}=e;const v=f||$();if(!v)return d(v,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:a}),t;const N=g||v.t.bind(v)||(e=>e),x={...I(),...v.options?.react};let E=p||N.ns||v.options?.defaultNS;E=y(E)?[E]:E||["translation"];const b=R(t,x,v,a),O=c||b||x.transEmptyNodeValue||a,{hashTransKey:S}=x,w=a||(S?S(b||O):b||O);v.options?.interpolation?.defaultVariables&&(l=l&&Object.keys(l).length>0?{...l,...v.options.interpolation.defaultVariables}:{...v.options.interpolation.defaultVariables});const k=l||void 0!==s&&!v.options?.interpolation?.alwaysFormat||!t?o.interpolation:{interpolation:{...o.interpolation,prefix:"#$?",suffix:"?$#"}},T={...o,context:i||o.context,count:s,...l,...k,defaultValue:O,ns:E},A=w?N(w,T):O,C=L(u,A,v,a),P=j(C||t,A,v,x,T,m),V=r??x.defaultTransParent;return V?n.createElement(V,h,P):P}const V={type:"3rdParty",init(e){O(e.options.react),w(e)}},_=n.createContext();class D{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const K=e=>async n=>({...await(e.getInitialProps?.(n))??{},...z()}),z=()=>{const e=$(),n=e.reportNamespaces?.getUsedNamespaces()??[],t={},s={};return e.languages.forEach((t=>{s[t]={},n.forEach((n=>{s[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=s,t.initialLanguage=e.language,t};const U=(e,n,t,s)=>e.getFixedT(n,t,s),F=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{i18n:s}=t,{i18n:r,defaultNS:a}=n.useContext(_)||{},i=s||r||$();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new D),!i){d(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:v(n)&&y(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}i.options.react?.wait&&d(i,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...I(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||a||i.options?.defaultNS;u=y(u)?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces?.(u);const p=(i.isInitialized||i.initializedStoreOnce)&&u.every((e=>function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return n.languages&&n.languages.length?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n?.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):(d(n,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:n.languages}),!0)}(e,i,o))),f=((e,t,s,r)=>n.useCallback(U(e,t,s,r),[e,t,s,r]))(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,N=()=>U(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[x,E]=n.useState(h);let b=u.join();t.lng&&(b=`${t.lng}${b}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(b),S=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;S.current=!0,p||l||(t.lng?m(i,t.lng,u,(()=>{S.current&&E(N)})):g(i,u,(()=>{S.current&&E(N)}))),p&&O&&O!==b&&S.current&&E(N);const s=()=>{S.current&&E(N)};return e&&i?.on(e,s),n&&i?.store.on(n,s),()=>{S.current=!1,i&&e?.split(" ").forEach((e=>i.off(e,s))),n&&i&&n.split(" ").forEach((e=>i.store.off(e,s)))}}),[i,b]),n.useEffect((()=>{S.current&&p&&E(h)}),[i,c,p]);const w=[x,i,p];if(w.t=x,w.i18n=i,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?m(i,t.lng,u,(()=>e())):g(i,u,(()=>e()))}))};const B=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{i18n:r}=s,{i18n:a}=n.useContext(_)||{},i=r||a||$();i.options?.isClone||(e&&!i.initializedStoreOnce&&(i.services.resourceStore.data=e,i.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),i.options.ns),i.initializedStoreOnce=!0,i.isInitialized=!0),t&&!i.initializedLanguageOnce&&(i.changeLanguage(t),i.initializedLanguageOnce=!0))};e.I18nContext=_,e.I18nextProvider=function(e){let{i18n:t,defaultNS:s,children:r}=e;const a=n.useMemo((()=>({i18n:t,defaultNS:s})),[t,s]);return n.createElement(_.Provider,{value:a},r)},e.Trans=function(e){let{children:t,count:s,parent:r,i18nKey:a,context:i,tOptions:o={},values:l,defaults:c,components:u,ns:p,i18n:d,t:f,shouldUnescape:g,...m}=e;const{i18n:h,defaultNS:y}=n.useContext(_)||{},v=d||h||$(),N=f||v?.t.bind(v);return P({children:t,count:s,parent:r,i18nKey:a,context:i,tOptions:o,values:l,defaults:c,components:u,ns:p||N?.ns||y||v?.options?.defaultNS,i18n:v,t:f,shouldUnescape:g,...m})},e.TransWithoutContext=P,e.Translation=e=>{let{ns:n,children:t,...s}=e;const[r,a,i]=F(n,s);return t(r,{i18n:a,lng:a.language},i)},e.composeInitialProps=K,e.date=()=>"",e.getDefaults=I,e.getI18n=$,e.getInitialProps=z,e.initReactI18next=V,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=B,e.useTranslation=F,e.withSSR=()=>function(e){function t(t){let{initialI18nStore:s,initialLanguage:r,...a}=t;return B(s,r),n.createElement(e,{...a})}return t.getInitialProps=K(e),t.displayName=`withI18nextSSR(${h(e)})`,t.WrappedComponent=e,t},e.withTranslation=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){function r(r){let{forwardedRef:a,...i}=r;const[o,l,c]=F(e,{...i,keyPrefix:t.keyPrefix}),u={...i,t:o,i18n:l,tReady:c};return t.withRef&&a?u.ref=a:!t.withRef&&a&&(u.forwardedRef=a),n.createElement(s,u)}r.displayName=`withI18nextTranslation(${h(s)})`,r.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(r,Object.assign({},e,{forwardedRef:t})))):r}}}));
1
+ define(["exports","react"],(function(e,n){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=t({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}),r=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function a(e){var n={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},t=e.match(/<\/?([^\s]+?)[/\s>]/);if(t&&(n.name=t[1],(s[t[1]]||"/"===e.charAt(e.length-2))&&(n.voidElement=!0),n.name.startsWith("!--"))){var a=e.indexOf("--\x3e");return{type:"comment",comment:-1!==a?e.slice(4,a):""}}for(var i=new RegExp(r),o=null;null!==(o=i.exec(e));)if(o[0].trim())if(o[1]){var l=o[1].trim(),c=[l,""];l.indexOf("=")>-1&&(c=l.split("=")),n.attrs[c[0]]=c[1],i.lastIndex--}else o[2]&&(n.attrs[o[2]]=o[3].trim().substring(1,o[3].length-1));return n}var i=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,o=/^\s*$/,l=Object.create(null);var c=function(e,n){n||(n={}),n.components||(n.components=l);var t,s=[],r=[],c=-1,u=!1;if(0!==e.indexOf("<")){var p=e.indexOf("<");s.push({type:"text",content:-1===p?e:e.substring(0,p)})}return e.replace(i,(function(i,l){if(u){if(i!=="</"+t.name+">")return;u=!1}var p,d="/"!==i.charAt(1),f=i.startsWith("\x3c!--"),m=l+i.length,g=e.charAt(m);if(f){var h=a(i);return c<0?(s.push(h),s):((p=r[c]).children.push(h),s)}if(d&&(c++,"tag"===(t=a(i)).type&&n.components[t.name]&&(t.type="component",u=!0),t.voidElement||u||!g||"<"===g||t.children.push({type:"text",content:e.slice(m,e.indexOf("<",m))}),0===c&&s.push(t),(p=r[c-1])&&p.children.push(t),r[c]=t),(!d||t.voidElement)&&(c>-1&&(t.voidElement||t.name===i.slice(2,-1))&&(c--,t=-1===c?s:r[c]),!u&&"<"!==g&&g)){p=-1===c?s:r[c].children;var y=e.indexOf("<",m),N=e.slice(m,-1===y?void 0:y);o.test(N)&&(N=" "),(y>-1&&c+p.length>=0||" "!==N)&&p.push({type:"text",content:N})}})),s};const u=(e,n,t,s)=>{const r=[t,{code:n,...s||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(r,"warn","react-i18next::",!0);y(r[0])&&(r[0]=`react-i18next:: ${r[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...r):console?.warn&&console.warn(...r)},p={},d=(e,n,t,s)=>{y(t)&&p[t]||(y(t)&&(p[t]=new Date),u(e,n,t,s))},f=(e,n)=>()=>{if(e.isInitialized)n();else{const t=()=>{setTimeout((()=>{e.off("initialized",t)}),0),n()};e.on("initialized",t)}},m=(e,n,t)=>{e.loadNamespaces(n,f(e,t))},g=(e,n,t,s)=>{if(y(t)&&(t=[t]),e.options.preload&&e.options.preload.indexOf(n)>-1)return m(e,t,s);t.forEach((n=>{e.options.ns.indexOf(n)<0&&e.options.ns.push(n)})),e.loadLanguages(n,f(e,s))},h=e=>e.displayName||e.name||(y(e)&&e.length>0?e:"Unknown"),y=e=>"string"==typeof e,N=e=>"object"==typeof e&&null!==e,x=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,v={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},E=e=>v[e];let b={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(x,E)};const O=(e={})=>{b={...b,...e}},I=()=>b;let S;const w=e=>{S=e},$=()=>S,k=(e,n)=>{if(!e)return!1;const t=e.props?.children??e.children;return n?t.length>0:!!t},T=e=>{if(!e)return[];const n=e.props?.children??e.children;return e.props?.i18nIsDynamicList?A(n):n},A=e=>Array.isArray(e)?e:[e],R=(e,t,s,r)=>{if(!e)return"";let a="";const i=A(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return i.forEach(((e,i)=>{if(y(e))a+=`${e}`;else if(n.isValidElement(e)){const{props:n,type:l}=e,c=Object.keys(n).length,u=o.indexOf(l)>-1,p=n.children;if(!p&&u&&!c)return void(a+=`<${l}/>`);if(!p&&(!u||c)||n.i18nIsDynamicList)return void(a+=`<${i}></${i}>`);if(u&&1===c&&y(p))return void(a+=`<${l}>${p}</${l}>`);const d=R(p,t,s,r);a+=`<${i}>${d}</${i}>`}else if(null!==e)if(N(e)){const{format:n,...t}=e,i=Object.keys(t);if(1===i.length){const e=n?`${i[0]}, ${n}`:i[0];return void(a+=`{{${e}}}`)}u(s,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:r,child:e})}else u(s,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:r,child:e});else u(s,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:r})})),a},j=(e,t,s,r,a,i)=>{if(""===t)return[];const o=r.transKeepBasicHtmlNodesFor||[],l=t&&new RegExp(o.map((e=>`<${e}`)).join("|")).test(t);if(!e&&!l&&!i)return[t];const u={},p=e=>{A(e).forEach((e=>{y(e)||(k(e)?p(T(e)):N(e)&&!n.isValidElement(e)&&Object.assign(u,e))}))};p(e);const d=c(`<0>${t}</0>`),f={...u,...a},m=(e,t,s)=>{const r=T(e),a=h(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===a.length||e.props?.i18nIsDynamicList?r:a},g=(e,t,s,r,a)=>{e.dummy?(e.children=t,s.push(n.cloneElement(e,{key:r},a?void 0:t))):s.push(...n.Children.map([e],(e=>{const s={...e.props};return delete s.i18nIsDynamicList,n.createElement(e.type,{...s,key:r,ref:e.props.ref??e.ref},a?null:t)})))},h=(t,a,c)=>{const u=A(t);return A(a).reduce(((t,a,p)=>{const d=a.children?.[0]?.content&&s.services.interpolator.interpolate(a.children[0].content,f,s.language);if("tag"===a.type){let i=u[parseInt(a.name,10)];1!==c.length||i||(i=c[0][a.name]),i||(i={});const x=0!==Object.keys(a.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:a.attrs},i):i,v=n.isValidElement(x),E=v&&k(a,!0)&&!a.voidElement,b=l&&N(x)&&x.dummy&&!v,O=N(e)&&Object.hasOwnProperty.call(e,a.name);if(y(x)){const e=s.services.interpolator.interpolate(x,f,s.language);t.push(e)}else if(k(x)||E){const e=m(x,a,c);g(x,e,t,p)}else if(b){const e=h(u,a.children,c);g(x,e,t,p)}else if(Number.isNaN(parseFloat(a.name)))if(O){const e=m(x,a,c);g(x,e,t,p,a.voidElement)}else if(r.transSupportBasicHtmlNodes&&o.indexOf(a.name)>-1)if(a.voidElement)t.push(n.createElement(a.name,{key:`${a.name}-${p}`}));else{const e=h(u,a.children,c);t.push(n.createElement(a.name,{key:`${a.name}-${p}`},e))}else if(a.voidElement)t.push(`<${a.name} />`);else{const e=h(u,a.children,c);t.push(`<${a.name}>${e}</${a.name}>`)}else if(N(x)&&!v){const e=a.children[0]?d:null;e&&t.push(e)}else g(x,d,t,p,1!==a.children.length||!d)}else if("text"===a.type){const e=r.transWrapTextNodes,o=i?r.unescape(s.services.interpolator.interpolate(a.content,f,s.language)):s.services.interpolator.interpolate(a.content,f,s.language);e?t.push(n.createElement(e,{key:`${a.name}-${p}`},o)):t.push(o)}return t}),[])},x=h([{dummy:!0,children:e||[]}],d,A(e||[]));return T(x[0])},C=(e,t,s)=>{const r=e.key||t,a=n.cloneElement(e,{key:r});if(!a.props||!a.props.children||s.indexOf(`${t}/>`)<0&&s.indexOf(`${t} />`)<0)return a;return n.createElement((function(){return n.createElement(n.Fragment,null,a)}),{key:r})},L=(e,n,t,s)=>e?Array.isArray(e)?((e,n)=>e.map(((e,t)=>C(e,t,n))))(e,n):N(e)?((e,n)=>{const t={};return Object.keys(e).forEach((s=>{Object.assign(t,{[s]:C(e[s],s,n)})})),t})(e,n):(d(t,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:s}),null):null;function P({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:f,shouldUnescape:m,...g}){const h=p||$();if(!h)return d(h,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:r}),e;const N=f||h.t.bind(h)||(e=>e),x={...I(),...h.options?.react};let v=u||N.ns||h.options?.defaultNS;v=y(v)?[v]:v||["translation"];const E=R(e,x,h,r),b=l||E||x.transEmptyNodeValue||r,{hashTransKey:O}=x,S=r||(O?O(E||b):E||b);h.options?.interpolation?.defaultVariables&&(o=o&&Object.keys(o).length>0?{...o,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables});const w=o||void 0!==t&&!h.options?.interpolation?.alwaysFormat||!e?i.interpolation:{interpolation:{...i.interpolation,prefix:"#$?",suffix:"?$#"}},k={...i,context:a||i.context,count:t,...o,...w,defaultValue:b,ns:v},T=S?N(S,k):b,A=L(c,T,h,r),C=j(A||e,T,h,x,k,m),P=s??x.defaultTransParent;return P?n.createElement(P,g,C):C}const V={type:"3rdParty",init(e){O(e.options.react),w(e)}},_=n.createContext();class D{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const K=e=>async n=>({...await(e.getInitialProps?.(n))??{},...z()}),z=()=>{const e=$(),n=e.reportNamespaces?.getUsedNamespaces()??[],t={},s={};return e.languages.forEach((t=>{s[t]={},n.forEach((n=>{s[t][n]=e.getResourceBundle(t,n)||{}}))})),t.initialI18nStore=s,t.initialLanguage=e.language,t};const U=(e,n,t,s)=>e.getFixedT(n,t,s),F=(e,t={})=>{const{i18n:s}=t,{i18n:r,defaultNS:a}=n.useContext(_)||{},i=s||r||$();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new D),!i){d(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const e=(e,n)=>y(n)?n:N(n)&&y(n.defaultValue)?n.defaultValue:Array.isArray(e)?e[e.length-1]:e,n=[e,{},!1];return n.t=e,n.i18n={},n.ready=!1,n}i.options.react?.wait&&d(i,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...I(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=o;let u=e||a||i.options?.defaultNS;u=y(u)?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces?.(u);const p=(i.isInitialized||i.initializedStoreOnce)&&u.every((e=>((e,n,t={})=>n.languages&&n.languages.length?n.hasLoadedNamespace(e,{lng:t.lng,precheck:(n,s)=>{if(t.bindI18n?.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!s(n.isLanguageChangingTo,e))return!1}}):(d(n,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:n.languages}),!0))(e,i,o))),f=((e,t,s,r)=>n.useCallback(U(e,t,s,r),[e,t,s,r]))(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,x=()=>U(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[v,E]=n.useState(h);let b=u.join();t.lng&&(b=`${t.lng}${b}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(b),S=n.useRef(!0);n.useEffect((()=>{const{bindI18n:e,bindI18nStore:n}=o;S.current=!0,p||l||(t.lng?g(i,t.lng,u,(()=>{S.current&&E(x)})):m(i,u,(()=>{S.current&&E(x)}))),p&&O&&O!==b&&S.current&&E(x);const s=()=>{S.current&&E(x)};return e&&i?.on(e,s),n&&i?.store.on(n,s),()=>{S.current=!1,i&&e?.split(" ").forEach((e=>i.off(e,s))),n&&i&&n.split(" ").forEach((e=>i.store.off(e,s)))}}),[i,b]),n.useEffect((()=>{S.current&&p&&E(h)}),[i,c,p]);const w=[v,i,p];if(w.t=v,w.i18n=i,w.ready=p,p)return w;if(!p&&!l)return w;throw new Promise((e=>{t.lng?g(i,t.lng,u,(()=>e())):m(i,u,(()=>e()))}))};const B=(e,t,s={})=>{const{i18n:r}=s,{i18n:a}=n.useContext(_)||{},i=r||a||$();i.options?.isClone||(e&&!i.initializedStoreOnce&&(i.services.resourceStore.data=e,i.options.ns=Object.values(e).reduce(((e,n)=>(Object.keys(n).forEach((n=>{e.indexOf(n)<0&&e.push(n)})),e)),i.options.ns),i.initializedStoreOnce=!0,i.isInitialized=!0),t&&!i.initializedLanguageOnce&&(i.changeLanguage(t),i.initializedLanguageOnce=!0))};e.I18nContext=_,e.I18nextProvider=function({i18n:e,defaultNS:t,children:s}){const r=n.useMemo((()=>({i18n:e,defaultNS:t})),[e,t]);return n.createElement(_.Provider,{value:r},s)},e.Trans=function({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i={},values:o,defaults:l,components:c,ns:u,i18n:p,t:d,shouldUnescape:f,...m}){const{i18n:g,defaultNS:h}=n.useContext(_)||{},y=p||g||$(),N=d||y?.t.bind(y);return P({children:e,count:t,parent:s,i18nKey:r,context:a,tOptions:i,values:o,defaults:l,components:c,ns:u||N?.ns||h||y?.options?.defaultNS,i18n:y,t:d,shouldUnescape:f,...m})},e.TransWithoutContext=P,e.Translation=({ns:e,children:n,...t})=>{const[s,r,a]=F(e,t);return n(s,{i18n:r,lng:r.language},a)},e.composeInitialProps=K,e.date=()=>"",e.getDefaults=I,e.getI18n=$,e.getInitialProps=z,e.initReactI18next=V,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=B,e.useTranslation=F,e.withSSR=()=>function(e){function t({initialI18nStore:t,initialLanguage:s,...r}){return B(t,s),n.createElement(e,{...r})}return t.getInitialProps=K(e),t.displayName=`withI18nextSSR(${h(e)})`,t.WrappedComponent=e,t},e.withTranslation=(e,t={})=>function(s){function r({forwardedRef:r,...a}){const[i,o,l]=F(e,{...a,keyPrefix:t.keyPrefix}),c={...a,t:i,i18n:o,tReady:l};return t.withRef&&r?c.ref=r:!t.withRef&&r&&(c.forwardedRef=r),n.createElement(s,c)}r.displayName=`withI18nextTranslation(${h(s)})`,r.WrappedComponent=s;return t.withRef?n.forwardRef(((e,t)=>n.createElement(r,Object.assign({},e,{forwardedRef:t})))):r}}));
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.I18nextProvider = I18nextProvider;
7
7
  var _react = require("react");
8
8
  var _context = require("./context.js");
9
- function I18nextProvider(_ref) {
10
- let {
11
- i18n,
12
- defaultNS,
13
- children
14
- } = _ref;
9
+ function I18nextProvider({
10
+ i18n,
11
+ defaultNS,
12
+ children
13
+ }) {
15
14
  const value = (0, _react.useMemo)(() => ({
16
15
  i18n,
17
16
  defaultNS
@@ -13,23 +13,22 @@ Object.defineProperty(exports, "nodesToString", {
13
13
  var _react = require("react");
14
14
  var _TransWithoutContext = require("./TransWithoutContext.js");
15
15
  var _context = require("./context.js");
16
- function Trans(_ref) {
17
- let {
18
- children,
19
- count,
20
- parent,
21
- i18nKey,
22
- context,
23
- tOptions = {},
24
- values,
25
- defaults,
26
- components,
27
- ns,
28
- i18n: i18nFromProps,
29
- t: tFromProps,
30
- shouldUnescape,
31
- ...additionalProps
32
- } = _ref;
16
+ function Trans({
17
+ children,
18
+ count,
19
+ parent,
20
+ i18nKey,
21
+ context,
22
+ tOptions = {},
23
+ values,
24
+ defaults,
25
+ components,
26
+ ns,
27
+ i18n: i18nFromProps,
28
+ t: tFromProps,
29
+ shouldUnescape,
30
+ ...additionalProps
31
+ }) {
33
32
  const {
34
33
  i18n: i18nFromContext,
35
34
  defaultNS: defaultNSFromContext
@@ -135,7 +135,7 @@ const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, s
135
135
  return (0, _react.createElement)(c.type, {
136
136
  ...props,
137
137
  key: i,
138
- ref: c.ref
138
+ ref: c.props.ref ?? c.ref
139
139
  }, isVoid ? null : inner);
140
140
  }));
141
141
  }
@@ -250,23 +250,22 @@ const generateComponents = (components, translation, i18n, i18nKey) => {
250
250
  });
251
251
  return null;
252
252
  };
253
- function Trans(_ref) {
254
- let {
255
- children,
256
- count,
257
- parent,
258
- i18nKey,
259
- context,
260
- tOptions = {},
261
- values,
262
- defaults,
263
- components,
264
- ns,
265
- i18n: i18nFromProps,
266
- t: tFromProps,
267
- shouldUnescape,
268
- ...additionalProps
269
- } = _ref;
253
+ function Trans({
254
+ children,
255
+ count,
256
+ parent,
257
+ i18nKey,
258
+ context,
259
+ tOptions = {},
260
+ values,
261
+ defaults,
262
+ components,
263
+ ns,
264
+ i18n: i18nFromProps,
265
+ t: tFromProps,
266
+ shouldUnescape,
267
+ ...additionalProps
268
+ }) {
270
269
  const i18n = i18nFromProps || (0, _i18nInstance.getI18n)();
271
270
  if (!i18n) {
272
271
  (0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Translation = void 0;
7
7
  var _useTranslation = require("./useTranslation.js");
8
- const Translation = _ref => {
9
- let {
10
- ns,
11
- children,
12
- ...options
13
- } = _ref;
8
+ const Translation = ({
9
+ ns,
10
+ children,
11
+ ...options
12
+ }) => {
14
13
  const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, options);
15
14
  return children(t, {
16
15
  i18n,
@@ -15,8 +15,7 @@ let defaultOptions = {
15
15
  useSuspense: true,
16
16
  unescape: _unescape.unescape
17
17
  };
18
- const setDefaults = function () {
19
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
+ const setDefaults = (options = {}) => {
20
19
  defaultOptions = {
21
20
  ...defaultOptions,
22
21
  ...options
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useSSR = void 0;
7
7
  var _react = require("react");
8
8
  var _context = require("./context.js");
9
- const useSSR = function (initialI18nStore, initialLanguage) {
10
- let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
9
+ const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
11
10
  const {
12
11
  i18n: i18nFromProps
13
12
  } = props;
@@ -16,8 +16,7 @@ const usePrevious = (value, ignore) => {
16
16
  };
17
17
  const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
18
18
  const useMemoizedT = (i18n, language, namespace, keyPrefix) => (0, _react.useCallback)(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
19
- const useTranslation = function (ns) {
20
- let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ const useTranslation = (ns, props = {}) => {
21
20
  const {
22
21
  i18n: i18nFromProps
23
22
  } = props;
@@ -53,8 +53,7 @@ const loadLanguages = (i18n, lng, ns, cb) => {
53
53
  i18n.loadLanguages(lng, loadedClb(i18n, cb));
54
54
  };
55
55
  exports.loadLanguages = loadLanguages;
56
- const hasLoadedNamespace = function (ns, i18n) {
57
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
56
+ const hasLoadedNamespace = (ns, i18n, options = {}) => {
58
57
  if (!i18n.languages || !i18n.languages.length) {
59
58
  warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
60
59
  languages: i18n.languages
@@ -9,12 +9,11 @@ var _useSSR = require("./useSSR.js");
9
9
  var _context = require("./context.js");
10
10
  var _utils = require("./utils.js");
11
11
  const withSSR = () => function Extend(WrappedComponent) {
12
- function I18nextWithSSR(_ref) {
13
- let {
14
- initialI18nStore,
15
- initialLanguage,
16
- ...rest
17
- } = _ref;
12
+ function I18nextWithSSR({
13
+ initialI18nStore,
14
+ initialLanguage,
15
+ ...rest
16
+ }) {
18
17
  (0, _useSSR.useSSR)(initialI18nStore, initialLanguage);
19
18
  return (0, _react.createElement)(WrappedComponent, {
20
19
  ...rest
@@ -7,37 +7,33 @@ exports.withTranslation = void 0;
7
7
  var _react = require("react");
8
8
  var _useTranslation = require("./useTranslation.js");
9
9
  var _utils = require("./utils.js");
10
- const withTranslation = function (ns) {
11
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12
- return function Extend(WrappedComponent) {
13
- function I18nextWithTranslation(_ref) {
14
- let {
15
- forwardedRef,
16
- ...rest
17
- } = _ref;
18
- const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, {
19
- ...rest,
20
- keyPrefix: options.keyPrefix
21
- });
22
- const passDownProps = {
23
- ...rest,
24
- t,
25
- i18n,
26
- tReady: ready
27
- };
28
- if (options.withRef && forwardedRef) {
29
- passDownProps.ref = forwardedRef;
30
- } else if (!options.withRef && forwardedRef) {
31
- passDownProps.forwardedRef = forwardedRef;
32
- }
33
- return (0, _react.createElement)(WrappedComponent, passDownProps);
10
+ const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
11
+ function I18nextWithTranslation({
12
+ forwardedRef,
13
+ ...rest
14
+ }) {
15
+ const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, {
16
+ ...rest,
17
+ keyPrefix: options.keyPrefix
18
+ });
19
+ const passDownProps = {
20
+ ...rest,
21
+ t,
22
+ i18n,
23
+ tReady: ready
24
+ };
25
+ if (options.withRef && forwardedRef) {
26
+ passDownProps.ref = forwardedRef;
27
+ } else if (!options.withRef && forwardedRef) {
28
+ passDownProps.forwardedRef = forwardedRef;
34
29
  }
35
- I18nextWithTranslation.displayName = `withI18nextTranslation(${(0, _utils.getDisplayName)(WrappedComponent)})`;
36
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
37
- const forwardRef = (props, ref) => (0, _react.createElement)(I18nextWithTranslation, Object.assign({}, props, {
38
- forwardedRef: ref
39
- }));
40
- return options.withRef ? (0, _react.forwardRef)(forwardRef) : I18nextWithTranslation;
41
- };
30
+ return (0, _react.createElement)(WrappedComponent, passDownProps);
31
+ }
32
+ I18nextWithTranslation.displayName = `withI18nextTranslation(${(0, _utils.getDisplayName)(WrappedComponent)})`;
33
+ I18nextWithTranslation.WrappedComponent = WrappedComponent;
34
+ const forwardRef = (props, ref) => (0, _react.createElement)(I18nextWithTranslation, Object.assign({}, props, {
35
+ forwardedRef: ref
36
+ }));
37
+ return options.withRef ? (0, _react.forwardRef)(forwardRef) : I18nextWithTranslation;
42
38
  };
43
39
  exports.withTranslation = withTranslation;
@@ -126,7 +126,7 @@ const renderNodes = (children, targetString, i18n, i18nOptions, combinedTOpts, s
126
126
  return createElement(c.type, {
127
127
  ...props,
128
128
  key: i,
129
- ref: c.ref
129
+ ref: c.props.ref ?? c.ref
130
130
  }, isVoid ? null : inner);
131
131
  }));
132
132
  }
@@ -1 +1 @@
1
- {"type":"module","version":"15.5.1"}
1
+ {"type":"module","version":"15.5.3"}