gt-react 9.2.12 → 9.2.14-alpha.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.
@@ -1 +1 @@
1
- import e,{isValidElement as r}from"react";import"generaltranslation";import{jsx as t}from"react/jsx-runtime";const n=e=>`Duplicate key found in dictionary: "${e}"`;function a(e,r=""){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=r?`${r}.${i}`:i;if("object"!=typeof e[i]||null===e[i]||Array.isArray(e[i])){if(t.hasOwnProperty(o))throw new Error(n(o));t[o]=e[i]}else{const r=a(e[i],o);for(const e in r){if(t.hasOwnProperty(e))throw new Error(n(e));t[e]=r[e]}}}return t}function i(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}"function"==typeof SuppressedError&&SuppressedError;var o="en",l=["singular","plural","dual","zero","one","two","few","many","other"];var s=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,r,t){void 0===t&&(t={});var n=Array.isArray(r)?r.join(","):r,a=t?JSON.stringify(t,Object.keys(t).sort()):"{}";return"".concat(e,":").concat(n,":").concat(a)},e.prototype.get=function(e,r,t){void 0===t&&(t={});var n=this._generateKey(e,r,t);if(!this.cache.has(n)){var a=new Intl[e](r,t);this.cache.set(n,a)}return this.cache.get(n)},e}());function c(t,n=0){let a=n;const o=e=>{const{type:r,props:t}=e;a+=1;let n,o={id:a};try{n="function"==typeof r&&r.gtTransformation||""}catch(e){n=""}if(n){const r=n.split("-");if("translate"===r[0])throw new Error((e=>{var r;return`General Translation: Nested <T> components. The inner <T> has the id: "${null===(r=null==e?void 0:e.props)||void 0===r?void 0:r.id}".`})(e));if("variable"===r[0]&&(o.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(t).reduce(((e,[r,t])=>{var n;return n=r,l.includes(n)&&(e[r]=c(t,a)),e}),{});Object.keys(e).length&&(o.branches=e)}if("branch"===r[0]){const e=i(t,["children","branch"]),r=Object.entries(e).reduce(((e,[r,t])=>(e[r]=c(t,a),e)),{});Object.keys(r).length&&(o.branches=r)}o.transformation=r[0]}return o};function s(t){return r(t)?function(r){const{props:t}=r;if(t["data-_gt"])throw new Error((e=>`General Translation already in use on child with props: ${e.props}. This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue.`)(r));let n=o(r),a=Object.assign(Object.assign({},t),{"data-_gt":n});return t.children&&!n.variableType&&(a.children=u(t.children)),r.type===e.Fragment&&(a["data-_gt"].transformation="fragment"),e.cloneElement(r,a)}(t):t}function u(r){return Array.isArray(r)?e.Children.map(r,s):s(r)}return u(t)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e={},r){var t;return`_gt_${u[r]||"value"}_${null===(t=e["data-_gt"])||void 0===t?void 0:t.id}`}const p=e=>{var r;if(!e)return"";const{type:t,props:n}=e;if(t&&"function"==typeof t){if("displayName"in t&&"string"==typeof t.displayName&&t.displayName)return t.displayName;if("name"in t&&"string"==typeof t.name&&t.name)return t.name}return t&&"string"==typeof t?t:n.href?"a":(null===(r=n["data-_gt"])||void 0===r?void 0:r.id)?`C${n["data-_gt"].id}`:"function"},f=r=>{return t=r,e.isValidElement(t)?(e=>{const{type:r,props:t}=e;let n={type:p(e),props:{}};if(t["data-_gt"]){const e=t["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:d(t,r),id:e.id}}if("plural"===a&&e.branches){n.type="Plural";let t={};Object.entries(e.branches).forEach((([e,r])=>{t[e]=b(r)})),r=Object.assign(Object.assign({},r),{branches:t})}if("branch"===a&&e.branches){n.type="Branch";let t={};Object.entries(e.branches).forEach((([e,r])=>{t[e]=b(r)})),r=Object.assign(Object.assign({},r),{branches:t})}n.props["data-_gt"]=r}return t.children&&(n.props.children=b(t.children)),n})(r):"number"==typeof r?r.toString():r;var t};function b(e){return Array.isArray(e)?e.map(f):f(e)}function h(e,r,t){let n="",a=null;return"number"==typeof e&&!a&&t&&(n=function(e,r,t){void 0===r&&(r=l),void 0===t&&(t=["en"]);var n=s.get("PluralRules",t).select(e),a=Math.abs(e);if(0===a&&r.includes("zero"))return"zero";if(1===a){if(r.includes("singular"))return"singular";if(r.includes("one"))return"one"}if("one"===n&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===n&&r.includes("dual")?"dual":r.includes(n)?n:"two"===n&&r.includes("dual")?"dual":"two"===n&&r.includes("plural")?"plural":"two"===n&&r.includes("other")?"other":"few"===n&&r.includes("plural")?"plural":"few"===n&&r.includes("other")?"other":"many"===n&&r.includes("plural")?"plural":"many"===n&&r.includes("other")?"other":"other"===n&&r.includes("plural")?"plural":""}(e,Object.keys(t),r)),n&&!a&&(a=t[n]),a}function y(e){if("string"==typeof e)return!0;if(Array.isArray(e)){if("string"!=typeof(null==e?void 0:e[0]))return!1;const r=null==e?void 0:e[1];if(void 0===r)return!0;if(r&&"object"==typeof r)return!0}return!1}function v(r,t){let n=r,a=t.split(".");for(const r of a){if("object"!=typeof n||Array.isArray(n)||e.isValidElement(n))return;n=n[r]}return n}function g(e){if(Array.isArray(e)){if(1===e.length)return{entry:e[0]};if(2===e.length)return{entry:e[0],metadata:e[1]}}return{entry:e}}function m(e){var r;const t=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableName:d(e,t),variableType:t,variableValue:void 0!==e.value?e.value:void 0!==e["data-_gt-unformatted-value"]?e["data-_gt-unformatted-value"]:void 0!==e.children?e.children:void 0,variableOptions:(()=>{const r=Object.assign(Object.assign({},e.currency&&{currency:e.currency}),e.options&&Object.assign({},e.options));return Object.keys(r).length?r:"string"==typeof e["data-_gt-variable-options"]?JSON.parse(e["data-_gt-variable-options"]):e["data-_gt-variable-options"]||void 0})()}}function O(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.key){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.id)return!0;if("string"==typeof r.variable)return!0}if(3===e.length&&"string"==typeof r.variable&&"number"==typeof r.id)return!0}return!1}function j(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function _({children:r,defaultLocale:t=o,renderVariable:n}){const a=r=>e.isValidElement(r)?(r=>{const a=j(r);if("variable"===(null==a?void 0:a.transformation)){const{variableType:e,variableValue:a,variableOptions:i}=m(r.props);return n({variableType:e,variableValue:a,variableOptions:i,locales:[t]})}if("plural"===(null==a?void 0:a.transformation)){const e=a.branches||{};return l(h(r.props.n,[t],e)||r.props.children)}if("branch"===(null==a?void 0:a.transformation)){let e=r.props,{children:t,name:n,branch:o,"data-_gt":s}=e,c=i(e,["children","name","branch","data-_gt"]);return n=n||r.props["data-_gt-name"]||"branch",c=a.branches||{},l(void 0!==c[o]?c[o]:t)}return"fragment"===(null==a?void 0:a.transformation)?e.createElement(r.type,{key:r.props.key,children:l(r.props.children)}):r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:l(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,l=r=>Array.isArray(r)?e.Children.map(r,a):a(r);return l(r)}function w({sourceElement:r,targetElement:t,locales:n=[o],renderVariable:a}){var i,l;const{props:s}=r,c=s["data-_gt"],u=null==c?void 0:c.transformation;if("plural"===u){const e=r.props.n;return E({source:h(e,n,c.branches||{})||r.props.children,target:h(e,n,t.props["data-_gt"].branches||{})||t.props.children,locales:n,renderVariable:a})}if("branch"===u){let{name:e,branch:i,children:o}=s;e=e||r.props["data-_gt-name"]||"branch";return E({source:(c.branches||{})[i]||o,target:(t.props["data-_gt"].branches||{})[i]||t.props.children,locales:n,renderVariable:a})}return"fragment"===u&&(null===(i=t.props)||void 0===i?void 0:i.children)?e.createElement(r.type,{key:r.props.key,children:E({source:s.children,target:t.props.children,locales:n,renderVariable:a})}):(null==s?void 0:s.children)&&(null===(l=t.props)||void 0===l?void 0:l.children)?e.cloneElement(r,Object.assign(Object.assign({},s),{"data-_gt":void 0,children:E({source:s.children,target:t.props.children,locales:n,renderVariable:a})})):_({children:r,defaultLocale:n[0],renderVariable:a})}function E({source:r,target:n,locales:a=[o],renderVariable:i}){if(null==n&&r)return _({children:r,defaultLocale:a[0],renderVariable:i});if("string"==typeof n)return n;if(Array.isArray(n)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(n)){const o={},l={},s=r.filter((r=>{if(e.isValidElement(r)){const e=j(r);if("variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:t,variableOptions:n}=m(r.props);o[e]=t,l[e]=n}}})),c=e=>s.find((r=>{var t,n;const a=j(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(n=null===(t=null==e?void 0:e.props)||void 0===t?void 0:t["data-_gt"])||void 0===n?void 0:n.id)}return!1}))||s.shift();return n.map(((r,n)=>{if("string"==typeof r)return t(e.Fragment,{children:r},`string_${n}`);if(O(r))return t(e.Fragment,{children:i({variableType:r.variable||"variable",variableValue:o[r.key],variableOptions:l[r.key],locales:a})},`var_${n}`);const s=c(r);return s?t(e.Fragment,{children:w({sourceElement:s,targetElement:r,locales:a,renderVariable:i})},`element_${n}`):void 0}))}if(n&&"object"==typeof n&&!Array.isArray(n)){const t=O(n)?"variable":"element";if(e.isValidElement(r)){if("element"===t)return w({sourceElement:r,targetElement:n,locales:a,renderVariable:i});const e=j(r);if("variable"===(null==e?void 0:e.transformation)){const{variableValue:e,variableOptions:t,variableType:n}=m(r.props);return i({variableType:n,variableValue:e,variableOptions:t,locales:a})}}}return _({children:r,defaultLocale:a[0],renderVariable:i})}const A={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};function V(){return""}class T extends Error{constructor(e,r){super(e),this.error=e,this.code=r,this.code=r}toTranslationError(){return{state:"error",error:this.error,code:this.code}}}export{T as GTTranslationError,c as addGTIdentifier,A as defaultRenderSettings,a as flattenDictionary,v as getDictionaryEntry,g as getEntryAndMetadata,h as getPluralBranch,d as getVariableName,m as getVariableProps,y as isValidDictionaryEntry,O as isVariableObject,_ as renderDefaultChildren,V as renderSkeleton,E as renderTranslatedChildren,b as writeChildrenAsObjects};
1
+ import e,{isValidElement as r}from"react";import"generaltranslation";import{jsx as n}from"react/jsx-runtime";const t=e=>`Duplicate key found in dictionary: "${e}"`;function a(e,r=""){const n={};for(const i in e)if(e.hasOwnProperty(i)){const o=r?`${r}.${i}`:i;if("object"!=typeof e[i]||null===e[i]||Array.isArray(e[i])){if(n.hasOwnProperty(o))throw new Error(t(o));n[o]=e[i]}else{const r=a(e[i],o);for(const e in r){if(n.hasOwnProperty(e))throw new Error(t(e));n[e]=r[e]}}}return n}function i(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}"function"==typeof SuppressedError&&SuppressedError;var o="en",l=["singular","plural","dual","zero","one","two","few","many","other"];var s=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,r,n){void 0===n&&(n={});var t=Array.isArray(r)?r.join(","):r,a=n?JSON.stringify(n,Object.keys(n).sort()):"{}";return"".concat(e,":").concat(t,":").concat(a)},e.prototype.get=function(e,r,n){void 0===n&&(n={});var t=this._generateKey(e,r,n);if(!this.cache.has(t)){var a=new Intl[e](r,n);this.cache.set(t,a)}return this.cache.get(t)},e}());function c(n,t=0){let a=t;const o=e=>{const{type:r,props:n}=e;a+=1;let t,o={id:a};try{t="function"==typeof r&&r.gtTransformation||""}catch(e){t=""}if(t){const r=t.split("-");if("translate"===r[0])throw new Error((e=>{var r;return`General Translation: Nested <T> components. The inner <T> has the id: "${null===(r=null==e?void 0:e.props)||void 0===r?void 0:r.id}".`})(e));if("variable"===r[0]&&(o.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(n).reduce(((e,[r,n])=>{var t;return t=r,l.includes(t)&&(e[r]=c(n,a)),e}),{});Object.keys(e).length&&(o.branches=e)}if("branch"===r[0]){const e=i(n,["children","branch"]),r=Object.entries(e).reduce(((e,[r,n])=>(e[r]=c(n,a),e)),{});Object.keys(r).length&&(o.branches=r)}o.transformation=r[0]}return o};function s(n){return r(n)?function(r){const{props:n}=r;if(n["data-_gt"])throw new Error((e=>`General Translation already in use on child with props: ${e.props}. This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue.`)(r));let t=o(r),a=Object.assign(Object.assign({},n),{"data-_gt":t});return n.children&&!t.variableType&&(a.children=u(n.children)),r.type===e.Fragment&&(a["data-_gt"].transformation="fragment"),e.cloneElement(r,a)}(n):n}function u(r){return Array.isArray(r)?e.Children.map(r,s):s(r)}return u(n)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e={},r){var n;if(e.name)return e.name;return`_gt_${u[r]||"value"}_${null===(n=e["data-_gt"])||void 0===n?void 0:n.id}`}const p=e=>{var r;if(!e)return"";const{type:n,props:t}=e;if(n&&"function"==typeof n){if("displayName"in n&&"string"==typeof n.displayName&&n.displayName)return n.displayName;if("name"in n&&"string"==typeof n.name&&n.name)return n.name}return n&&"string"==typeof n?n:t.href?"a":(null===(r=t["data-_gt"])||void 0===r?void 0:r.id)?`C${t["data-_gt"].id}`:"function"},f=r=>{return n=r,e.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:p(e),props:{}};if(n["data-_gt"]){const e=n["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:d(n,r),id:e.id}}if("plural"===a&&e.branches){t.type="Plural";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=b(r)})),r=Object.assign(Object.assign({},r),{branches:n})}if("branch"===a&&e.branches){t.type="Branch";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=b(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=b(n.children)),t})(r):"number"==typeof r?r.toString():r;var n};function b(e){return Array.isArray(e)?e.map(f):f(e)}function h(e,r,n){let t="",a=null;return"number"==typeof e&&!a&&n&&(t=function(e,r,n){void 0===r&&(r=l),void 0===n&&(n=["en"]);var t=s.get("PluralRules",n).select(e),a=Math.abs(e);if(0===a&&r.includes("zero"))return"zero";if(1===a){if(r.includes("singular"))return"singular";if(r.includes("one"))return"one"}if("one"===t&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===t&&r.includes("dual")?"dual":r.includes(t)?t:"two"===t&&r.includes("dual")?"dual":"two"===t&&r.includes("plural")?"plural":"two"===t&&r.includes("other")?"other":"few"===t&&r.includes("plural")?"plural":"few"===t&&r.includes("other")?"other":"many"===t&&r.includes("plural")?"plural":"many"===t&&r.includes("other")?"other":"other"===t&&r.includes("plural")?"plural":""}(e,Object.keys(n),r)),t&&!a&&(a=n[t]),a}function y(e){if("string"==typeof e)return!0;if(Array.isArray(e)){if("string"!=typeof(null==e?void 0:e[0]))return!1;const r=null==e?void 0:e[1];if(void 0===r)return!0;if(r&&"object"==typeof r)return!0}return!1}function v(r,n){let t=r,a=n.split(".");for(const r of a){if("object"!=typeof t||Array.isArray(t)||e.isValidElement(t))return;t=t[r]}return t}function g(e){if(Array.isArray(e)){if(1===e.length)return{entry:e[0]};if(2===e.length)return{entry:e[0],metadata:e[1]}}return{entry:e}}function m(e){var r;const n=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableName:d(e,n),variableType:n,variableValue:void 0!==e.value?e.value:void 0!==e["data-_gt-unformatted-value"]?e["data-_gt-unformatted-value"]:void 0!==e.children?e.children:void 0,variableOptions:(()=>{const r=Object.assign(Object.assign({},e.currency&&{currency:e.currency}),e.options&&Object.assign({},e.options));return Object.keys(r).length?r:"string"==typeof e["data-_gt-variable-options"]?JSON.parse(e["data-_gt-variable-options"]):e["data-_gt-variable-options"]||void 0})()}}function O(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.key){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.id)return!0;if("string"==typeof r.variable)return!0}if(3===e.length&&"string"==typeof r.variable&&"number"==typeof r.id)return!0}return!1}function j(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function _({children:r,defaultLocale:n=o,renderVariable:t}){const a=r=>e.isValidElement(r)?(r=>{const a=j(r);if("variable"===(null==a?void 0:a.transformation)){const{variableType:e,variableValue:a,variableOptions:i}=m(r.props);return t({variableType:e,variableValue:a,variableOptions:i,locales:[n]})}if("plural"===(null==a?void 0:a.transformation)){const e=a.branches||{};return l(h(r.props.n,[n],e)||r.props.children)}if("branch"===(null==a?void 0:a.transformation)){let e=r.props,{children:n,name:t,branch:o,"data-_gt":s}=e,c=i(e,["children","name","branch","data-_gt"]);return t=t||r.props["data-_gt-name"]||"branch",c=a.branches||{},l(void 0!==c[o]?c[o]:n)}return"fragment"===(null==a?void 0:a.transformation)?e.createElement(r.type,{key:r.props.key,children:l(r.props.children)}):r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:l(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,l=r=>Array.isArray(r)?e.Children.map(r,a):a(r);return l(r)}function w({sourceElement:r,targetElement:n,locales:t=[o],renderVariable:a}){var i,l;const{props:s}=r,c=s["data-_gt"],u=null==c?void 0:c.transformation;if("plural"===u){const e=r.props.n;return E({source:h(e,t,c.branches||{})||r.props.children,target:h(e,t,n.props["data-_gt"].branches||{})||n.props.children,locales:t,renderVariable:a})}if("branch"===u){let{name:e,branch:i,children:o}=s;e=e||r.props["data-_gt-name"]||"branch";return E({source:(c.branches||{})[i]||o,target:(n.props["data-_gt"].branches||{})[i]||n.props.children,locales:t,renderVariable:a})}return"fragment"===u&&(null===(i=n.props)||void 0===i?void 0:i.children)?e.createElement(r.type,{key:r.props.key,children:E({source:s.children,target:n.props.children,locales:t,renderVariable:a})}):(null==s?void 0:s.children)&&(null===(l=n.props)||void 0===l?void 0:l.children)?e.cloneElement(r,Object.assign(Object.assign({},s),{"data-_gt":void 0,children:E({source:s.children,target:n.props.children,locales:t,renderVariable:a})})):_({children:r,defaultLocale:t[0],renderVariable:a})}function E({source:r,target:t,locales:a=[o],renderVariable:i}){if(null==t&&r)return _({children:r,defaultLocale:a[0],renderVariable:i});if("string"==typeof t)return t;if(Array.isArray(t)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(t)){const o={},l={},s=r.filter((r=>{if(e.isValidElement(r)){const e=j(r);if("variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:n,variableOptions:t}=m(r.props);o[e]=n,l[e]=t}}})),c=e=>s.find((r=>{var n,t;const a=j(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(t=null===(n=null==e?void 0:e.props)||void 0===n?void 0:n["data-_gt"])||void 0===t?void 0:t.id)}return!1}))||s.shift();return t.map(((r,t)=>{if("string"==typeof r)return n(e.Fragment,{children:r},`string_${t}`);if(O(r))return n(e.Fragment,{children:i({variableType:r.variable||"variable",variableValue:o[r.key],variableOptions:l[r.key],locales:a})},`var_${t}`);const s=c(r);return s?n(e.Fragment,{children:w({sourceElement:s,targetElement:r,locales:a,renderVariable:i})},`element_${t}`):void 0}))}if(t&&"object"==typeof t&&!Array.isArray(t)){const n=O(t)?"variable":"element";if(e.isValidElement(r)){if("element"===n)return w({sourceElement:r,targetElement:t,locales:a,renderVariable:i});const e=j(r);if("variable"===(null==e?void 0:e.transformation)){const{variableValue:e,variableOptions:n,variableType:t}=m(r.props);return i({variableType:t,variableValue:e,variableOptions:n,locales:a})}}}return _({children:r,defaultLocale:a[0],renderVariable:i})}const A={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};function V(){return""}class T extends Error{constructor(e,r){super(e),this.error=e,this.code=r,this.code=r}toTranslationError(){return{state:"error",error:this.error,code:this.code}}}export{T as GTTranslationError,c as addGTIdentifier,A as defaultRenderSettings,a as flattenDictionary,v as getDictionaryEntry,g as getEntryAndMetadata,h as getPluralBranch,d as getVariableName,m as getVariableProps,y as isValidDictionaryEntry,O as isVariableObject,_ as renderDefaultChildren,V as renderSkeleton,E as renderTranslatedChildren,b as writeChildrenAsObjects};
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
2
  import { ClientProviderProps } from '../types/providers';
3
3
  export default function ClientProvider({ children, dictionary, initialTranslations, dictionaryTranslations, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, renderSettings, projectId, devApiKey, runtimeUrl, runtimeTranslationEnabled, onLocaleChange, cookieName, }: ClientProviderProps): React.JSX.Element;
4
4
  //# sourceMappingURL=ClientProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmC,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,sBAAsB,EACtB,MAAM,EAAE,OAAO,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,OAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,yBAAyB,EACzB,cAAyB,EACzB,UAA6B,GAC9B,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA0HzC"}
1
+ {"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,sBAAsB,EACtB,MAAM,EAAE,OAAO,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,OAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,yBAAyB,EACzB,cAAyB,EACzB,UAA6B,GAC9B,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA8HzC"}
@@ -1,5 +1,5 @@
1
- import { CustomLoader, RenderMethod } from '../types/types';
2
1
  import React from 'react';
2
+ import { CustomLoader, RenderMethod } from '../types/types';
3
3
  /**
4
4
  * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
5
5
  *
@@ -19,7 +19,7 @@ import React from 'react';
19
19
  *
20
20
  * @returns {JSX.Element} The provider component for General Translation context.
21
21
  */
22
- export default function GTProvider({ children, projectId: _projectId, devApiKey: _devApiKey, dictionary: _dictionary, locales, defaultLocale, locale: _locale, cacheUrl, runtimeUrl, renderSettings, loadDictionary, loadTranslations, fallback, _versionId, ...metadata }: {
22
+ export default function GTProvider({ children, projectId: _projectId, devApiKey: _devApiKey, dictionary: _dictionary, locales, defaultLocale, locale: _locale, cacheUrl, runtimeUrl, renderSettings, loadDictionary, loadTranslations, fallback, ssr, _versionId, ...metadata }: {
23
23
  children?: React.ReactNode;
24
24
  projectId?: string;
25
25
  devApiKey?: string;
@@ -36,6 +36,7 @@ export default function GTProvider({ children, projectId: _projectId, devApiKey:
36
36
  loadDictionary?: CustomLoader;
37
37
  loadTranslations?: CustomLoader;
38
38
  _versionId?: string;
39
+ ssr?: boolean;
39
40
  [key: string]: any;
40
41
  }): React.JSX.Element;
41
42
  //# sourceMappingURL=GTProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,YAAY,EAGZ,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAkBxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,SAAS,EAAE,UAAe,EAC1B,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,WAAW,EACvB,OAAY,EACZ,aAAoC,EACpC,MAAM,EAAE,OAAO,EACf,QAA0B,EAC1B,UAAiC,EACjC,cAAsC,EACtC,cAAc,EACd,gBAAgB,EAChB,QAAoB,EACpB,UAAU,EACV,GAAG,QAAQ,EACZ,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE;QACf,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA0XpB"}
1
+ {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,EACL,YAAY,EAGZ,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAyBxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,SAAS,EAAE,UAAe,EAC1B,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,WAAW,EACvB,OAAY,EACZ,aAAoC,EACpC,MAAM,EAAE,OAAO,EACf,QAA0B,EAC1B,UAAiC,EACjC,cAAsC,EACtC,cAAc,EACd,gBAAgB,EAChB,QAAoB,EACpB,GAAoB,EACpB,UAAU,EACV,GAAG,QAAQ,EACZ,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE;QACf,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2XpB"}
@@ -0,0 +1,2 @@
1
+ export declare function isSSREnabled(): boolean;
2
+ //# sourceMappingURL=isSSREnabled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSSREnabled.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/isSSREnabled.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,YAa3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderVariable.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderVariable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAA,MAAM,cAAc,EAAE,cA0BrB,CAAC;AACF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"renderVariable.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderVariable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAA,MAAM,cAAc,EAAE,cAarB,CAAC;AACF,eAAe,cAAc,CAAC"}
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  * ```jsx
7
7
  * // Basic usage:
8
8
  * <T id="welcome_message">
9
- * Hello, <Var name="name" value={firstname}>!
9
+ * Hello, <Var>{name}</Var>!
10
10
  * </T>
11
11
  * ```
12
12
  *
@@ -14,8 +14,8 @@ import React from 'react';
14
14
  * ```jsx
15
15
  * // Translating a plural
16
16
  * <T id="item_count">
17
- * <Plural n={3} singular={<>You have <Num value={n}/> item.</>}>
18
- * You have <Num value={n}/> items.
17
+ * <Plural n={3} singular={<>You have <Num children={n}/> item.</>}>
18
+ * You have <Num children={n}/> items.
19
19
  * </Plural>
20
20
  * </T>
21
21
  * ```
@@ -16,9 +16,10 @@ import React from 'react';
16
16
  * @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
17
17
  * @returns {JSX.Element} The formatted currency component.
18
18
  */
19
- declare function Currency({ children, currency, locales, options, }: {
19
+ declare function Currency({ children, currency, name, locales, options, }: {
20
20
  children?: any;
21
21
  currency?: string;
22
+ name?: string;
22
23
  locales?: string[];
23
24
  options?: Intl.NumberFormatOptions;
24
25
  }): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Currency.d.ts","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACpC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAsBpB;kBAhCQ,QAAQ;;;AAqCjB,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Currency.d.ts","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,QAAgB,EAChB,IAAI,EACJ,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACpC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAqBpB;kBAjCQ,QAAQ;;;AAsCjB,eAAe,QAAQ,CAAC"}
@@ -16,9 +16,10 @@ import React from 'react';
16
16
  * @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
17
17
  * @returns {JSX.Element} The formatted date or time component.
18
18
  */
19
- declare function DateTime({ children, locales, options, }: {
19
+ declare function DateTime({ children, locales, name, options, }: {
20
20
  children?: any;
21
21
  locales?: string[];
22
+ name?: string;
22
23
  options?: Intl.DateTimeFormatOptions;
23
24
  }): React.JSX.Element;
24
25
  declare namespace DateTime {
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACtC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA6BpB;kBArCQ,QAAQ;;;AA0CjB,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,QAAQ,CAAC,EAChB,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACtC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA6BpB;kBAvCQ,QAAQ;;;AA4CjB,eAAe,QAAQ,CAAC"}
@@ -17,10 +17,11 @@ import React from 'react';
17
17
  * @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
18
18
  * @returns {JSX.Element} The formatted number component.
19
19
  */
20
- declare function Num({ children, locales, options, }: {
20
+ declare function Num({ children, name, locales, options, }: {
21
21
  children?: any;
22
22
  locales?: string[];
23
23
  options?: Intl.NumberFormatOptions;
24
+ name?: string;
24
25
  }): React.JSX.Element;
25
26
  declare namespace Num {
26
27
  var gtTransformation: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,GAAG,CAAC,EACX,QAAQ,EACR,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACpC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAkBpB;kBA1BQ,GAAG;;;AA8BZ,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,GAAG,CAAC,EACX,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,OAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAkBpB;kBA5BQ,GAAG;;;AAgCZ,eAAe,GAAG,CAAC"}
@@ -21,8 +21,9 @@ import React from 'react';
21
21
  * @param {any} [children] - The content to render inside the component. If provided, it will take precedence over `value`.
22
22
  * @returns {JSX.Element} The rendered variable component with either `children` or `value`.
23
23
  */
24
- declare function Var({ children }: {
24
+ declare function Var({ children, name, }: {
25
25
  children?: any;
26
+ name?: string;
26
27
  }): React.JSX.Element;
27
28
  declare namespace Var {
28
29
  var gtTransformation: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAEhE;kBAFQ,GAAG;;;AAMZ,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,GAAG,CAAC,EACX,QAAQ,EACR,IAAI,GACL,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAEpB;kBARQ,GAAG;;;AAYZ,eAAe,GAAG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getVariableName.d.ts","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EAC/B,YAAY,EAAE,MAAM,GACnB,MAAM,CAIR"}
1
+ {"version":3,"file":"getVariableName.d.ts","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EAC/B,YAAY,EAAE,MAAM,GACnB,MAAM,CAKR"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "gt-react",
3
- "version": "9.2.12",
3
+ "version": "9.2.14-alpha.1",
4
4
  "description": "A React library for automatic internationalization.",
5
5
  "main": "./dist/index.cjs.min.cjs",
6
6
  "module": "./dist/index.esm.min.mjs",
7
7
  "types": "./dist/index.d.ts",
8
8
  "peerDependencies": {
9
- "react": ">=16.8.0 <20.0.0",
10
- "react-dom": ">=16.8.0 <20.0.0"
9
+ "react": ">=16.8.0",
10
+ "react-dom": ">=16.8.0"
11
11
  },
12
12
  "dependencies": {
13
13
  "@generaltranslation/supported-locales": "^2.0.7",
@@ -29,5 +29,5 @@ export default {
29
29
  postcss(), // Process CSS files
30
30
  preserveDirectives(), // Preserve directives in the output (i.e., "use client")
31
31
  ],
32
- external: ['generaltranslation', '@generaltranslation/supported-locales'],
33
- };
32
+ external: ['react', 'react-dom', 'generaltranslation', '@generaltranslation/supported-locales'],
33
+ };