@team-monolith/cds 1.129.2-alpha.2 → 1.130.0-alpha
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/emotion.d.ts +185 -0
- package/dist/index.d.ts +8 -1
- package/dist/patterns/LexicalEditor/LexicalCustomConfigContext.d.ts +1 -0
- package/dist/patterns/LexicalEditor/LexicalCustomConfigContext.js +2 -1
- package/dist/patterns/LexicalEditor/LexicalEditor.d.ts +4 -0
- package/dist/patterns/LexicalEditor/LexicalEditor.js +9 -7
- package/dist/patterns/LexicalEditor/Plugins.d.ts +1 -0
- package/dist/patterns/LexicalEditor/Plugins.js +65 -61
- package/dist/patterns/LexicalEditor/components/FileSelectInput.js +24 -23
- package/dist/patterns/LexicalEditor/components/UploadFileDialog/UploadFileDialog.js +2 -1
- package/dist/patterns/LexicalEditor/nodes/FileNode/CompactFileView.d.ts +7 -0
- package/dist/patterns/LexicalEditor/nodes/FileNode/CompactFileView.js +53 -0
- package/dist/patterns/LexicalEditor/nodes/FileNode/FileComponent.d.ts +0 -27
- package/dist/patterns/LexicalEditor/nodes/FileNode/FileComponent.js +44 -115
- package/dist/patterns/LexicalEditor/nodes/FileNode/FileDownloadButton.js +1 -1
- package/dist/patterns/LexicalEditor/nodes/FileNode/fileStyles.d.ts +27 -0
- package/dist/patterns/LexicalEditor/nodes/FileNode/fileStyles.js +85 -0
- package/dist/patterns/LexicalEditor/nodes/ImageNode/CompactImageView.d.ts +6 -0
- package/dist/patterns/LexicalEditor/nodes/ImageNode/CompactImageView.js +91 -0
- package/dist/patterns/LexicalEditor/nodes/ImageNode/ImageComponent.js +108 -102
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.js +7 -7
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +4 -4
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/InputComponent.js +4 -4
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectComponent.js +4 -4
- package/dist/patterns/LexicalEditor/plugins/CompactToolbarPlugin/CompactToolbarPlugin.d.ts +1 -0
- package/dist/patterns/LexicalEditor/plugins/CompactToolbarPlugin/CompactToolbarPlugin.js +106 -0
- package/dist/patterns/LexicalEditor/plugins/CompactToolbarPlugin/compactAttachmentNodes.d.ts +8 -0
- package/dist/patterns/LexicalEditor/plugins/CompactToolbarPlugin/compactAttachmentNodes.js +6 -0
- package/dist/patterns/LexicalEditor/plugins/CompactToolbarPlugin/index.d.ts +1 -0
- package/dist/patterns/LexicalEditor/plugins/DragDropPastePlugin/index.js +15 -14
- package/dist/patterns/LexicalEditor/uploadConstants.d.ts +6 -0
- package/dist/patterns/LexicalEditor/uploadConstants.js +4 -0
- package/package.json +3 -7
- package/@types/emotion.d.ts +0 -197
- package/node_modules/react-i18next/.eslintrc.json +0 -74
- package/node_modules/react-i18next/.husky/pre-commit +0 -1
- package/node_modules/react-i18next/.prettierignore +0 -4
- package/node_modules/react-i18next/CHANGELOG.md +0 -1433
- package/node_modules/react-i18next/LICENSE +0 -22
- package/node_modules/react-i18next/README.md +0 -181
- package/node_modules/react-i18next/TransWithoutContext.d.mts +0 -1
- package/node_modules/react-i18next/TransWithoutContext.d.ts +0 -129
- package/node_modules/react-i18next/dist/amd/react-i18next.js +0 -867
- package/node_modules/react-i18next/dist/amd/react-i18next.min.js +0 -1
- package/node_modules/react-i18next/dist/commonjs/I18nextProvider.js +0 -21
- package/node_modules/react-i18next/dist/commonjs/Trans.js +0 -54
- package/node_modules/react-i18next/dist/commonjs/TransWithoutContext.js +0 -330
- package/node_modules/react-i18next/dist/commonjs/Translation.js +0 -19
- package/node_modules/react-i18next/dist/commonjs/context.js +0 -81
- package/node_modules/react-i18next/dist/commonjs/defaults.js +0 -26
- package/node_modules/react-i18next/dist/commonjs/i18nInstance.js +0 -13
- package/node_modules/react-i18next/dist/commonjs/index.js +0 -128
- package/node_modules/react-i18next/dist/commonjs/initReactI18next.js +0 -15
- package/node_modules/react-i18next/dist/commonjs/unescape.js +0 -32
- package/node_modules/react-i18next/dist/commonjs/useSSR.js +0 -34
- package/node_modules/react-i18next/dist/commonjs/useTranslation.js +0 -114
- package/node_modules/react-i18next/dist/commonjs/utils.js +0 -76
- package/node_modules/react-i18next/dist/commonjs/withSSR.js +0 -27
- package/node_modules/react-i18next/dist/commonjs/withTranslation.js +0 -39
- package/node_modules/react-i18next/dist/es/I18nextProvider.js +0 -15
- package/node_modules/react-i18next/dist/es/Trans.js +0 -43
- package/node_modules/react-i18next/dist/es/TransWithoutContext.js +0 -321
- package/node_modules/react-i18next/dist/es/Translation.js +0 -12
- package/node_modules/react-i18next/dist/es/context.js +0 -42
- package/node_modules/react-i18next/dist/es/defaults.js +0 -18
- package/node_modules/react-i18next/dist/es/i18nInstance.js +0 -5
- package/node_modules/react-i18next/dist/es/index.js +0 -18
- package/node_modules/react-i18next/dist/es/initReactI18next.js +0 -9
- package/node_modules/react-i18next/dist/es/package.json +0 -1
- package/node_modules/react-i18next/dist/es/unescape.js +0 -25
- package/node_modules/react-i18next/dist/es/useSSR.js +0 -27
- package/node_modules/react-i18next/dist/es/useTranslation.js +0 -107
- package/node_modules/react-i18next/dist/es/utils.js +0 -62
- package/node_modules/react-i18next/dist/es/withSSR.js +0 -20
- package/node_modules/react-i18next/dist/es/withTranslation.js +0 -32
- package/node_modules/react-i18next/dist/umd/react-i18next.js +0 -871
- package/node_modules/react-i18next/dist/umd/react-i18next.min.js +0 -1
- package/node_modules/react-i18next/helpers.d.ts +0 -3
- package/node_modules/react-i18next/icu.macro.d.mts +0 -1
- package/node_modules/react-i18next/icu.macro.d.ts +0 -103
- package/node_modules/react-i18next/icu.macro.js +0 -729
- package/node_modules/react-i18next/index.d.mts +0 -1
- package/node_modules/react-i18next/index.d.ts +0 -209
- package/node_modules/react-i18next/initReactI18next.d.mts +0 -1
- package/node_modules/react-i18next/initReactI18next.d.ts +0 -3
- package/node_modules/react-i18next/lint-staged.config.mjs +0 -4
- package/node_modules/react-i18next/package.json +0 -167
- package/node_modules/react-i18next/react-i18next.js +0 -871
- package/node_modules/react-i18next/react-i18next.min.js +0 -1
- package/node_modules/react-i18next/src/I18nextProvider.js +0 -7
- package/node_modules/react-i18next/src/Trans.js +0 -45
- package/node_modules/react-i18next/src/TransWithoutContext.js +0 -479
- package/node_modules/react-i18next/src/Translation.js +0 -14
- package/node_modules/react-i18next/src/context.js +0 -54
- package/node_modules/react-i18next/src/defaults.js +0 -20
- package/node_modules/react-i18next/src/i18nInstance.js +0 -7
- package/node_modules/react-i18next/src/index.js +0 -22
- package/node_modules/react-i18next/src/initReactI18next.js +0 -11
- package/node_modules/react-i18next/src/unescape.js +0 -31
- package/node_modules/react-i18next/src/useSSR.js +0 -33
- package/node_modules/react-i18next/src/useTranslation.js +0 -171
- package/node_modules/react-i18next/src/utils.js +0 -93
- package/node_modules/react-i18next/src/withSSR.js +0 -21
- package/node_modules/react-i18next/src/withTranslation.js +0 -35
- package/node_modules/react-i18next/vitest.workspace.typescript.mts +0 -52
|
@@ -1 +0,0 @@
|
|
|
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,b={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},v=e=>b[e];let E={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(x,v)};const O=(e={})=>{E={...E,...e}},I=()=>E;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,o)=>{if(""===s)return[];const l=a.transKeepBasicHtmlNodesFor||[],u=s&&new RegExp(l.map((e=>`<${e}`)).join("|")).test(s);if(!(e||t||u||o))return[s];const p=t??{},d=e=>{A(e).forEach((e=>{y(e)||(k(e)?d(T(e)):N(e)&&!n.isValidElement(e)&&Object.assign(p,e))}))};d(e);const f=c(`<0>${s}</0>`),m={...p,...i},g=(e,t,s)=>{const r=T(e),a=x(r,t.children,s);return(e=>Array.isArray(e)&&e.every(n.isValidElement))(r)&&0===a.length||e.props?.i18nIsDynamicList?r:a},h=(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)})))},x=(e,s,i)=>{const c=A(e);return A(s).reduce(((e,s,p)=>{const d=s.children?.[0]?.content&&r.services.interpolator.interpolate(s.children[0].content,m,r.language);if("tag"===s.type){let o=c[parseInt(s.name,10)];!o&&t&&(o=t[s.name]),1!==i.length||o||(o=i[0][s.name]),o||(o={});const f=0!==Object.keys(s.attrs).length?((e,n)=>{const t={...n};return t.props=Object.assign(e.props,n.props),t})({props:s.attrs},o):o,b=n.isValidElement(f),v=b&&k(s,!0)&&!s.voidElement,E=u&&N(f)&&f.dummy&&!b,O=N(t)&&Object.hasOwnProperty.call(t,s.name);if(y(f)){const n=r.services.interpolator.interpolate(f,m,r.language);e.push(n)}else if(k(f)||v){const n=g(f,s,i);h(f,n,e,p)}else if(E){const n=x(c,s.children,i);h(f,n,e,p)}else if(Number.isNaN(parseFloat(s.name)))if(O){const n=g(f,s,i);h(f,n,e,p,s.voidElement)}else if(a.transSupportBasicHtmlNodes&&l.indexOf(s.name)>-1)if(s.voidElement)e.push(n.createElement(s.name,{key:`${s.name}-${p}`}));else{const t=x(c,s.children,i);e.push(n.createElement(s.name,{key:`${s.name}-${p}`},t))}else if(s.voidElement)e.push(`<${s.name} />`);else{const n=x(c,s.children,i);e.push(`<${s.name}>${n}</${s.name}>`)}else if(N(f)&&!b){const n=s.children[0]?d:null;n&&e.push(n)}else h(f,d,e,p,1!==s.children.length||!d)}else if("text"===s.type){const t=a.transWrapTextNodes,i=o?a.unescape(r.services.interpolator.interpolate(s.content,m,r.language)):r.services.interpolator.interpolate(s.content,m,r.language);t?e.push(n.createElement(t,{key:`${s.name}-${p}`},i)):e.push(i)}return e}),[])},b=x([{dummy:!0,children:e||[]}],f,A(e||[]));return T(b[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,P=e=>!!N(e)&&(!Array.isArray(e)&&Object.keys(e).reduce(((e,n)=>e&&Number.isNaN(Number.parseFloat(n))),!0));function V({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 b=u||N.ns||h.options?.defaultNS;b=y(b)?[b]:b||["translation"];const v=R(e,x,h,r),E=l||v||x.transEmptyNodeValue||r,{hashTransKey:O}=x,S=r||(O?O(v||E):v||E);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:E,ns:b},T=S?N(S,k):E,A=L(c,T,h,r);let C=A||e,V=null;P(A)&&(V=A,C=e);const _=j(C,V,T,h,x,k,m),D=s??x.defaultTransParent;return D?n.createElement(D,g,_):_}const _={type:"3rdParty",init(e){O(e.options.react),w(e)}},D=n.createContext();class K{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach((e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)}))}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const z=e=>async n=>({...await(e.getInitialProps?.(n))??{},...U()}),U=()=>{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 F=(e,n,t,s)=>e.getFixedT(n,t,s),B=(e,t={})=>{const{i18n:s}=t,{i18n:r,defaultNS:a}=n.useContext(D)||{},i=s||r||$();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new K),!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&&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(F(e,t,s,r),[e,t,s,r]))(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),h=()=>f,x=()=>F(i,t.lng||null,"fallback"===o.nsMode?u:u[0],c),[b,v]=n.useState(h);let E=u.join();t.lng&&(E=`${t.lng}${E}`);const O=((e,t)=>{const s=n.useRef();return n.useEffect((()=>{s.current=e}),[e,t]),s.current})(E),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&&v(x)})):m(i,u,(()=>{S.current&&v(x)}))),p&&O&&O!==E&&S.current&&v(x);const s=()=>{S.current&&v(x)};return e&&i?.on(e,s),n&&i?.store.on(n,s),()=>{S.current=!1,i&&e&&e?.split(" ").forEach((e=>i.off(e,s))),n&&i&&n.split(" ").forEach((e=>i.store.off(e,s)))}}),[i,E]),n.useEffect((()=>{S.current&&p&&v(h)}),[i,c,p]);const w=[b,i,p];if(w.t=b,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 W=(e,t,s={})=>{const{i18n:r}=s,{i18n:a}=n.useContext(D)||{},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=D,e.I18nextProvider=function({i18n:e,defaultNS:t,children:s}){const r=n.useMemo((()=>({i18n:e,defaultNS:t})),[e,t]);return n.createElement(D.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(D)||{},y=p||g||$(),N=d||y?.t.bind(y);return V({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=V,e.Translation=({ns:e,children:n,...t})=>{const[s,r,a]=B(e,t);return n(s,{i18n:r,lng:r.language},a)},e.composeInitialProps=z,e.date=()=>"",e.getDefaults=I,e.getI18n=$,e.getInitialProps=U,e.initReactI18next=_,e.number=()=>"",e.plural=()=>"",e.select=()=>"",e.selectOrdinal=()=>"",e.setDefaults=O,e.setI18n=w,e.time=()=>"",e.useSSR=W,e.useTranslation=B,e.withSSR=()=>function(e){function t({initialI18nStore:t,initialLanguage:s,...r}){return W(t,s),n.createElement(e,{...r})}return t.getInitialProps=z(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]=B(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}}));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.I18nextProvider = I18nextProvider;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _context = require("./context.js");
|
|
9
|
-
function I18nextProvider({
|
|
10
|
-
i18n,
|
|
11
|
-
defaultNS,
|
|
12
|
-
children
|
|
13
|
-
}) {
|
|
14
|
-
const value = (0, _react.useMemo)(() => ({
|
|
15
|
-
i18n,
|
|
16
|
-
defaultNS
|
|
17
|
-
}), [i18n, defaultNS]);
|
|
18
|
-
return (0, _react.createElement)(_context.I18nContext.Provider, {
|
|
19
|
-
value
|
|
20
|
-
}, children);
|
|
21
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Trans = Trans;
|
|
7
|
-
Object.defineProperty(exports, "nodesToString", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _TransWithoutContext.nodesToString;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
var _react = require("react");
|
|
14
|
-
var _TransWithoutContext = require("./TransWithoutContext.js");
|
|
15
|
-
var _context = require("./context.js");
|
|
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
|
-
}) {
|
|
32
|
-
const {
|
|
33
|
-
i18n: i18nFromContext,
|
|
34
|
-
defaultNS: defaultNSFromContext
|
|
35
|
-
} = (0, _react.useContext)(_context.I18nContext) || {};
|
|
36
|
-
const i18n = i18nFromProps || i18nFromContext || (0, _context.getI18n)();
|
|
37
|
-
const t = tFromProps || i18n?.t.bind(i18n);
|
|
38
|
-
return (0, _TransWithoutContext.Trans)({
|
|
39
|
-
children,
|
|
40
|
-
count,
|
|
41
|
-
parent,
|
|
42
|
-
i18nKey,
|
|
43
|
-
context,
|
|
44
|
-
tOptions,
|
|
45
|
-
values,
|
|
46
|
-
defaults,
|
|
47
|
-
components,
|
|
48
|
-
ns: ns || t?.ns || defaultNSFromContext || i18n?.options?.defaultNS,
|
|
49
|
-
i18n,
|
|
50
|
-
t: tFromProps,
|
|
51
|
-
shouldUnescape,
|
|
52
|
-
...additionalProps
|
|
53
|
-
});
|
|
54
|
-
}
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Trans = Trans;
|
|
8
|
-
exports.nodesToString = void 0;
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
var _htmlParseStringify = _interopRequireDefault(require("html-parse-stringify"));
|
|
11
|
-
var _utils = require("./utils.js");
|
|
12
|
-
var _defaults = require("./defaults.js");
|
|
13
|
-
var _i18nInstance = require("./i18nInstance.js");
|
|
14
|
-
const hasChildren = (node, checkLength) => {
|
|
15
|
-
if (!node) return false;
|
|
16
|
-
const base = node.props?.children ?? node.children;
|
|
17
|
-
if (checkLength) return base.length > 0;
|
|
18
|
-
return !!base;
|
|
19
|
-
};
|
|
20
|
-
const getChildren = node => {
|
|
21
|
-
if (!node) return [];
|
|
22
|
-
const children = node.props?.children ?? node.children;
|
|
23
|
-
return node.props?.i18nIsDynamicList ? getAsArray(children) : children;
|
|
24
|
-
};
|
|
25
|
-
const hasValidReactChildren = children => Array.isArray(children) && children.every(_react.isValidElement);
|
|
26
|
-
const getAsArray = data => Array.isArray(data) ? data : [data];
|
|
27
|
-
const mergeProps = (source, target) => {
|
|
28
|
-
const newTarget = {
|
|
29
|
-
...target
|
|
30
|
-
};
|
|
31
|
-
newTarget.props = Object.assign(source.props, target.props);
|
|
32
|
-
return newTarget;
|
|
33
|
-
};
|
|
34
|
-
const nodesToString = (children, i18nOptions, i18n, i18nKey) => {
|
|
35
|
-
if (!children) return '';
|
|
36
|
-
let stringNode = '';
|
|
37
|
-
const childrenArray = getAsArray(children);
|
|
38
|
-
const keepArray = i18nOptions?.transSupportBasicHtmlNodes ? i18nOptions.transKeepBasicHtmlNodesFor ?? [] : [];
|
|
39
|
-
childrenArray.forEach((child, childIndex) => {
|
|
40
|
-
if ((0, _utils.isString)(child)) {
|
|
41
|
-
stringNode += `${child}`;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if ((0, _react.isValidElement)(child)) {
|
|
45
|
-
const {
|
|
46
|
-
props,
|
|
47
|
-
type
|
|
48
|
-
} = child;
|
|
49
|
-
const childPropsCount = Object.keys(props).length;
|
|
50
|
-
const shouldKeepChild = keepArray.indexOf(type) > -1;
|
|
51
|
-
const childChildren = props.children;
|
|
52
|
-
if (!childChildren && shouldKeepChild && !childPropsCount) {
|
|
53
|
-
stringNode += `<${type}/>`;
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (!childChildren && (!shouldKeepChild || childPropsCount) || props.i18nIsDynamicList) {
|
|
57
|
-
stringNode += `<${childIndex}></${childIndex}>`;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (shouldKeepChild && childPropsCount === 1 && (0, _utils.isString)(childChildren)) {
|
|
61
|
-
stringNode += `<${type}>${childChildren}</${type}>`;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const content = nodesToString(childChildren, i18nOptions, i18n, i18nKey);
|
|
65
|
-
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (child === null) {
|
|
69
|
-
(0, _utils.warn)(i18n, 'TRANS_NULL_VALUE', `Passed in a null value as child`, {
|
|
70
|
-
i18nKey
|
|
71
|
-
});
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if ((0, _utils.isObject)(child)) {
|
|
75
|
-
const {
|
|
76
|
-
format,
|
|
77
|
-
...clone
|
|
78
|
-
} = child;
|
|
79
|
-
const keys = Object.keys(clone);
|
|
80
|
-
if (keys.length === 1) {
|
|
81
|
-
const value = format ? `${keys[0]}, ${format}` : keys[0];
|
|
82
|
-
stringNode += `{{${value}}}`;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
(0, _utils.warn)(i18n, 'TRANS_INVALID_OBJ', `Invalid child - Object should only have keys {{ value, format }} (format is optional).`, {
|
|
86
|
-
i18nKey,
|
|
87
|
-
child
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
(0, _utils.warn)(i18n, 'TRANS_INVALID_VAR', `Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`, {
|
|
92
|
-
i18nKey,
|
|
93
|
-
child
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
return stringNode;
|
|
97
|
-
};
|
|
98
|
-
exports.nodesToString = nodesToString;
|
|
99
|
-
const renderNodes = (children, knownComponentsMap, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) => {
|
|
100
|
-
if (targetString === '') return [];
|
|
101
|
-
const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
|
|
102
|
-
const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map(keep => `<${keep}`).join('|')).test(targetString);
|
|
103
|
-
if (!children && !knownComponentsMap && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString];
|
|
104
|
-
const data = knownComponentsMap ?? {};
|
|
105
|
-
const getData = childs => {
|
|
106
|
-
const childrenArray = getAsArray(childs);
|
|
107
|
-
childrenArray.forEach(child => {
|
|
108
|
-
if ((0, _utils.isString)(child)) return;
|
|
109
|
-
if (hasChildren(child)) getData(getChildren(child));else if ((0, _utils.isObject)(child) && !(0, _react.isValidElement)(child)) Object.assign(data, child);
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
getData(children);
|
|
113
|
-
const ast = _htmlParseStringify.default.parse(`<0>${targetString}</0>`);
|
|
114
|
-
const opts = {
|
|
115
|
-
...data,
|
|
116
|
-
...combinedTOpts
|
|
117
|
-
};
|
|
118
|
-
const renderInner = (child, node, rootReactNode) => {
|
|
119
|
-
const childs = getChildren(child);
|
|
120
|
-
const mappedChildren = mapAST(childs, node.children, rootReactNode);
|
|
121
|
-
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props?.i18nIsDynamicList ? childs : mappedChildren;
|
|
122
|
-
};
|
|
123
|
-
const pushTranslatedJSX = (child, inner, mem, i, isVoid) => {
|
|
124
|
-
if (child.dummy) {
|
|
125
|
-
child.children = inner;
|
|
126
|
-
mem.push((0, _react.cloneElement)(child, {
|
|
127
|
-
key: i
|
|
128
|
-
}, isVoid ? undefined : inner));
|
|
129
|
-
} else {
|
|
130
|
-
mem.push(..._react.Children.map([child], c => {
|
|
131
|
-
const props = {
|
|
132
|
-
...c.props
|
|
133
|
-
};
|
|
134
|
-
delete props.i18nIsDynamicList;
|
|
135
|
-
return (0, _react.createElement)(c.type, {
|
|
136
|
-
...props,
|
|
137
|
-
key: i,
|
|
138
|
-
ref: c.props.ref ?? c.ref
|
|
139
|
-
}, isVoid ? null : inner);
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
const mapAST = (reactNode, astNode, rootReactNode) => {
|
|
144
|
-
const reactNodes = getAsArray(reactNode);
|
|
145
|
-
const astNodes = getAsArray(astNode);
|
|
146
|
-
return astNodes.reduce((mem, node, i) => {
|
|
147
|
-
const translationContent = node.children?.[0]?.content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
|
|
148
|
-
if (node.type === 'tag') {
|
|
149
|
-
let tmp = reactNodes[parseInt(node.name, 10)];
|
|
150
|
-
if (!tmp && knownComponentsMap) tmp = knownComponentsMap[node.name];
|
|
151
|
-
if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
|
|
152
|
-
if (!tmp) tmp = {};
|
|
153
|
-
const child = Object.keys(node.attrs).length !== 0 ? mergeProps({
|
|
154
|
-
props: node.attrs
|
|
155
|
-
}, tmp) : tmp;
|
|
156
|
-
const isElement = (0, _react.isValidElement)(child);
|
|
157
|
-
const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
|
|
158
|
-
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && (0, _utils.isObject)(child) && child.dummy && !isElement;
|
|
159
|
-
const isKnownComponent = (0, _utils.isObject)(knownComponentsMap) && Object.hasOwnProperty.call(knownComponentsMap, node.name);
|
|
160
|
-
if ((0, _utils.isString)(child)) {
|
|
161
|
-
const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
|
|
162
|
-
mem.push(value);
|
|
163
|
-
} else if (hasChildren(child) || isValidTranslationWithChildren) {
|
|
164
|
-
const inner = renderInner(child, node, rootReactNode);
|
|
165
|
-
pushTranslatedJSX(child, inner, mem, i);
|
|
166
|
-
} else if (isEmptyTransWithHTML) {
|
|
167
|
-
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
168
|
-
pushTranslatedJSX(child, inner, mem, i);
|
|
169
|
-
} else if (Number.isNaN(parseFloat(node.name))) {
|
|
170
|
-
if (isKnownComponent) {
|
|
171
|
-
const inner = renderInner(child, node, rootReactNode);
|
|
172
|
-
pushTranslatedJSX(child, inner, mem, i, node.voidElement);
|
|
173
|
-
} else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
|
|
174
|
-
if (node.voidElement) {
|
|
175
|
-
mem.push((0, _react.createElement)(node.name, {
|
|
176
|
-
key: `${node.name}-${i}`
|
|
177
|
-
}));
|
|
178
|
-
} else {
|
|
179
|
-
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
180
|
-
mem.push((0, _react.createElement)(node.name, {
|
|
181
|
-
key: `${node.name}-${i}`
|
|
182
|
-
}, inner));
|
|
183
|
-
}
|
|
184
|
-
} else if (node.voidElement) {
|
|
185
|
-
mem.push(`<${node.name} />`);
|
|
186
|
-
} else {
|
|
187
|
-
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
188
|
-
mem.push(`<${node.name}>${inner}</${node.name}>`);
|
|
189
|
-
}
|
|
190
|
-
} else if ((0, _utils.isObject)(child) && !isElement) {
|
|
191
|
-
const content = node.children[0] ? translationContent : null;
|
|
192
|
-
if (content) mem.push(content);
|
|
193
|
-
} else {
|
|
194
|
-
pushTranslatedJSX(child, translationContent, mem, i, node.children.length !== 1 || !translationContent);
|
|
195
|
-
}
|
|
196
|
-
} else if (node.type === 'text') {
|
|
197
|
-
const wrapTextNodes = i18nOptions.transWrapTextNodes;
|
|
198
|
-
const content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
|
|
199
|
-
if (wrapTextNodes) {
|
|
200
|
-
mem.push((0, _react.createElement)(wrapTextNodes, {
|
|
201
|
-
key: `${node.name}-${i}`
|
|
202
|
-
}, content));
|
|
203
|
-
} else {
|
|
204
|
-
mem.push(content);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return mem;
|
|
208
|
-
}, []);
|
|
209
|
-
};
|
|
210
|
-
const result = mapAST([{
|
|
211
|
-
dummy: true,
|
|
212
|
-
children: children || []
|
|
213
|
-
}], ast, getAsArray(children || []));
|
|
214
|
-
return getChildren(result[0]);
|
|
215
|
-
};
|
|
216
|
-
const fixComponentProps = (component, index, translation) => {
|
|
217
|
-
const componentKey = component.key || index;
|
|
218
|
-
const comp = (0, _react.cloneElement)(component, {
|
|
219
|
-
key: componentKey
|
|
220
|
-
});
|
|
221
|
-
if (!comp.props || !comp.props.children || translation.indexOf(`${index}/>`) < 0 && translation.indexOf(`${index} />`) < 0) {
|
|
222
|
-
return comp;
|
|
223
|
-
}
|
|
224
|
-
function Componentized() {
|
|
225
|
-
return (0, _react.createElement)(_react.Fragment, null, comp);
|
|
226
|
-
}
|
|
227
|
-
return (0, _react.createElement)(Componentized, {
|
|
228
|
-
key: componentKey
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
const generateArrayComponents = (components, translation) => components.map((c, index) => fixComponentProps(c, index, translation));
|
|
232
|
-
const generateObjectComponents = (components, translation) => {
|
|
233
|
-
const componentMap = {};
|
|
234
|
-
Object.keys(components).forEach(c => {
|
|
235
|
-
Object.assign(componentMap, {
|
|
236
|
-
[c]: fixComponentProps(components[c], c, translation)
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
return componentMap;
|
|
240
|
-
};
|
|
241
|
-
const generateComponents = (components, translation, i18n, i18nKey) => {
|
|
242
|
-
if (!components) return null;
|
|
243
|
-
if (Array.isArray(components)) {
|
|
244
|
-
return generateArrayComponents(components, translation);
|
|
245
|
-
}
|
|
246
|
-
if ((0, _utils.isObject)(components)) {
|
|
247
|
-
return generateObjectComponents(components, translation);
|
|
248
|
-
}
|
|
249
|
-
(0, _utils.warnOnce)(i18n, 'TRANS_INVALID_COMPONENTS', `<Trans /> "components" prop expects an object or array`, {
|
|
250
|
-
i18nKey
|
|
251
|
-
});
|
|
252
|
-
return null;
|
|
253
|
-
};
|
|
254
|
-
const isComponentsMap = object => {
|
|
255
|
-
if (!(0, _utils.isObject)(object)) return false;
|
|
256
|
-
if (Array.isArray(object)) return false;
|
|
257
|
-
return Object.keys(object).reduce((acc, key) => acc && Number.isNaN(Number.parseFloat(key)), true);
|
|
258
|
-
};
|
|
259
|
-
function Trans({
|
|
260
|
-
children,
|
|
261
|
-
count,
|
|
262
|
-
parent,
|
|
263
|
-
i18nKey,
|
|
264
|
-
context,
|
|
265
|
-
tOptions = {},
|
|
266
|
-
values,
|
|
267
|
-
defaults,
|
|
268
|
-
components,
|
|
269
|
-
ns,
|
|
270
|
-
i18n: i18nFromProps,
|
|
271
|
-
t: tFromProps,
|
|
272
|
-
shouldUnescape,
|
|
273
|
-
...additionalProps
|
|
274
|
-
}) {
|
|
275
|
-
const i18n = i18nFromProps || (0, _i18nInstance.getI18n)();
|
|
276
|
-
if (!i18n) {
|
|
277
|
-
(0, _utils.warnOnce)(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
|
|
278
|
-
i18nKey
|
|
279
|
-
});
|
|
280
|
-
return children;
|
|
281
|
-
}
|
|
282
|
-
const t = tFromProps || i18n.t.bind(i18n) || (k => k);
|
|
283
|
-
const reactI18nextOptions = {
|
|
284
|
-
...(0, _defaults.getDefaults)(),
|
|
285
|
-
...i18n.options?.react
|
|
286
|
-
};
|
|
287
|
-
let namespaces = ns || t.ns || i18n.options?.defaultNS;
|
|
288
|
-
namespaces = (0, _utils.isString)(namespaces) ? [namespaces] : namespaces || ['translation'];
|
|
289
|
-
const nodeAsString = nodesToString(children, reactI18nextOptions, i18n, i18nKey);
|
|
290
|
-
const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
|
|
291
|
-
const {
|
|
292
|
-
hashTransKey
|
|
293
|
-
} = reactI18nextOptions;
|
|
294
|
-
const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
|
|
295
|
-
if (i18n.options?.interpolation?.defaultVariables) {
|
|
296
|
-
values = values && Object.keys(values).length > 0 ? {
|
|
297
|
-
...values,
|
|
298
|
-
...i18n.options.interpolation.defaultVariables
|
|
299
|
-
} : {
|
|
300
|
-
...i18n.options.interpolation.defaultVariables
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
const interpolationOverride = values || count !== undefined && !i18n.options?.interpolation?.alwaysFormat || !children ? tOptions.interpolation : {
|
|
304
|
-
interpolation: {
|
|
305
|
-
...tOptions.interpolation,
|
|
306
|
-
prefix: '#$?',
|
|
307
|
-
suffix: '?$#'
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
const combinedTOpts = {
|
|
311
|
-
...tOptions,
|
|
312
|
-
context: context || tOptions.context,
|
|
313
|
-
count,
|
|
314
|
-
...values,
|
|
315
|
-
...interpolationOverride,
|
|
316
|
-
defaultValue,
|
|
317
|
-
ns: namespaces
|
|
318
|
-
};
|
|
319
|
-
const translation = key ? t(key, combinedTOpts) : defaultValue;
|
|
320
|
-
const generatedComponents = generateComponents(components, translation, i18n, i18nKey);
|
|
321
|
-
let indexedChildren = generatedComponents || children;
|
|
322
|
-
let componentsMap = null;
|
|
323
|
-
if (isComponentsMap(generatedComponents)) {
|
|
324
|
-
componentsMap = generatedComponents;
|
|
325
|
-
indexedChildren = children;
|
|
326
|
-
}
|
|
327
|
-
const content = renderNodes(indexedChildren, componentsMap, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
|
|
328
|
-
const useAsParent = parent ?? reactI18nextOptions.defaultTransParent;
|
|
329
|
-
return useAsParent ? (0, _react.createElement)(useAsParent, additionalProps, content) : content;
|
|
330
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Translation = void 0;
|
|
7
|
-
var _useTranslation = require("./useTranslation.js");
|
|
8
|
-
const Translation = ({
|
|
9
|
-
ns,
|
|
10
|
-
children,
|
|
11
|
-
...options
|
|
12
|
-
}) => {
|
|
13
|
-
const [t, i18n, ready] = (0, _useTranslation.useTranslation)(ns, options);
|
|
14
|
-
return children(t, {
|
|
15
|
-
i18n,
|
|
16
|
-
lng: i18n.language
|
|
17
|
-
}, ready);
|
|
18
|
-
};
|
|
19
|
-
exports.Translation = Translation;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.composeInitialProps = exports.ReportNamespaces = exports.I18nContext = void 0;
|
|
7
|
-
Object.defineProperty(exports, "getDefaults", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _defaults.getDefaults;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "getI18n", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _i18nInstance.getI18n;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
exports.getInitialProps = void 0;
|
|
20
|
-
Object.defineProperty(exports, "initReactI18next", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _initReactI18next.initReactI18next;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "setDefaults", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return _defaults.setDefaults;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, "setI18n", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _i18nInstance.setI18n;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
var _react = require("react");
|
|
39
|
-
var _defaults = require("./defaults.js");
|
|
40
|
-
var _i18nInstance = require("./i18nInstance.js");
|
|
41
|
-
var _initReactI18next = require("./initReactI18next.js");
|
|
42
|
-
const I18nContext = exports.I18nContext = (0, _react.createContext)();
|
|
43
|
-
class ReportNamespaces {
|
|
44
|
-
constructor() {
|
|
45
|
-
this.usedNamespaces = {};
|
|
46
|
-
}
|
|
47
|
-
addUsedNamespaces(namespaces) {
|
|
48
|
-
namespaces.forEach(ns => {
|
|
49
|
-
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
getUsedNamespaces() {
|
|
53
|
-
return Object.keys(this.usedNamespaces);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.ReportNamespaces = ReportNamespaces;
|
|
57
|
-
const composeInitialProps = ForComponent => async ctx => {
|
|
58
|
-
const componentsInitialProps = (await ForComponent.getInitialProps?.(ctx)) ?? {};
|
|
59
|
-
const i18nInitialProps = getInitialProps();
|
|
60
|
-
return {
|
|
61
|
-
...componentsInitialProps,
|
|
62
|
-
...i18nInitialProps
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
exports.composeInitialProps = composeInitialProps;
|
|
66
|
-
const getInitialProps = () => {
|
|
67
|
-
const i18n = (0, _i18nInstance.getI18n)();
|
|
68
|
-
const namespaces = i18n.reportNamespaces?.getUsedNamespaces() ?? [];
|
|
69
|
-
const ret = {};
|
|
70
|
-
const initialI18nStore = {};
|
|
71
|
-
i18n.languages.forEach(l => {
|
|
72
|
-
initialI18nStore[l] = {};
|
|
73
|
-
namespaces.forEach(ns => {
|
|
74
|
-
initialI18nStore[l][ns] = i18n.getResourceBundle(l, ns) || {};
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
ret.initialI18nStore = initialI18nStore;
|
|
78
|
-
ret.initialLanguage = i18n.language;
|
|
79
|
-
return ret;
|
|
80
|
-
};
|
|
81
|
-
exports.getInitialProps = getInitialProps;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setDefaults = exports.getDefaults = void 0;
|
|
7
|
-
var _unescape = require("./unescape.js");
|
|
8
|
-
let defaultOptions = {
|
|
9
|
-
bindI18n: 'languageChanged',
|
|
10
|
-
bindI18nStore: '',
|
|
11
|
-
transEmptyNodeValue: '',
|
|
12
|
-
transSupportBasicHtmlNodes: true,
|
|
13
|
-
transWrapTextNodes: '',
|
|
14
|
-
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
15
|
-
useSuspense: true,
|
|
16
|
-
unescape: _unescape.unescape
|
|
17
|
-
};
|
|
18
|
-
const setDefaults = (options = {}) => {
|
|
19
|
-
defaultOptions = {
|
|
20
|
-
...defaultOptions,
|
|
21
|
-
...options
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.setDefaults = setDefaults;
|
|
25
|
-
const getDefaults = () => defaultOptions;
|
|
26
|
-
exports.getDefaults = getDefaults;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setI18n = exports.getI18n = void 0;
|
|
7
|
-
let i18nInstance;
|
|
8
|
-
const setI18n = instance => {
|
|
9
|
-
i18nInstance = instance;
|
|
10
|
-
};
|
|
11
|
-
exports.setI18n = setI18n;
|
|
12
|
-
const getI18n = () => i18nInstance;
|
|
13
|
-
exports.getI18n = getI18n;
|