@entropic-bond/localize-react 1.6.8 → 1.7.1
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/lib/entropic-bond-localize-react.js +1645 -0
- package/lib/entropic-bond-localize-react.umd.cjs +39 -0
- package/package.json +31 -24
- package/lib/index.js +0 -19
- package/lib/index.js.map +0 -1
- package/lib/locale.js +0 -149
- package/lib/locale.js.map +0 -1
- package/lib/locale.spec.js +0 -107
- package/lib/locale.spec.js.map +0 -1
- package/lib/localized-component.js +0 -131
- package/lib/localized-component.js.map +0 -1
- package/lib/react-localizer.spec.js +0 -185
- package/lib/react-localizer.spec.js.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
(function(M,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(M=typeof globalThis<"u"?globalThis:M||self,D(M["entropic-bond-localize-react"]={}))})(this,function(M){"use strict";const A=class A{constructor(o){this._pendingPromise=void 0,this._table=void 0,this._table=void 0,this._pendingPromise=void 0,this._lang=o.locale||"en",this._localePath=o.localePath||""}static get instance(){return this._instance||(this._instance=new A(this._registeredConfig)),this._instance}static get currentLocale(){return A._registeredConfig.locale||A.instance._lang}pluralize(o,y=0,_){var z;if(y===1)return o;let L;if(typeof _!="function"){if(L=_==null?void 0:_[o],L)return L}else L=_==null?void 0:_(o,this._lang);let N=0;const F=A._registeredRules[this._lang];for(;!L&&F&&N<F.length;)L=(z=F[N++])==null?void 0:z.call(F,o,this._lang);return L??o}static config(o){this._registeredConfig={...this._registeredConfig,...o},this._instance=void 0}async get(o){return this._table||(this._table=await this.fetchCache(async()=>{try{return(await fetch(this.getLocaleFilePath())).json()}catch{return(await fetch(this.getLocaleFilePath("en"))).json()}})),this._table[o]}fetchCache(o){return this._pendingPromise||(this._pendingPromise=new Promise(y=>y(o()))),this._pendingPromise}getLocaleFilePath(o){return this._lang.indexOf("http")<0?`${this._localePath}/${o||this._lang}.json`:this._lang}static usePluralizerRule(o,y){A._registeredRules[y]||(A._registeredRules[y]=[]),!(A._registeredRules[y].indexOf(o)>=0)&&A._registeredRules[y].unshift(o)}static useRule(o,y){return A.usePluralizerRule(o,y)}};A.defaultRules={en:[o=>o.slice(-1)==="f"?o.slice(0,-1)+"ves":o.slice(-1)==="o"?o.slice(0,-1)+"oes":o.slice(-1)==="x"?o.slice(0,-1)+"xes":o.slice(-1)==="h"?o.slice(0,-1)+"hes":o.slice(-1)==="s"?o.slice(0,-1)+"ses":o.slice(-1)==="y"?o.slice(0,-1)+"ies":o.slice(-1)==="z"?o.slice(0,-1)+"zes":o+"s"],es:[o=>o.slice(-1)==="l"?o.slice(0,-1)+"les":o.slice(-1)==="n"?o.slice(0,-1)+"nes":o.slice(-1)==="r"?o.slice(0,-1)+"res":o.slice(-1)==="z"?o.slice(0,-1)+"ces":o+"s"]},A._instance=void 0,A._registeredConfig={},A._registeredRules=A.defaultRules;let D=A;var je={exports:{}},p={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var He;function At(){if(He)return p;He=1;var P=Symbol.for("react.element"),o=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),N=Symbol.for("react.provider"),F=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),ue=Symbol.for("react.suspense"),Z=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),K=Symbol.iterator;function se(r){return r===null||typeof r!="object"?null:(r=K&&r[K]||r["@@iterator"],typeof r=="function"?r:null)}var U={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Q=Object.assign,ve={};function W(r,u,d){this.props=r,this.context=u,this.refs=ve,this.updater=d||U}W.prototype.isReactComponent={},W.prototype.setState=function(r,u){if(typeof r!="object"&&typeof r!="function"&&r!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,r,u,"setState")},W.prototype.forceUpdate=function(r){this.updater.enqueueForceUpdate(this,r,"forceUpdate")};function he(){}he.prototype=W.prototype;function ee(r,u,d){this.props=r,this.context=u,this.refs=ve,this.updater=d||U}var te=ee.prototype=new he;te.constructor=ee,Q(te,W.prototype),te.isPureReactComponent=!0;var Y=Array.isArray,k=Object.prototype.hasOwnProperty,x={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function J(r,u,d){var m,v={},b=null,O=null;if(u!=null)for(m in u.ref!==void 0&&(O=u.ref),u.key!==void 0&&(b=""+u.key),u)k.call(u,m)&&!B.hasOwnProperty(m)&&(v[m]=u[m]);var R=arguments.length-2;if(R===1)v.children=d;else if(1<R){for(var E=Array(R),$=0;$<R;$++)E[$]=arguments[$+2];v.children=E}if(r&&r.defaultProps)for(m in R=r.defaultProps,R)v[m]===void 0&&(v[m]=R[m]);return{$$typeof:P,type:r,key:b,ref:O,props:v,_owner:x.current}}function ye(r,u){return{$$typeof:P,type:r.type,key:u,ref:r.ref,props:r.props,_owner:r._owner}}function ce(r){return typeof r=="object"&&r!==null&&r.$$typeof===P}function Le(r){var u={"=":"=0",":":"=2"};return"$"+r.replace(/[=:]/g,function(d){return u[d]})}var me=/\/+/g;function le(r,u){return typeof r=="object"&&r!==null&&r.key!=null?Le(""+r.key):u.toString(36)}function re(r,u,d,m,v){var b=typeof r;(b==="undefined"||b==="boolean")&&(r=null);var O=!1;if(r===null)O=!0;else switch(b){case"string":case"number":O=!0;break;case"object":switch(r.$$typeof){case P:case o:O=!0}}if(O)return O=r,v=v(O),r=m===""?"."+le(O,0):m,Y(v)?(d="",r!=null&&(d=r.replace(me,"$&/")+"/"),re(v,u,d,"",function($){return $})):v!=null&&(ce(v)&&(v=ye(v,d+(!v.key||O&&O.key===v.key?"":(""+v.key).replace(me,"$&/")+"/")+r)),u.push(v)),1;if(O=0,m=m===""?".":m+":",Y(r))for(var R=0;R<r.length;R++){b=r[R];var E=m+le(b,R);O+=re(b,u,d,E,v)}else if(E=se(r),typeof E=="function")for(r=E.call(r),R=0;!(b=r.next()).done;)b=b.value,E=m+le(b,R++),O+=re(b,u,d,E,v);else if(b==="object")throw u=String(r),Error("Objects are not valid as a React child (found: "+(u==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":u)+"). If you meant to render a collection of children, use an array instead.");return O}function V(r,u,d){if(r==null)return r;var m=[],v=0;return re(r,m,"","",function(b){return u.call(d,b,v++)}),m}function H(r){if(r._status===-1){var u=r._result;u=u(),u.then(function(d){(r._status===0||r._status===-1)&&(r._status=1,r._result=d)},function(d){(r._status===0||r._status===-1)&&(r._status=2,r._result=d)}),r._status===-1&&(r._status=0,r._result=u)}if(r._status===1)return r._result.default;throw r._result}var l={current:null},X={transition:null},ge={ReactCurrentDispatcher:l,ReactCurrentBatchConfig:X,ReactCurrentOwner:x};return p.Children={map:V,forEach:function(r,u,d){V(r,function(){u.apply(this,arguments)},d)},count:function(r){var u=0;return V(r,function(){u++}),u},toArray:function(r){return V(r,function(u){return u})||[]},only:function(r){if(!ce(r))throw Error("React.Children.only expected to receive a single React element child.");return r}},p.Component=W,p.Fragment=y,p.Profiler=L,p.PureComponent=ee,p.StrictMode=_,p.Suspense=ue,p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ge,p.cloneElement=function(r,u,d){if(r==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+r+".");var m=Q({},r.props),v=r.key,b=r.ref,O=r._owner;if(u!=null){if(u.ref!==void 0&&(b=u.ref,O=x.current),u.key!==void 0&&(v=""+u.key),r.type&&r.type.defaultProps)var R=r.type.defaultProps;for(E in u)k.call(u,E)&&!B.hasOwnProperty(E)&&(m[E]=u[E]===void 0&&R!==void 0?R[E]:u[E])}var E=arguments.length-2;if(E===1)m.children=d;else if(1<E){R=Array(E);for(var $=0;$<E;$++)R[$]=arguments[$+2];m.children=R}return{$$typeof:P,type:r.type,key:v,ref:b,props:m,_owner:O}},p.createContext=function(r){return r={$$typeof:F,_currentValue:r,_currentValue2:r,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},r.Provider={$$typeof:N,_context:r},r.Consumer=r},p.createElement=J,p.createFactory=function(r){var u=J.bind(null,r);return u.type=r,u},p.createRef=function(){return{current:null}},p.forwardRef=function(r){return{$$typeof:z,render:r}},p.isValidElement=ce,p.lazy=function(r){return{$$typeof:G,_payload:{_status:-1,_result:r},_init:H}},p.memo=function(r,u){return{$$typeof:Z,type:r,compare:u===void 0?null:u}},p.startTransition=function(r){var u=X.transition;X.transition={};try{r()}finally{X.transition=u}},p.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},p.useCallback=function(r,u){return l.current.useCallback(r,u)},p.useContext=function(r){return l.current.useContext(r)},p.useDebugValue=function(){},p.useDeferredValue=function(r){return l.current.useDeferredValue(r)},p.useEffect=function(r,u){return l.current.useEffect(r,u)},p.useId=function(){return l.current.useId()},p.useImperativeHandle=function(r,u,d){return l.current.useImperativeHandle(r,u,d)},p.useInsertionEffect=function(r,u){return l.current.useInsertionEffect(r,u)},p.useLayoutEffect=function(r,u){return l.current.useLayoutEffect(r,u)},p.useMemo=function(r,u){return l.current.useMemo(r,u)},p.useReducer=function(r,u,d){return l.current.useReducer(r,u,d)},p.useRef=function(r){return l.current.useRef(r)},p.useState=function(r){return l.current.useState(r)},p.useSyncExternalStore=function(r,u,d){return l.current.useSyncExternalStore(r,u,d)},p.useTransition=function(){return l.current.useTransition()},p.version="18.2.0",p}var ie={exports:{}};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/ie.exports;var qe;function Lt(){return qe||(qe=1,function(P,o){process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var y="18.2.0",_=Symbol.for("react.element"),L=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),ue=Symbol.for("react.provider"),Z=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),ve=Symbol.for("react.offscreen"),W=Symbol.iterator,he="@@iterator";function ee(e){if(e===null||typeof e!="object")return null;var t=W&&e[W]||e[he];return typeof t=="function"?t:null}var te={current:null},Y={transition:null},k={current:null,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1},x={current:null},B={},J=null;function ye(e){J=e}B.setExtraStackFrame=function(e){J=e},B.getCurrentStack=null,B.getStackAddendum=function(){var e="";J&&(e+=J);var t=B.getCurrentStack;return t&&(e+=t()||""),e};var ce=!1,Le=!1,me=!1,le=!1,re=!1,V={ReactCurrentDispatcher:te,ReactCurrentBatchConfig:Y,ReactCurrentOwner:x};V.ReactDebugCurrentFrame=B,V.ReactCurrentActQueue=k;function H(e){{for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];X("warn",e,n)}}function l(e){{for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];X("error",e,n)}}function X(e,t,n){{var a=V.ReactDebugCurrentFrame,i=a.getStackAddendum();i!==""&&(t+="%s",n=n.concat([i]));var c=n.map(function(s){return String(s)});c.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,c)}}var ge={};function r(e,t){{var n=e.constructor,a=n&&(n.displayName||n.name)||"ReactClass",i=a+"."+t;if(ge[i])return;l("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",t,a),ge[i]=!0}}var u={isMounted:function(e){return!1},enqueueForceUpdate:function(e,t,n){r(e,"forceUpdate")},enqueueReplaceState:function(e,t,n,a){r(e,"replaceState")},enqueueSetState:function(e,t,n,a){r(e,"setState")}},d=Object.assign,m={};Object.freeze(m);function v(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||u}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};{var b={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]},O=function(e,t){Object.defineProperty(v.prototype,e,{get:function(){H("%s(...) is deprecated in plain JavaScript React classes. %s",t[0],t[1])}})};for(var R in b)b.hasOwnProperty(R)&&O(R,b[R])}function E(){}E.prototype=v.prototype;function $(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||u}var $e=$.prototype=new E;$e.constructor=$,d($e,v.prototype),$e.isPureReactComponent=!0;function xt(){var e={current:null};return Object.seal(e),e}var Mt=Array.isArray;function _e(e){return Mt(e)}function Nt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,n=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function Vt(e){try{return Ke(e),!1}catch{return!0}}function Ke(e){return""+e}function be(e){if(Vt(e))return l("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Nt(e)),Ke(e)}function Ut(e,t,n){var a=e.displayName;if(a)return a;var i=t.displayName||t.name||"";return i!==""?n+"("+i+")":n}function Qe(e){return e.displayName||"Context"}function q(e){if(e==null)return null;if(typeof e.tag=="number"&&l("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case L:return"Portal";case z:return"Profiler";case F:return"StrictMode";case K:return"Suspense";case se:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:var t=e;return Qe(t)+".Consumer";case ue:var n=e;return Qe(n._context)+".Provider";case G:return Ut(e,e.render,"ForwardRef");case U:var a=e.displayName||null;return a!==null?a:q(e.type)||"Memo";case Q:{var i=e,c=i._payload,s=i._init;try{return q(s(c))}catch{return null}}}return null}var fe=Object.prototype.hasOwnProperty,Je={key:!0,ref:!0,__self:!0,__source:!0},Xe,Ze,Ie;Ie={};function et(e){if(fe.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function tt(e){if(fe.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Wt(e,t){var n=function(){Xe||(Xe=!0,l("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function Yt(e,t){var n=function(){Ze||(Ze=!0,l("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}function zt(e){if(typeof e.ref=="string"&&x.current&&e.__self&&x.current.stateNode!==e.__self){var t=q(x.current.type);Ie[t]||(l('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',t,e.ref),Ie[t]=!0)}}var De=function(e,t,n,a,i,c,s){var f={$$typeof:_,type:e,key:t,ref:n,props:s,_owner:c};return f._store={},Object.defineProperty(f._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(f,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(f,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f};function Bt(e,t,n){var a,i={},c=null,s=null,f=null,h=null;if(t!=null){et(t)&&(s=t.ref,zt(t)),tt(t)&&(be(t.key),c=""+t.key),f=t.__self===void 0?null:t.__self,h=t.__source===void 0?null:t.__source;for(a in t)fe.call(t,a)&&!Je.hasOwnProperty(a)&&(i[a]=t[a])}var g=arguments.length-2;if(g===1)i.children=n;else if(g>1){for(var C=Array(g),S=0;S<g;S++)C[S]=arguments[S+2];Object.freeze&&Object.freeze(C),i.children=C}if(e&&e.defaultProps){var w=e.defaultProps;for(a in w)i[a]===void 0&&(i[a]=w[a])}if(c||s){var T=typeof e=="function"?e.displayName||e.name||"Unknown":e;c&&Wt(i,T),s&&Yt(i,T)}return De(e,c,s,f,h,x.current,i)}function Ht(e,t){var n=De(e.type,t,e.ref,e._self,e._source,e._owner,e.props);return n}function qt(e,t,n){if(e==null)throw new Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var a,i=d({},e.props),c=e.key,s=e.ref,f=e._self,h=e._source,g=e._owner;if(t!=null){et(t)&&(s=t.ref,g=x.current),tt(t)&&(be(t.key),c=""+t.key);var C;e.type&&e.type.defaultProps&&(C=e.type.defaultProps);for(a in t)fe.call(t,a)&&!Je.hasOwnProperty(a)&&(t[a]===void 0&&C!==void 0?i[a]=C[a]:i[a]=t[a])}var S=arguments.length-2;if(S===1)i.children=n;else if(S>1){for(var w=Array(S),T=0;T<S;T++)w[T]=arguments[T+2];i.children=w}return De(e.type,c,s,f,h,g,i)}function ne(e){return typeof e=="object"&&e!==null&&e.$$typeof===_}var rt=".",Gt=":";function Kt(e){var t=/[=:]/g,n={"=":"=0",":":"=2"},a=e.replace(t,function(i){return n[i]});return"$"+a}var nt=!1,Qt=/\/+/g;function at(e){return e.replace(Qt,"$&/")}function Fe(e,t){return typeof e=="object"&&e!==null&&e.key!=null?(be(e.key),Kt(""+e.key)):t.toString(36)}function Re(e,t,n,a,i){var c=typeof e;(c==="undefined"||c==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(c){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case _:case L:s=!0}}if(s){var f=e,h=i(f),g=a===""?rt+Fe(f,0):a;if(_e(h)){var C="";g!=null&&(C=at(g)+"/"),Re(h,t,C,"",function(Yr){return Yr})}else h!=null&&(ne(h)&&(h.key&&(!f||f.key!==h.key)&&be(h.key),h=Ht(h,n+(h.key&&(!f||f.key!==h.key)?at(""+h.key)+"/":"")+g)),t.push(h));return 1}var S,w,T=0,j=a===""?rt:a+Gt;if(_e(e))for(var ke=0;ke<e.length;ke++)S=e[ke],w=j+Fe(S,ke),T+=Re(S,t,n,w,i);else{var Be=ee(e);if(typeof Be=="function"){var Pt=e;Be===Pt.entries&&(nt||H("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),nt=!0);for(var Ur=Be.call(Pt),kt,Wr=0;!(kt=Ur.next()).done;)S=kt.value,w=j+Fe(S,Wr++),T+=Re(S,t,n,w,i)}else if(c==="object"){var jt=String(e);throw new Error("Objects are not valid as a React child (found: "+(jt==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":jt)+"). If you meant to render a collection of children, use an array instead.")}}return T}function Ee(e,t,n){if(e==null)return e;var a=[],i=0;return Re(e,a,"","",function(c){return t.call(n,c,i++)}),a}function Jt(e){var t=0;return Ee(e,function(){t++}),t}function Xt(e,t,n){Ee(e,function(){t.apply(this,arguments)},n)}function Zt(e){return Ee(e,function(t){return t})||[]}function er(e){if(!ne(e))throw new Error("React.Children.only expected to receive a single React element child.");return e}function tr(e){var t={$$typeof:Z,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};t.Provider={$$typeof:ue,_context:t};var n=!1,a=!1,i=!1;{var c={$$typeof:Z,_context:t};Object.defineProperties(c,{Provider:{get:function(){return a||(a=!0,l("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?")),t.Provider},set:function(s){t.Provider=s}},_currentValue:{get:function(){return t._currentValue},set:function(s){t._currentValue=s}},_currentValue2:{get:function(){return t._currentValue2},set:function(s){t._currentValue2=s}},_threadCount:{get:function(){return t._threadCount},set:function(s){t._threadCount=s}},Consumer:{get:function(){return n||(n=!0,l("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?")),t.Consumer}},displayName:{get:function(){return t.displayName},set:function(s){i||(H("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.",s),i=!0)}}}),t.Consumer=c}return t._currentRenderer=null,t._currentRenderer2=null,t}var de=-1,xe=0,ot=1,rr=2;function nr(e){if(e._status===de){var t=e._result,n=t();if(n.then(function(c){if(e._status===xe||e._status===de){var s=e;s._status=ot,s._result=c}},function(c){if(e._status===xe||e._status===de){var s=e;s._status=rr,s._result=c}}),e._status===de){var a=e;a._status=xe,a._result=n}}if(e._status===ot){var i=e._result;return i===void 0&&l(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
18
|
+
|
|
19
|
+
Your code should look like:
|
|
20
|
+
const MyComponent = lazy(() => import('./MyComponent'))
|
|
21
|
+
|
|
22
|
+
Did you accidentally put curly braces around the import?`,i),"default"in i||l(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
23
|
+
|
|
24
|
+
Your code should look like:
|
|
25
|
+
const MyComponent = lazy(() => import('./MyComponent'))`,i),i.default}else throw e._result}function ar(e){var t={_status:de,_result:e},n={$$typeof:Q,_payload:t,_init:nr};{var a,i;Object.defineProperties(n,{defaultProps:{configurable:!0,get:function(){return a},set:function(c){l("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."),a=c,Object.defineProperty(n,"defaultProps",{enumerable:!0})}},propTypes:{configurable:!0,get:function(){return i},set:function(c){l("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."),i=c,Object.defineProperty(n,"propTypes",{enumerable:!0})}}})}return n}function or(e){e!=null&&e.$$typeof===U?l("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof e!="function"?l("forwardRef requires a render function but was given %s.",e===null?"null":typeof e):e.length!==0&&e.length!==2&&l("forwardRef render functions accept exactly two parameters: props and ref. %s",e.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),e!=null&&(e.defaultProps!=null||e.propTypes!=null)&&l("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");var t={$$typeof:G,render:e};{var n;Object.defineProperty(t,"displayName",{enumerable:!1,configurable:!0,get:function(){return n},set:function(a){n=a,!e.name&&!e.displayName&&(e.displayName=a)}})}return t}var it;it=Symbol.for("react.module.reference");function ut(e){return!!(typeof e=="string"||typeof e=="function"||e===N||e===z||re||e===F||e===K||e===se||le||e===ve||ce||Le||me||typeof e=="object"&&e!==null&&(e.$$typeof===Q||e.$$typeof===U||e.$$typeof===ue||e.$$typeof===Z||e.$$typeof===G||e.$$typeof===it||e.getModuleId!==void 0))}function ir(e,t){ut(e)||l("memo: The first argument must be a component. Instead received: %s",e===null?"null":typeof e);var n={$$typeof:U,type:e,compare:t===void 0?null:t};{var a;Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return a},set:function(i){a=i,!e.name&&!e.displayName&&(e.displayName=i)}})}return n}function I(){var e=te.current;return e===null&&l(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
26
|
+
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
27
|
+
2. You might be breaking the Rules of Hooks
|
|
28
|
+
3. You might have more than one copy of React in the same app
|
|
29
|
+
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.`),e}function ur(e){var t=I();if(e._context!==void 0){var n=e._context;n.Consumer===e?l("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?"):n.Provider===e&&l("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?")}return t.useContext(e)}function sr(e){var t=I();return t.useState(e)}function cr(e,t,n){var a=I();return a.useReducer(e,t,n)}function lr(e){var t=I();return t.useRef(e)}function fr(e,t){var n=I();return n.useEffect(e,t)}function dr(e,t){var n=I();return n.useInsertionEffect(e,t)}function pr(e,t){var n=I();return n.useLayoutEffect(e,t)}function vr(e,t){var n=I();return n.useCallback(e,t)}function hr(e,t){var n=I();return n.useMemo(e,t)}function yr(e,t,n){var a=I();return a.useImperativeHandle(e,t,n)}function mr(e,t){{var n=I();return n.useDebugValue(e,t)}}function gr(){var e=I();return e.useTransition()}function _r(e){var t=I();return t.useDeferredValue(e)}function br(){var e=I();return e.useId()}function Rr(e,t,n){var a=I();return a.useSyncExternalStore(e,t,n)}var pe=0,st,ct,lt,ft,dt,pt,vt;function ht(){}ht.__reactDisabledLog=!0;function Er(){{if(pe===0){st=console.log,ct=console.info,lt=console.warn,ft=console.error,dt=console.group,pt=console.groupCollapsed,vt=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ht,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}pe++}}function Cr(){{if(pe--,pe===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:d({},e,{value:st}),info:d({},e,{value:ct}),warn:d({},e,{value:lt}),error:d({},e,{value:ft}),group:d({},e,{value:dt}),groupCollapsed:d({},e,{value:pt}),groupEnd:d({},e,{value:vt})})}pe<0&&l("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Me=V.ReactCurrentDispatcher,Ne;function Ce(e,t,n){{if(Ne===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);Ne=a&&a[1]||""}return`
|
|
30
|
+
`+Ne+e}}var Ve=!1,Se;{var Sr=typeof WeakMap=="function"?WeakMap:Map;Se=new Sr}function yt(e,t){if(!e||Ve)return"";{var n=Se.get(e);if(n!==void 0)return n}var a;Ve=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var c;c=Me.current,Me.current=null,Er();try{if(t){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(j){a=j}Reflect.construct(e,[],s)}else{try{s.call()}catch(j){a=j}e.call(s.prototype)}}else{try{throw Error()}catch(j){a=j}e()}}catch(j){if(j&&a&&typeof j.stack=="string"){for(var f=j.stack.split(`
|
|
31
|
+
`),h=a.stack.split(`
|
|
32
|
+
`),g=f.length-1,C=h.length-1;g>=1&&C>=0&&f[g]!==h[C];)C--;for(;g>=1&&C>=0;g--,C--)if(f[g]!==h[C]){if(g!==1||C!==1)do if(g--,C--,C<0||f[g]!==h[C]){var S=`
|
|
33
|
+
`+f[g].replace(" at new "," at ");return e.displayName&&S.includes("<anonymous>")&&(S=S.replace("<anonymous>",e.displayName)),typeof e=="function"&&Se.set(e,S),S}while(g>=1&&C>=0);break}}}finally{Ve=!1,Me.current=c,Cr(),Error.prepareStackTrace=i}var w=e?e.displayName||e.name:"",T=w?Ce(w):"";return typeof e=="function"&&Se.set(e,T),T}function wr(e,t,n){return yt(e,!1)}function Or(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function we(e,t,n){if(e==null)return"";if(typeof e=="function")return yt(e,Or(e));if(typeof e=="string")return Ce(e);switch(e){case K:return Ce("Suspense");case se:return Ce("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case G:return wr(e.render);case U:return we(e.type,t,n);case Q:{var a=e,i=a._payload,c=a._init;try{return we(c(i),t,n)}catch{}}}return""}var mt={},gt=V.ReactDebugCurrentFrame;function Oe(e){if(e){var t=e._owner,n=we(e.type,e._source,t?t.type:null);gt.setExtraStackFrame(n)}else gt.setExtraStackFrame(null)}function Tr(e,t,n,a,i){{var c=Function.call.bind(fe);for(var s in e)if(c(e,s)){var f=void 0;try{if(typeof e[s]!="function"){var h=Error((a||"React class")+": "+n+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw h.name="Invariant Violation",h}f=e[s](t,s,a,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(g){f=g}f&&!(f instanceof Error)&&(Oe(i),l("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",a||"React class",n,s,typeof f),Oe(null)),f instanceof Error&&!(f.message in mt)&&(mt[f.message]=!0,Oe(i),l("Failed %s type: %s",n,f.message),Oe(null))}}}function ae(e){if(e){var t=e._owner,n=we(e.type,e._source,t?t.type:null);ye(n)}else ye(null)}var Ue;Ue=!1;function _t(){if(x.current){var e=q(x.current.type);if(e)return`
|
|
34
|
+
|
|
35
|
+
Check the render method of \``+e+"`."}return""}function Pr(e){if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return`
|
|
36
|
+
|
|
37
|
+
Check your code at `+t+":"+n+"."}return""}function kr(e){return e!=null?Pr(e.__source):""}var bt={};function jr(e){var t=_t();if(!t){var n=typeof e=="string"?e:e.displayName||e.name;n&&(t=`
|
|
38
|
+
|
|
39
|
+
Check the top-level render call using <`+n+">.")}return t}function Rt(e,t){if(!(!e._store||e._store.validated||e.key!=null)){e._store.validated=!0;var n=jr(t);if(!bt[n]){bt[n]=!0;var a="";e&&e._owner&&e._owner!==x.current&&(a=" It was passed a child from "+q(e._owner.type)+"."),ae(e),l('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,a),ae(null)}}}function Et(e,t){if(typeof e=="object"){if(_e(e))for(var n=0;n<e.length;n++){var a=e[n];ne(a)&&Rt(a,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var i=ee(e);if(typeof i=="function"&&i!==e.entries)for(var c=i.call(e),s;!(s=c.next()).done;)ne(s.value)&&Rt(s.value,t)}}}function Ct(e){{var t=e.type;if(t==null||typeof t=="string")return;var n;if(typeof t=="function")n=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===G||t.$$typeof===U))n=t.propTypes;else return;if(n){var a=q(t);Tr(n,e.props,"prop",a,e)}else if(t.PropTypes!==void 0&&!Ue){Ue=!0;var i=q(t);l("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&l("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ar(e){{for(var t=Object.keys(e.props),n=0;n<t.length;n++){var a=t[n];if(a!=="children"&&a!=="key"){ae(e),l("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),ae(null);break}}e.ref!==null&&(ae(e),l("Invalid attribute `ref` supplied to `React.Fragment`."),ae(null))}}function St(e,t,n){var a=ut(e);if(!a){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var c=kr(t);c?i+=c:i+=_t();var s;e===null?s="null":_e(e)?s="array":e!==void 0&&e.$$typeof===_?(s="<"+(q(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,l("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,i)}var f=Bt.apply(this,arguments);if(f==null)return f;if(a)for(var h=2;h<arguments.length;h++)Et(arguments[h],e);return e===N?Ar(f):Ct(f),f}var wt=!1;function Lr(e){var t=St.bind(null,e);return t.type=e,wt||(wt=!0,H("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.")),Object.defineProperty(t,"type",{enumerable:!1,get:function(){return H("Factory.type is deprecated. Access the class directly before passing it to createFactory."),Object.defineProperty(this,"type",{value:e}),e}}),t}function $r(e,t,n){for(var a=qt.apply(this,arguments),i=2;i<arguments.length;i++)Et(arguments[i],a.type);return Ct(a),a}function Ir(e,t){var n=Y.transition;Y.transition={};var a=Y.transition;Y.transition._updatedFibers=new Set;try{e()}finally{if(Y.transition=n,n===null&&a._updatedFibers){var i=a._updatedFibers.size;i>10&&H("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."),a._updatedFibers.clear()}}}var Ot=!1,Te=null;function Dr(e){if(Te===null)try{var t=("require"+Math.random()).slice(0,7),n=P&&P[t];Te=n.call(P,"timers").setImmediate}catch{Te=function(i){Ot===!1&&(Ot=!0,typeof MessageChannel>"u"&&l("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var c=new MessageChannel;c.port1.onmessage=i,c.port2.postMessage(void 0)}}return Te(e)}var oe=0,Tt=!1;function Fr(e){{var t=oe;oe++,k.current===null&&(k.current=[]);var n=k.isBatchingLegacy,a;try{if(k.isBatchingLegacy=!0,a=e(),!n&&k.didScheduleLegacyUpdate){var i=k.current;i!==null&&(k.didScheduleLegacyUpdate=!1,ze(i))}}catch(w){throw Pe(t),w}finally{k.isBatchingLegacy=n}if(a!==null&&typeof a=="object"&&typeof a.then=="function"){var c=a,s=!1,f={then:function(w,T){s=!0,c.then(function(j){Pe(t),oe===0?We(j,w,T):w(j)},function(j){Pe(t),T(j)})}};return!Tt&&typeof Promise<"u"&&Promise.resolve().then(function(){}).then(function(){s||(Tt=!0,l("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),f}else{var h=a;if(Pe(t),oe===0){var g=k.current;g!==null&&(ze(g),k.current=null);var C={then:function(w,T){k.current===null?(k.current=[],We(h,w,T)):w(h)}};return C}else{var S={then:function(w,T){w(h)}};return S}}}}function Pe(e){e!==oe-1&&l("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),oe=e}function We(e,t,n){{var a=k.current;if(a!==null)try{ze(a),Dr(function(){a.length===0?(k.current=null,t(e)):We(e,t,n)})}catch(i){n(i)}else t(e)}}var Ye=!1;function ze(e){if(!Ye){Ye=!0;var t=0;try{for(;t<e.length;t++){var n=e[t];do n=n(!0);while(n!==null)}e.length=0}catch(a){throw e=e.slice(t+1),a}finally{Ye=!1}}}var xr=St,Mr=$r,Nr=Lr,Vr={map:Ee,forEach:Xt,count:Jt,toArray:Zt,only:er};o.Children=Vr,o.Component=v,o.Fragment=N,o.Profiler=z,o.PureComponent=$,o.StrictMode=F,o.Suspense=K,o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,o.cloneElement=Mr,o.createContext=tr,o.createElement=xr,o.createFactory=Nr,o.createRef=xt,o.forwardRef=or,o.isValidElement=ne,o.lazy=ar,o.memo=ir,o.startTransition=Ir,o.unstable_act=Fr,o.useCallback=vr,o.useContext=ur,o.useDebugValue=mr,o.useDeferredValue=_r,o.useEffect=fr,o.useId=br,o.useImperativeHandle=yr,o.useInsertionEffect=dr,o.useLayoutEffect=pr,o.useMemo=hr,o.useReducer=cr,o.useRef=lr,o.useState=sr,o.useSyncExternalStore=Rr,o.useTransition=gr,o.version=y,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}(ie,ie.exports)),ie.exports}process.env.NODE_ENV==="production"?je.exports=At():je.exports=Lt();var Ae=je.exports;function Ge(P,o=!1){return(y,_=o)=>{if(!P)return y;const L=y.split(".").reduce((N,F)=>N[F],P);if(L===void 0&&_)throw Error(`Translation for ${y} not found`);return L||y}}function $t(P,o,y=!1){return Ge(P,y)(o)}class It extends Ae.Component{constructor(o){super(o),this.state={locale:{}},Promise.all([D.instance.get(this.className()),D.instance.get("Generic")]).then(y=>{const _={...y[0],...y[1]};this.setState({locale:_}),this.onLoadLocale(_)})}onLoadLocale(o){}}function Dt(P){return function(o){return class extends o{constructor(){super(...arguments),this.state={locale:{},...this.state},this.loadLocale=Promise.all([D.instance.get(P),D.instance.get("Generic")]).then(y=>{const _={...y[0],...y[1]};this.setState({locale:_}),this.onLoadLocale&&this.onLoadLocale(_)})}}}}function Ft(P){const[o,y]=Ae.useState({});return Ae.useEffect(()=>{Promise.all([D.instance.get(P),D.instance.get("Generic")]).then(_=>y({..._[0],..._[1]}))},[]),o}M.Locale=D,M.LocalizedComponent=It,M.createSafeLocalizerFor=Ge,M.localize=Dt,M.safeLocalize=$t,M.useLocale=Ft,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entropic-bond/localize-react",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.7.1",
|
|
5
|
+
"description": "Localize react components",
|
|
6
|
+
"main": "lib/entropic-bond-localize-react.umd.cjs",
|
|
7
|
+
"module": "lib/entropic-bond-localize-react.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./lib/entropic-bond-localize-react.js",
|
|
11
|
+
"require": "./lib/entropic-bond-localize-react.umd.cjs",
|
|
12
|
+
"types": "./lib/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "lib/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib"
|
|
18
|
+
],
|
|
4
19
|
"publishConfig": {
|
|
5
20
|
"access": "public",
|
|
6
21
|
"branches": [
|
|
@@ -16,18 +31,10 @@
|
|
|
16
31
|
"@semantic-release/github"
|
|
17
32
|
]
|
|
18
33
|
},
|
|
19
|
-
"description": "Localize react components",
|
|
20
|
-
"main": "lib/index.js",
|
|
21
|
-
"types": "lib/index.d.ts",
|
|
22
|
-
"files": [
|
|
23
|
-
"lib"
|
|
24
|
-
],
|
|
25
34
|
"scripts": {
|
|
26
|
-
"test": "
|
|
27
|
-
"build": "
|
|
28
|
-
"prepare": "npm run build"
|
|
29
|
-
"build-ts": "cp -r ./src/ ./lib",
|
|
30
|
-
"build-cjs": "tsc -p tsconfig-cjs.json"
|
|
35
|
+
"test": "vitest",
|
|
36
|
+
"build": "tsc -p tsconfig-build.json && vite build",
|
|
37
|
+
"prepare": "npm run build"
|
|
31
38
|
},
|
|
32
39
|
"repository": {
|
|
33
40
|
"type": "git",
|
|
@@ -46,22 +53,22 @@
|
|
|
46
53
|
"devDependencies": {
|
|
47
54
|
"@semantic-release/changelog": "^6.0.3",
|
|
48
55
|
"@semantic-release/git": "^10.0.1",
|
|
49
|
-
"@testing-library/jest-dom": "^
|
|
50
|
-
"@testing-library/react": "^14.
|
|
51
|
-
"@testing-library/user-event": "^14.
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/react": "^18.2.
|
|
54
|
-
"@types/react-dom": "^18.2.
|
|
56
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
57
|
+
"@testing-library/react": "^14.2.1",
|
|
58
|
+
"@testing-library/user-event": "^14.5.2",
|
|
59
|
+
"@types/node": "^20.11.16",
|
|
60
|
+
"@types/react": "^18.2.55",
|
|
61
|
+
"@types/react-dom": "^18.2.19",
|
|
55
62
|
"fetch-mock": "^9.11.0",
|
|
56
63
|
"git-branch-is": "^4.0.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"jest-environment-jsdom": "^29.6.1",
|
|
64
|
+
"happy-dom": "^13.3.8",
|
|
65
|
+
"husky": "^9.0.10",
|
|
60
66
|
"react": "^18.2.0",
|
|
61
67
|
"react-dom": "^18.2.0",
|
|
62
|
-
"semantic-release": "^
|
|
63
|
-
"
|
|
64
|
-
"
|
|
68
|
+
"semantic-release": "^23.0.2",
|
|
69
|
+
"typescript": "^5.3.3",
|
|
70
|
+
"vite-plugin-dts": "^3.7.2",
|
|
71
|
+
"vitest": "^1.2.2"
|
|
65
72
|
},
|
|
66
73
|
"husky": {
|
|
67
74
|
"hooks": {
|
package/lib/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./locale"), exports);
|
|
18
|
-
__exportStar(require("./localized-component"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,wDAAqC"}
|
package/lib/locale.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Locale = void 0;
|
|
13
|
-
class Locale {
|
|
14
|
-
constructor(config) {
|
|
15
|
-
this._pendingPromise = undefined;
|
|
16
|
-
this._table = undefined;
|
|
17
|
-
this._table = undefined;
|
|
18
|
-
this._pendingPromise = undefined;
|
|
19
|
-
this._lang = config.locale || 'en';
|
|
20
|
-
this._localePath = config.localePath || '';
|
|
21
|
-
}
|
|
22
|
-
static get instance() {
|
|
23
|
-
if (!this._instance) {
|
|
24
|
-
this._instance = new Locale(this._registeredConfig);
|
|
25
|
-
}
|
|
26
|
-
return this._instance;
|
|
27
|
-
}
|
|
28
|
-
static get currentLocale() {
|
|
29
|
-
return Locale._registeredConfig.locale || Locale.instance._lang;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Returns the plural form of a word
|
|
33
|
-
*
|
|
34
|
-
* @param word to pluralize
|
|
35
|
-
* @param amount if the word to pluralize is a number, the amount is used to determine the plural form
|
|
36
|
-
* @param pluralizer a map of words to their plural form or a function that returns the plural form
|
|
37
|
-
* @returns the plural form of the word
|
|
38
|
-
*/
|
|
39
|
-
pluralize(word, amount = 0, pluralizer) {
|
|
40
|
-
var _a;
|
|
41
|
-
if (amount === 1)
|
|
42
|
-
return word;
|
|
43
|
-
let plural;
|
|
44
|
-
if (typeof pluralizer !== 'function') {
|
|
45
|
-
plural = pluralizer === null || pluralizer === void 0 ? void 0 : pluralizer[word];
|
|
46
|
-
if (plural)
|
|
47
|
-
return plural;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
plural = pluralizer === null || pluralizer === void 0 ? void 0 : pluralizer(word, this._lang);
|
|
51
|
-
}
|
|
52
|
-
let i = 0;
|
|
53
|
-
const rules = Locale._registeredRules[this._lang];
|
|
54
|
-
while (!plural && rules && i < rules.length) {
|
|
55
|
-
plural = (_a = rules[i++]) === null || _a === void 0 ? void 0 : _a.call(rules, word, this._lang);
|
|
56
|
-
}
|
|
57
|
-
return plural !== null && plural !== void 0 ? plural : word;
|
|
58
|
-
}
|
|
59
|
-
static config(config) {
|
|
60
|
-
this._registeredConfig = Object.assign(Object.assign({}, this._registeredConfig), config);
|
|
61
|
-
this._instance = undefined;
|
|
62
|
-
}
|
|
63
|
-
get(component) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
if (!this._table) {
|
|
66
|
-
this._table = yield this.fetchCache(() => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
try {
|
|
68
|
-
return (yield fetch(this.getLocaleFilePath())).json();
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
return (yield fetch(this.getLocaleFilePath('en'))).json();
|
|
72
|
-
}
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
return this._table[component];
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
fetchCache(cachedPromise) {
|
|
79
|
-
if (!this._pendingPromise) {
|
|
80
|
-
this._pendingPromise = new Promise(resolve => resolve(cachedPromise()));
|
|
81
|
-
}
|
|
82
|
-
return this._pendingPromise;
|
|
83
|
-
}
|
|
84
|
-
getLocaleFilePath(locale) {
|
|
85
|
-
if (this._lang.indexOf('http') < 0) {
|
|
86
|
-
return `${this._localePath}/${locale || this._lang}.json`;
|
|
87
|
-
}
|
|
88
|
-
return this._lang;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Registers a rule to pluralize words
|
|
92
|
-
*
|
|
93
|
-
* @param rule a function that returns the plural form of a word
|
|
94
|
-
* @param locale the locale to use the rule
|
|
95
|
-
*/
|
|
96
|
-
static usePluralizerRule(rule, locale) {
|
|
97
|
-
if (!Locale._registeredRules[locale])
|
|
98
|
-
Locale._registeredRules[locale] = [];
|
|
99
|
-
if (Locale._registeredRules[locale].indexOf(rule) >= 0)
|
|
100
|
-
return;
|
|
101
|
-
Locale._registeredRules[locale].unshift(rule);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Registers a rule to pluralize words
|
|
105
|
-
* @deprecated use usePluralizerRule instead
|
|
106
|
-
*/
|
|
107
|
-
static useRule(rule, locale) {
|
|
108
|
-
return Locale.usePluralizerRule(rule, locale);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.Locale = Locale;
|
|
112
|
-
Locale.defaultRules = {
|
|
113
|
-
en: [
|
|
114
|
-
(word) => {
|
|
115
|
-
if (word.slice(-1) === 'f')
|
|
116
|
-
return word.slice(0, -1) + 'ves';
|
|
117
|
-
if (word.slice(-1) === 'o')
|
|
118
|
-
return word.slice(0, -1) + 'oes';
|
|
119
|
-
if (word.slice(-1) === 'x')
|
|
120
|
-
return word.slice(0, -1) + 'xes';
|
|
121
|
-
if (word.slice(-1) === 'h')
|
|
122
|
-
return word.slice(0, -1) + 'hes';
|
|
123
|
-
if (word.slice(-1) === 's')
|
|
124
|
-
return word.slice(0, -1) + 'ses';
|
|
125
|
-
if (word.slice(-1) === 'y')
|
|
126
|
-
return word.slice(0, -1) + 'ies';
|
|
127
|
-
if (word.slice(-1) === 'z')
|
|
128
|
-
return word.slice(0, -1) + 'zes';
|
|
129
|
-
return word + 's';
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
es: [
|
|
133
|
-
(word) => {
|
|
134
|
-
if (word.slice(-1) === 'l')
|
|
135
|
-
return word.slice(0, -1) + 'les';
|
|
136
|
-
if (word.slice(-1) === 'n')
|
|
137
|
-
return word.slice(0, -1) + 'nes';
|
|
138
|
-
if (word.slice(-1) === 'r')
|
|
139
|
-
return word.slice(0, -1) + 'res';
|
|
140
|
-
if (word.slice(-1) === 'z')
|
|
141
|
-
return word.slice(0, -1) + 'ces';
|
|
142
|
-
return word + 's';
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
};
|
|
146
|
-
Locale._instance = undefined;
|
|
147
|
-
Locale._registeredConfig = {};
|
|
148
|
-
Locale._registeredRules = Locale.defaultRules;
|
|
149
|
-
//# sourceMappingURL=locale.js.map
|
package/lib/locale.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,MAAa,MAAM;IAClB,YAAqB,MAAoB;QA0IjC,oBAAe,GAAiC,SAAS,CAAA;QACzD,WAAM,GAAmB,SAAS,CAAA;QA1IzC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;QACvB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAA;QAChC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAA;IAC3C,CAAC;IAEM,MAAM,KAAK,QAAQ;QACzB,IAAK,CAAC,IAAI,CAAC,SAAS,EAAG;YACtB,IAAI,CAAC,SAAS,GAAG,IAAI,MAAM,CAAE,IAAI,CAAC,iBAAiB,CAAE,CAAA;SACrD;QACD,OAAO,IAAI,CAAC,SAAS,CAAA;IACtB,CAAC;I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C,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAE,GAAG,KAAK,CAAA;YAEhE,OAAO,IAAI,GAAG,GAAG,CAAA;QAClB,CAAC;KACD;IACD,EAAE,EAAE;QACH,CAAE,IAAY,EAAG,EAAE;YAClB,IAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAG,OAAO,IAAI,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAE,GAAG,KAAK,CAAA;YAChE,IAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAG,OAAO,IAAI,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAE,GAAG,KAAK,CAAA;YAChE,IAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAG,OAAO,IAAI,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAE,GAAG,KAAK,CAAA;YAChE,IAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAG,OAAO,IAAI,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAE,GAAG,KAAK,CAAA;YAEhE,OAAO,IAAI,GAAG,GAAG,CAAA;QAClB,CAAC;KACD;CACD,AAxB0B,CAwB1B;AAEc,gBAAS,GAAuB,SAAS,AAAhC,CAAgC;AACzC,wBAAiB,GAAiB,EAAkB,AAAnC,CAAmC;AACpD,uBAAgB,GAAkC,MAAM,CAAC,YAAY,AAArD,CAAqD"}
|
package/lib/locale.spec.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const fetch_mock_1 = __importDefault(require("fetch-mock"));
|
|
16
|
-
const locale_1 = require("./locale");
|
|
17
|
-
describe('Locale', () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
locale_1.Locale.config({
|
|
20
|
-
localePath: 'locales'
|
|
21
|
-
});
|
|
22
|
-
fetch_mock_1.default.mock('locales/en.json', () => {
|
|
23
|
-
return {
|
|
24
|
-
"hi": "Hello",
|
|
25
|
-
"moduleA": {
|
|
26
|
-
"bye": "Bye",
|
|
27
|
-
"goodMorning": "Good Morning"
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
fetch_mock_1.default.mock('locales/es.json', () => {
|
|
32
|
-
return {
|
|
33
|
-
"hi": "Hola!!!"
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
afterEach(() => fetch_mock_1.default.restore());
|
|
38
|
-
it('should translate string', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
expect(yield locale_1.Locale.instance.get('hi')).toEqual('Hello');
|
|
40
|
-
}));
|
|
41
|
-
it('should change locale', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
locale_1.Locale.config({ locale: 'es' });
|
|
43
|
-
expect(yield locale_1.Locale.instance.get('hi')).toEqual('Hola!!!');
|
|
44
|
-
}));
|
|
45
|
-
it('should work for named modules', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
locale_1.Locale.config({ locale: 'en' });
|
|
47
|
-
const module = yield locale_1.Locale.instance.get('moduleA');
|
|
48
|
-
expect(module['bye']).toEqual('Bye');
|
|
49
|
-
expect(module['goodMorning']).toEqual('Good Morning');
|
|
50
|
-
}));
|
|
51
|
-
it('should retrieve data only once in successive calls to get (cache calls)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
expect(fetch_mock_1.default.calls().length).toBe(0);
|
|
53
|
-
locale_1.Locale.instance.get('moduleA');
|
|
54
|
-
locale_1.Locale.instance.get('hi');
|
|
55
|
-
locale_1.Locale.instance.get('moduleA')['bye'];
|
|
56
|
-
expect(fetch_mock_1.default.calls('locales/en.json').length).toBe(1);
|
|
57
|
-
}));
|
|
58
|
-
describe('Pluralizer', () => {
|
|
59
|
-
it('should pluralize by default', () => {
|
|
60
|
-
expect(locale_1.Locale.instance.pluralize('apple')).toEqual('apples');
|
|
61
|
-
});
|
|
62
|
-
it('should pluralize exceptions', () => {
|
|
63
|
-
expect(locale_1.Locale.instance.pluralize('mouse', 2, {
|
|
64
|
-
mouse: 'mice',
|
|
65
|
-
foot: 'feet'
|
|
66
|
-
})).toEqual('mice');
|
|
67
|
-
});
|
|
68
|
-
it('should NOT pluralize exceptions with amount 1', () => {
|
|
69
|
-
expect(locale_1.Locale.instance.pluralize('mouse', 1, {
|
|
70
|
-
mouse: 'mice',
|
|
71
|
-
foot: 'feet'
|
|
72
|
-
})).toEqual('mouse');
|
|
73
|
-
});
|
|
74
|
-
it('should not pluralize on amount equal to 1', () => {
|
|
75
|
-
expect(locale_1.Locale.instance.pluralize('apple', 1)).toEqual('apple');
|
|
76
|
-
});
|
|
77
|
-
it('should pluralize on amounts greather than 1', () => {
|
|
78
|
-
expect(locale_1.Locale.instance.pluralize('apple', 2)).toEqual('apples');
|
|
79
|
-
expect(locale_1.Locale.instance.pluralize('apple', 3)).toEqual('apples');
|
|
80
|
-
});
|
|
81
|
-
it('should pluralize on negative amounts', () => {
|
|
82
|
-
expect(locale_1.Locale.instance.pluralize('apple', -1)).toEqual('apples');
|
|
83
|
-
expect(locale_1.Locale.instance.pluralize('apple', -2)).toEqual('apples');
|
|
84
|
-
expect(locale_1.Locale.instance.pluralize('apple', -3)).toEqual('apples');
|
|
85
|
-
});
|
|
86
|
-
it('should pluralize on 0 amount', () => {
|
|
87
|
-
expect(locale_1.Locale.instance.pluralize('apple', 0)).toEqual('apples');
|
|
88
|
-
});
|
|
89
|
-
it('should use provided pluralize function', () => {
|
|
90
|
-
const endsY = (word, locale) => {
|
|
91
|
-
if (locale !== 'en')
|
|
92
|
-
return;
|
|
93
|
-
return word.slice(-1) === 'y' ? word.slice(0, -1) + 'ies' : word;
|
|
94
|
-
};
|
|
95
|
-
expect(locale_1.Locale.instance.pluralize('city', 0, endsY)).toEqual('cities');
|
|
96
|
-
});
|
|
97
|
-
it('should use rules', () => {
|
|
98
|
-
expect(locale_1.Locale.instance.pluralize('city')).toEqual('cities');
|
|
99
|
-
expect(locale_1.Locale.instance.pluralize('class')).toEqual('classes');
|
|
100
|
-
});
|
|
101
|
-
it('should register rules', () => {
|
|
102
|
-
locale_1.Locale.usePluralizerRule(word => word + ' fake', 'en');
|
|
103
|
-
expect(locale_1.Locale.instance.pluralize('something')).toEqual('something fake');
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
//# sourceMappingURL=locale.spec.js.map
|
package/lib/locale.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale.spec.js","sourceRoot":"","sources":["../src/locale.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4DAAkC;AAClC,qCAAiC;AAEjC,QAAQ,CAAE,QAAQ,EAAE,GAAE,EAAE;IACvB,UAAU,CAAC,GAAE,EAAE;QACd,eAAM,CAAC,MAAM,CAAC;YACb,UAAU,EAAE,SAAS;SACrB,CAAC,CAAA;QACF,oBAAS,CAA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MAAM,KAAK,GAAG,CAAE,IAAY,EAAE,MAAc,EAAG,EAAE;gBAChD,IAAK,MAAM,KAAK,IAAI;oBAAG,OAAM;gBAC7B,OAAO,IAAI,CAAC,KAAK,CAAE,CAAC,CAAC,CAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAE,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;YACrE,CAAC,CAAA;YAED,MAAM,CACL,eAAM,CAAC,QAAQ,CAAC,SAAS,CAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAE,CAC7C,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAA;QACtB,CAAC,CAAC,CAAA;QAEF,EAAE,CAAE,kBAAkB,EAAE,GAAE,EAAE;YAC3B,MAAM,CACL,eAAM,CAAC,QAAQ,CAAC,SAAS,CAAE,MAAM,CAAE,CACnC,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAA;YAErB,MAAM,CACL,eAAM,CAAC,QAAQ,CAAC,SAAS,CAAE,OAAO,CAAE,CACpC,CAAC,OAAO,CAAE,SAAS,CAAE,CAAA;QACvB,CAAC,CAAC,CAAA;QAEF,EAAE,CAAE,uBAAuB,EAAE,GAAG,EAAE;YACjC,eAAM,CAAC,iBAAiB,CACvB,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,OAAO,EACtB,IAAI,CACJ,CAAA;YAED,MAAM,CACL,eAAM,CAAC,QAAQ,CAAC,SAAS,CAAE,WAAW,CAAE,CACxC,CAAC,OAAO,CAAE,gBAAgB,CAAE,CAAA;QAE9B,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocale = exports.localize = exports.LocalizedComponent = exports.safeLocalize = exports.createSafeLocalizerFor = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const locale_1 = require("./locale");
|
|
6
|
-
/**
|
|
7
|
-
* Creates a safe localizer function. The function will return the translated
|
|
8
|
-
* value associated to the `keyPath`. If the locale is undefined or the `keyPath` is
|
|
9
|
-
* not found in the locale, the function will return the `keyPath`.
|
|
10
|
-
* @param locale the locale to use
|
|
11
|
-
* @param throwOnKeyNotFound if true, the function will throw an error if the keyPath is not found in the locale
|
|
12
|
-
* @returns a function that will return the translated value associated to the keyPath
|
|
13
|
-
* @throws Error if the keyPath is not found in the locale and throwOnKeyNotFound is true
|
|
14
|
-
* @see safeLocalize
|
|
15
|
-
* @sample
|
|
16
|
-
* ```ts
|
|
17
|
-
* const safeLocalizer = createSafeLocalizerFor( locale ) // returns the localizer function
|
|
18
|
-
* safeLocalizer( 'myComponent.myKey' ) // returns the translated value
|
|
19
|
-
* ```
|
|
20
|
-
* @sample const safeLocalizer = createSafeLocalizerFor( locale, true )
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
function createSafeLocalizerFor(locale, throwOnKeyNotFound = false) {
|
|
24
|
-
return (keyPath, throwOnNotFound = throwOnKeyNotFound) => {
|
|
25
|
-
if (!locale)
|
|
26
|
-
return keyPath;
|
|
27
|
-
const value = keyPath.split('.').reduce((acc, prop) => acc[prop], locale);
|
|
28
|
-
if (value === undefined && throwOnNotFound)
|
|
29
|
-
throw Error(`Translation for ${keyPath} not found`);
|
|
30
|
-
return value || keyPath;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.createSafeLocalizerFor = createSafeLocalizerFor;
|
|
34
|
-
/**
|
|
35
|
-
* Returns the translated value associated to the keyPath. If the locale is
|
|
36
|
-
* undefined or the keyPath is not found in the locale, the function will return
|
|
37
|
-
* the keyPath.
|
|
38
|
-
* @param locale the locale to use
|
|
39
|
-
* @param keyPath the key path to the value to return
|
|
40
|
-
* @param throwOnKeyNotFound if true, the function will throw an error if the keyPath is not found in the locale
|
|
41
|
-
* @returns the translated value associated to the keyPath
|
|
42
|
-
* @throws Error if the keyPath is not found in the locale and throwOnKeyNotFound is true
|
|
43
|
-
* @see createSafeLocalizerFor
|
|
44
|
-
* @sample safeLocalize( locale, 'myComponent.myKey' )
|
|
45
|
-
* @sample safeLocalize( locale, 'myRootKey', true )
|
|
46
|
-
*/
|
|
47
|
-
function safeLocalize(locale, keyPath, throwOnKeyNotFound = false) {
|
|
48
|
-
return createSafeLocalizerFor(locale, throwOnKeyNotFound)(keyPath);
|
|
49
|
-
}
|
|
50
|
-
exports.safeLocalize = safeLocalize;
|
|
51
|
-
/**
|
|
52
|
-
* Derive React components from this class to provide locale capabilities.
|
|
53
|
-
*
|
|
54
|
-
* The locale is a javascript object. The main entries (properties) of object
|
|
55
|
-
* are the names of the components. Every component has its own entry and every
|
|
56
|
-
* subentry is a key-value pair where key is the reference used in the code and
|
|
57
|
-
* the value is the translation to the corresponding idiom.
|
|
58
|
-
*
|
|
59
|
-
* You can use this method or @see localize method to provide localization to your
|
|
60
|
-
* component.
|
|
61
|
-
*/
|
|
62
|
-
class LocalizedComponent extends react_1.Component {
|
|
63
|
-
constructor(props) {
|
|
64
|
-
super(props);
|
|
65
|
-
this.state = { locale: {} };
|
|
66
|
-
Promise.all([
|
|
67
|
-
locale_1.Locale.instance.get(this.className()),
|
|
68
|
-
locale_1.Locale.instance.get('Generic')
|
|
69
|
-
]).then(resp => {
|
|
70
|
-
const locale = Object.assign(Object.assign({}, resp[0]), resp[1]);
|
|
71
|
-
this.setState({ locale });
|
|
72
|
-
this.onLoadLocale(locale);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Override this method to get a notification when the locale has been loaded
|
|
77
|
-
* @param locale the loaded locale
|
|
78
|
-
*/
|
|
79
|
-
onLoadLocale(locale) { }
|
|
80
|
-
}
|
|
81
|
-
exports.LocalizedComponent = LocalizedComponent;
|
|
82
|
-
/**
|
|
83
|
-
* Decorator to inject locale capabilities. The decorator will set the component
|
|
84
|
-
* related locale strings in the locale property created on the component state.
|
|
85
|
-
* To have access to the locale state property, you should pass a state interface
|
|
86
|
-
* derived from LocaleState. @see LocalizedComponent
|
|
87
|
-
*
|
|
88
|
-
* You can use this method or @see LocalizedComponent method to provide
|
|
89
|
-
* localization to your component.
|
|
90
|
-
*
|
|
91
|
-
* @param className the class name to retrieve the locale strings for this class.
|
|
92
|
-
* @returns decorator
|
|
93
|
-
*/
|
|
94
|
-
function localize(className) {
|
|
95
|
-
return function (constructor) {
|
|
96
|
-
return class extends constructor {
|
|
97
|
-
constructor() {
|
|
98
|
-
super(...arguments);
|
|
99
|
-
this.state = Object.assign({ locale: {} }, this['state']);
|
|
100
|
-
this.loadLocale = Promise.all([
|
|
101
|
-
locale_1.Locale.instance.get(className),
|
|
102
|
-
locale_1.Locale.instance.get('Generic')
|
|
103
|
-
]).then(resp => {
|
|
104
|
-
const locale = Object.assign(Object.assign({}, resp[0]), resp[1]);
|
|
105
|
-
this['setState']({ locale });
|
|
106
|
-
this['onLoadLocale'] && this['onLoadLocale'](locale);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
exports.localize = localize;
|
|
113
|
-
/**
|
|
114
|
-
* Hook to add locale capabilities to React functional components. The hook will
|
|
115
|
-
* return an object with the component related locale strings.
|
|
116
|
-
*
|
|
117
|
-
* @param componentName the component name associated to the locale strings.
|
|
118
|
-
* @returns an object with the localized strings
|
|
119
|
-
*/
|
|
120
|
-
function useLocale(componentName) {
|
|
121
|
-
const [locale, setLocale] = (0, react_1.useState)({});
|
|
122
|
-
(0, react_1.useEffect)(() => {
|
|
123
|
-
Promise.all([
|
|
124
|
-
locale_1.Locale.instance.get(componentName),
|
|
125
|
-
locale_1.Locale.instance.get('Generic')
|
|
126
|
-
]).then(resp => setLocale(Object.assign(Object.assign({}, resp[0]), resp[1])));
|
|
127
|
-
}, []);
|
|
128
|
-
return locale;
|
|
129
|
-
}
|
|
130
|
-
exports.useLocale = useLocale;
|
|
131
|
-
//# sourceMappingURL=localized-component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localized-component.js","sourceRoot":"","sources":["../src/localized-component.tsx"],"names":[],"mappings":";;;AAAA,iCAAsD;AACtD,qCAAiC;AAUjC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,sBAAsB,CAAE,MAAiC,EAAE,kBAAkB,GAAG,KAAK;IACpG,OAAO,CAAE,OAAe,EAAE,eAAe,GAAG,kBAAkB,EAAG,EAAE;QAClE,IAAK,CAAC,MAAM;YAAG,OAAO,OAAO,CAAA;QAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAE,GAAO,EAAE,IAAY,EAAG,EAAE,CAAC,GAAG,CAAE,IAAI,CAAE,EAAE,MAAM,CAAE,CAAA;QAC1F,IAAK,KAAK,KAAK,SAAS,IAAI,eAAe;YAAG,MAAM,KAAK,CAAE,mBAAoB,OAAQ,YAAY,CAAE,CAAA;QACrG,OAAO,KAAK,IAAI,OAAO,CAAA;IACxB,CAAC,CAAA;AACF,CAAC;AAPD,wDAOC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,YAAY,CAAE,MAAiC,EAAE,OAAe,EAAE,kBAAkB,GAAG,KAAK;IAC3G,OAAO,sBAAsB,CAAE,MAAM,EAAE,kBAAkB,CAAE,CAAE,OAAO,CAAE,CAAA;AACvE,CAAC;AAFD,oCAEC;AAID;;;;;;;;;;GAUG;AACH,MAAsB,kBAAkE,SAAQ,iBAAe;IAC9G,YAAa,KAAQ;QACpB,KAAK,CAAE,KAAK,CAAE,CAAA;QAEd,IAAI,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,EAAE,EAAO,CAAA;QAEhC,OAAO,CAAC,GAAG,CAAC;YACX,eAAM,CAAC,QAAQ,CAAC,GAAG,CAAE,IAAI,CAAC,SAAS,EAAE,C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