solid-intlayer 6.1.6 → 7.0.0-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/IntlayerProvider.cjs +1 -1
- package/dist/cjs/client/getBrowserLocale.cjs +1 -1
- package/dist/cjs/client/index.cjs +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -0
- package/dist/cjs/client/useTraduction.cjs +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -1
- package/dist/cjs/editor/contexts/CommunicatorContext.cjs +1 -1
- package/dist/cjs/editor/contexts/EditedContentContext.cjs +1 -1
- package/dist/cjs/editor/contexts/useCrossFrameMessageListener.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/cjs/solidElement/renderSolidElement.cjs +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +9 -9
- package/dist/esm/client/getBrowserLocale.mjs +80 -84
- package/dist/esm/client/index.mjs +21 -18
- package/dist/esm/client/useDictionaryAsync.mjs +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
- package/dist/esm/client/useLocale.mjs +19 -13
- package/dist/esm/client/useLocaleStorage.mjs +25 -0
- package/dist/esm/client/useTraduction.mjs +10 -6
- package/dist/esm/editor/ContentSelectorWrapper.mjs +2 -2
- package/dist/esm/editor/contexts/CommunicatorContext.mjs +10 -10
- package/dist/esm/editor/contexts/EditedContentContext.mjs +92 -83
- package/dist/esm/editor/contexts/useCrossFrameMessageListener.mjs +8 -8
- package/dist/esm/getDictionary.mjs +1 -5
- package/dist/esm/index.mjs +26 -23
- package/dist/esm/plugins.mjs +25 -24
- package/dist/esm/solidElement/renderSolidElement.mjs +1 -1
- package/dist/types/IntlayerNode.d.ts +0 -1
- package/dist/types/UI/ContentSelector.d.ts +0 -1
- package/dist/types/client/IntlayerProvider.d.ts +3 -2
- package/dist/types/client/getBrowserLocale.d.ts +16 -12
- package/dist/types/client/index.d.ts +2 -3
- package/dist/types/client/t.d.ts +2 -4
- package/dist/types/client/useContent.d.ts +4 -5
- package/dist/types/client/useDictionary.d.ts +4 -4
- package/dist/types/client/useDictionaryAsync.d.ts +2 -4
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -4
- package/dist/types/client/useIntlayer.d.ts +3 -5
- package/dist/types/client/useLoadDynamic.d.ts +0 -1
- package/dist/types/client/useLocale.d.ts +9 -8
- package/dist/types/client/useLocaleBase.d.ts +9 -7
- package/dist/types/client/useLocaleStorage.d.ts +39 -0
- package/dist/types/client/useTraduction.d.ts +2 -3
- package/dist/types/editor/ContentSelectorWrapper.d.ts +0 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts +0 -1
- package/dist/types/editor/contexts/CommunicatorContext.d.ts +0 -1
- package/dist/types/editor/contexts/ConfigurationContext.d.ts +1 -2
- package/dist/types/editor/contexts/DictionariesRecordContext.d.ts +1 -2
- package/dist/types/editor/contexts/EditedContentContext.d.ts +3 -4
- package/dist/types/editor/contexts/EditorEnabledContext.d.ts +0 -1
- package/dist/types/editor/contexts/EditorProvider.d.ts +0 -1
- package/dist/types/editor/contexts/FocusDictionaryContext.d.ts +1 -2
- package/dist/types/editor/contexts/index.d.ts +0 -1
- package/dist/types/editor/contexts/useCrossFrameMessageListener.d.ts +1 -2
- package/dist/types/editor/contexts/useCrossFrameState.d.ts +0 -1
- package/dist/types/editor/contexts/useCrossURLPathState.d.ts +0 -1
- package/dist/types/editor/contexts/useIframeClickInterceptor.d.ts +0 -1
- package/dist/types/editor/index.d.ts +0 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts +2 -4
- package/dist/types/getDictionary.d.ts +3 -4
- package/dist/types/getIntlayer.d.ts +3 -4
- package/dist/types/index.d.ts +3 -4
- package/dist/types/markdown/MarkdownProvider.d.ts +1 -2
- package/dist/types/markdown/MarkdownRenderer.d.ts +1 -3
- package/dist/types/markdown/index.d.ts +0 -1
- package/dist/types/plugins.d.ts +3 -3
- package/dist/types/solidElement/renderSolidElement.d.ts +0 -1
- package/package.json +44 -46
- package/LICENSE +0 -202
- package/dist/cjs/client/useLocaleCookie.cjs +0 -1
- package/dist/esm/client/useLocaleCookie.mjs +0 -19
- package/dist/types/IntlayerNode.d.ts.map +0 -1
- package/dist/types/UI/ContentSelector.d.ts.map +0 -1
- package/dist/types/client/IntlayerProvider.d.ts.map +0 -1
- package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/t.d.ts.map +0 -1
- package/dist/types/client/useContent.d.ts.map +0 -1
- package/dist/types/client/useDictionary.d.ts.map +0 -1
- package/dist/types/client/useDictionaryAsync.d.ts.map +0 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +0 -1
- package/dist/types/client/useIntlayer.d.ts.map +0 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +0 -1
- package/dist/types/client/useLocale.d.ts.map +0 -1
- package/dist/types/client/useLocaleBase.d.ts.map +0 -1
- package/dist/types/client/useLocaleCookie.d.ts +0 -17
- package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
- package/dist/types/client/useTraduction.d.ts.map +0 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +0 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +0 -1
- package/dist/types/editor/contexts/CommunicatorContext.d.ts.map +0 -1
- package/dist/types/editor/contexts/ConfigurationContext.d.ts.map +0 -1
- package/dist/types/editor/contexts/DictionariesRecordContext.d.ts.map +0 -1
- package/dist/types/editor/contexts/EditedContentContext.d.ts.map +0 -1
- package/dist/types/editor/contexts/EditorEnabledContext.d.ts.map +0 -1
- package/dist/types/editor/contexts/EditorProvider.d.ts.map +0 -1
- package/dist/types/editor/contexts/FocusDictionaryContext.d.ts.map +0 -1
- package/dist/types/editor/contexts/index.d.ts.map +0 -1
- package/dist/types/editor/contexts/useCrossFrameMessageListener.d.ts.map +0 -1
- package/dist/types/editor/contexts/useCrossFrameState.d.ts.map +0 -1
- package/dist/types/editor/contexts/useCrossURLPathState.d.ts.map +0 -1
- package/dist/types/editor/contexts/useIframeClickInterceptor.d.ts.map +0 -1
- package/dist/types/editor/index.d.ts.map +0 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +0 -1
- package/dist/types/getDictionary.d.ts.map +0 -1
- package/dist/types/getIntlayer.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/markdown/MarkdownProvider.d.ts.map +0 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +0 -1
- package/dist/types/markdown/index.d.ts.map +0 -1
- package/dist/types/plugins.d.ts.map +0 -1
- package/dist/types/solidElement/renderSolidElement.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@intlayer/config/built"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@intlayer/config/built"),v=require("@intlayer/core"),o=require("solid-js"),I=require("../editor/IntlayerEditorProvider.cjs"),r=require("./useLocaleStorage.cjs"),a=o.createContext({locale:()=>r.localeCookie??d?.internationalization?.defaultLocale,setLocale:()=>null,disableEditor:!1}),b=()=>o.useContext(a),u=t=>{const{internationalization:f}=d??{},{defaultLocale:C,locales:l}=f??{},L=t.locale??r.localeCookie??t.defaultLocale??C,[n,i]=o.createSignal(L);o.createEffect(()=>{if(typeof window<"u"){const e=c=>{if(c.data?.type==="INTLAYER_LOCALE_CHANGE"){const s=c.data.locale;l?.includes(s)&&i(s)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}}),o.createEffect(()=>{const e=n();typeof window<"u"&&window.postMessage({type:"INTLAYER_LOCALE_CHANGE",locale:e},"*")});const g=e=>{if(n().toString()!==e.toString()){if(!l?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}i(e),r.setLocaleInStorage(e,t.isCookieEnabled)}},y=t.setLocale??g,E=()=>v.localeResolver(t.locale??n());return o.createComponent(a.Provider,{get value(){return{locale:E,setLocale:y,disableEditor:t.disableEditor}},get children(){return t.children}})},m=t=>o.createComponent(I.IntlayerEditorProvider,{get children(){return o.createComponent(u,t)}});exports.IntlayerClientContext=a;exports.IntlayerProvider=m;exports.IntlayerProviderContent=u;exports.useIntlayerContext=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@intlayer/config/built"),s=require("@intlayer/core"),y=require("@intlayer/types");var d=(e=>(e.Querystring="querystring",e.Storage="storage",e.Navigator="navigator",e.HtmlTag="htmlTag",e))(d||{});const v=()=>({order:["querystring","storage","navigator","htmlTag"],lookupQuerystring:"locale",htmlTag:typeof document<"u"?document.documentElement:null}),h=(e,a)=>{const r={},f={querystring:()=>{if(typeof window>"u")return;const t=window.location.search||"",n=new URLSearchParams(t).get(a.lookupQuerystring??"");n&&(r.querystring=n)},storage:()=>{if(typeof window>"u")return;const t=s.getLocaleFromStorage({getCookie:o=>{try{const n=document.cookie.split(";"),i=`${o}=`,u=n.find(m=>m.trim().startsWith(i));if(u)return u.split("=")[1].trim()}catch{}},getSessionStorage:o=>{try{return window.sessionStorage.getItem(o)??void 0}catch{}},getLocaleStorage:o=>{try{return window.localStorage.getItem(o)??void 0}catch{}}});t&&(r.storage=t)},navigator:()=>{if(typeof navigator>"u")return;const{internationalization:t}=l,o=navigator.languages??[navigator.language],n=s.localeDetector({"accept-language":o.join(",")},t.locales,t.defaultLocale);n&&(r.navigator=n)},htmlTag:()=>{const t=a.htmlTag;if(t&&typeof t.getAttribute=="function"){const o=t.getAttribute("lang");if(o){const{internationalization:n}=l,i=s.localeDetector({"accept-language":o},n.locales,n.defaultLocale);r.htmlTag=i}}}};return e.forEach(t=>{f[t]?.()}),r},p=(e,a)=>{const{internationalization:r}=l;for(const g of a){const c=e[g];if(c&&r.locales.includes(c))return c}return r?.defaultLocale??y.Locales.ENGLISH},w=(e={})=>{const a={...v(),...e},r=h(a.order??[],a);return p(r,a.order??[])};exports.LanguageDetector=d;exports.getBrowserLocale=w;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./getBrowserLocale.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./getBrowserLocale.cjs"),o=require("./IntlayerProvider.cjs"),r=require("./t.cjs"),n=require("./useDictionary.cjs"),a=require("./useDictionaryAsync.cjs"),c=require("./useDictionaryDynamic.cjs"),i=require("./useIntlayer.cjs"),l=require("./useLoadDynamic.cjs"),s=require("./useLocale.cjs"),u=require("./useLocaleBase.cjs"),e=require("./useLocaleStorage.cjs");exports.getBrowserLocale=t.getBrowserLocale;exports.IntlayerClientContext=o.IntlayerClientContext;exports.IntlayerProvider=o.IntlayerProvider;exports.IntlayerProviderContent=o.IntlayerProviderContent;exports.useIntlayerContext=o.useIntlayerContext;exports.t=r.t;exports.useDictionary=n.useDictionary;exports.useDictionaryAsync=a.useDictionaryAsync;exports.useDictionaryDynamic=c.useDictionaryDynamic;exports.useIntlayer=i.useIntlayer;exports.useLoadDynamic=l.useLoadDynamic;exports.useLocale=s.useLocale;exports.useLocaleBase=u.useLocaleBase;exports.localeCookie=e.localeCookie;exports.localeInStorage=e.localeInStorage;exports.setLocaleCookie=e.setLocaleCookie;exports.setLocaleInStorage=e.setLocaleInStorage;exports.useLocaleCookie=e.useLocaleCookie;exports.useLocaleStorage=e.useLocaleStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@intlayer/config/built"),a=require("solid-js"),s=require("./IntlayerProvider.cjs"),l=require("./useDictionary.cjs"),u=async(t,n)=>{const{locale:o}=a.useContext(s.IntlayerClientContext),i=r?.internationalization.defaultLocale,e=n??o()??i,c=await t[e]();return l.useDictionary(c,e)};exports.useDictionaryAsync=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@intlayer/config/built"),a=require("solid-js"),s=require("./IntlayerProvider.cjs"),l=require("./useDictionary.cjs"),u=async(t,n)=>{const{locale:o}=a.useContext(s.IntlayerClientContext),i=r?.internationalization.defaultLocale,e=n??o()??i,c=await t[e]?.();return l.useDictionary(c,e)};exports.useDictionaryAsync=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@intlayer/config/built"),s=require("solid-js"),l=require("./IntlayerProvider.cjs"),u=require("./useDictionary.cjs"),y=require("./useLoadDynamic.cjs"),d=(t,n,i)=>{const{locale:o}=s.useContext(l.IntlayerClientContext),c=a?.internationalization.defaultLocale,e=i??o()??c,r=y.useLoadDynamic(`${String(n)}.${e}`,t[e]());return u.useDictionary(r,e)};exports.useDictionaryDynamic=d;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@intlayer/config/built"),s=require("solid-js"),l=require("./IntlayerProvider.cjs"),u=require("./useDictionary.cjs"),y=require("./useLoadDynamic.cjs"),d=(t,n,i)=>{const{locale:o}=s.useContext(l.IntlayerClientContext)??{},c=a?.internationalization.defaultLocale,e=i??o?.()??c,r=y.useLoadDynamic(`${String(n)}.${e}`,t[e]?.());return u.useDictionary(r,e)};exports.useDictionaryDynamic=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@intlayer/config/built"),n=require("solid-js"),s=require("./IntlayerProvider.cjs"),u=require("./useLocaleStorage.cjs"),L=({isCookieEnabled:c,onLocaleChange:o}={})=>{const{defaultLocale:l,locales:r}=i?.internationalization??{},t=n.useContext(s.IntlayerClientContext),a=e=>{if(!r?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}t?.setLocale(e),u.setLocaleInStorage(e,c??t?.isCookieEnabled??!0),o?.(e)};return n.createEffect(()=>{if(o&&t?.locale){const e=t.locale();o(e)}}),{locale:t?.locale,defaultLocale:l,availableLocales:r,setLocale:a}};exports.useLocale=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@intlayer/core"),s=require("solid-js"),a=e.getLocaleFromStorage(e.localeStorageOptions),r=a,c=(o,t)=>e.setLocaleInStorage(o,{...e.localeStorageOptions,isCookieEnabled:t}),n=c,l=o=>s.createMemo(()=>e.LocaleStorage({...e.localeStorageOptions,isCookieEnabled:o})),g=o=>{const t=l(o);return{localeCookie:t().getLocale(),setLocaleCookie:t().setLocale}};exports.localeCookie=r;exports.localeInStorage=a;exports.setLocaleCookie=n;exports.setLocaleInStorage=c;exports.useLocaleCookie=g;exports.useLocaleStorage=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@intlayer/core"),r=require("solid-js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@intlayer/config/built"),o=require("@intlayer/core"),r=require("solid-js"),i=require("./IntlayerProvider.cjs"),a=e=>{const{locale:t}=r.useContext(i.IntlayerClientContext)??{};return o.getTranslation(e,t?.()??n?.internationalization.defaultLocale)};exports.useTranslation=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@intlayer/core"),r=require("solid-js");require("@intlayer/config/built");require("@intlayer/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@intlayer/core"),r=require("solid-js");require("@intlayer/config/built");require("@intlayer/types");const u=require("../client/IntlayerProvider.cjs");require("@intlayer/editor");require("./contexts/ConfigurationContext.cjs");require("./contexts/DictionariesRecordContext.cjs");require("./contexts/EditedContentContext.cjs");const s=require("./contexts/EditorEnabledContext.cjs");require("./contexts/CommunicatorContext.cjs");const d=require("./contexts/FocusDictionaryContext.cjs");require("../markdown/MarkdownProvider.cjs");require("../client/useLocaleStorage.cjs");require("../client/useLocaleBase.cjs");const a=require("../UI/ContentSelector.cjs"),l=e=>{const{focusedContent:t,setFocusedContent:n}=d.useFocusDictionary(),o=()=>n({dictionaryKey:e.dictionaryKey,keyPath:e.keyPath}),i=r.createMemo(()=>(t?.dictionaryKey===e.dictionaryKey&&(t?.keyPath?.length??0)>0&&c.isSameKeyPath(t?.keyPath??[],e.keyPath))??!1);return r.createComponent(a.ContentSelector,{onPress:o,get isSelecting(){return i()},get children(){return e.children}})},y=e=>{const{enabled:t}=s.useEditorEnabled(),{disableEditor:n}=u.useIntlayerContext();return t()&&!n?r.createComponent(l,r.mergeProps(e,{get children(){return e.children}})):e.children};exports.ContentSelectorRenderer=y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@intlayer/config/built"),o=require("solid-js"),c=()=>"xxxx-xxxx-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@intlayer/config/built"),o=require("solid-js"),c=()=>"xxxx-xxxx-xxxx-yxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),{editor:r}=i,s=o.createContext({postMessage:()=>null,allowedOrigins:[r?.applicationURL,r?.editorURL,r?.cmsURL],senderId:""}),a=e=>{const t=c(),n=o.createMemo(()=>({postMessage:e.postMessage,allowedOrigins:e.allowedOrigins,senderId:t}));return o.createComponent(s.Provider,{get value(){return n()},get children(){return e.children}})},u=()=>o.useContext(s);exports.CommunicatorProvider=a;exports.useCommunicator=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@intlayer/core"),f=require("@intlayer/editor"),l=require("solid-js"),G=require("./DictionariesRecordContext.cjs"),_=require("./useCrossFrameMessageListener.cjs"),R=require("./useCrossFrameState.cjs"),m=l.createContext(void 0),$=u=>_.useCrossFrameMessageListener(`${f.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/post`,u),j=u=>_.useCrossFrameMessageListener(`${f.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED}/get`,u),x=l.createContext(void 0),k=u=>{const{localeDictionaries:C}=G.useDictionariesRecord(),[D,c]=R.useCrossFrameState(f.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED),P=t=>{if(typeof t=="function")c(n=>{const e=n?.[Object.keys(n||{})[0]],s=t(e);return{...n,[s.key]:s}});else{const n=t;c(e=>({...e,[n.key]:n}))}},S=(t,n)=>{c(e=>({...e,[t]:{...e?.[t],content:n}}))},y=(t,n,e=[],s=!0)=>{c(d=>{const o=C[t]?.content,i=structuredClone(d?.[t]?.content??o);let r=e;if(!s){let N=0;const w=e.slice(0,-1),g=e[e.length-1];let h=g.key;for(;typeof E.getContentNodeByKeyPath(i,r)<"u";)N++,h=N===0?g.key:`${g.key} (${N})`,r=[...w,{...g,key:h}]}const a=E.editDictionaryByKeyPath(i,r,n);return{...d,[t]:{...d?.[t],content:a}}})},A=(t,n,e=[])=>{c(s=>{const d=C[t]?.content,o=structuredClone(s?.[t]?.content??d),i=E.renameContentNodeByKeyPath(o,n,e);return{...s,[t]:{...s?.[t],content:i}}})},F=(t,n)=>{c(e=>{const s=C[t]?.content,d=structuredClone(e?.[t]?.content??s),o=structuredClone(d),i=n.slice(0,-1),r=n[n.length-1]?.key;if(r){const a=E.getContentNodeByKeyPath(o,i);a&&typeof a=="object"&&r in a&&delete a[r]}return{...e,[t]:{...e?.[t],content:o}}})},I=t=>{c(n=>{const e={...n};return delete e[t],e})},L=t=>{c(n=>({...n,[t]:{...n?.[t],content:{}}}))},M=()=>{c({})},b=(t,n)=>{const e=D();if(!e)return;if(t.includes(":local:")||t.includes(":remote:")){const o=e?.[t]?.content??{};return E.getContentNodeByKeyPath(o,n)}const d=Object.keys(e).filter(o=>o.startsWith(`${t}:`));for(const o of d){const i=e?.[o]?.content??{},r=E.getContentNodeByKeyPath(i,n);if(r)return r}},q={editedContent:D()},B={setEditedContentState:c,setEditedDictionary:P,setEditedContent:S,addEditedContent:y,renameEditedContent:A,removeEditedContent:F,restoreEditedContent:I,clearEditedDictionaryContent:L,clearEditedContent:M,getEditedContentValue:b};return l.createComponent(m.Provider,{value:q,get children(){return l.createComponent(x.Provider,{value:B,get children(){return u.children}})}})},T=()=>l.useContext(x),v=()=>{const u=T(),C=l.useContext(m);if(!C)throw new Error("useEditedContent must be used within a EditedContentProvider");return{...C,...u}};exports.EditedContentProvider=k;exports.useEditedContent=v;exports.useEditedContentActions=T;exports.useGetEditedContentState=j;exports.usePostEditedContentState=$;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@intlayer/editor"),a=require("solid-js"),l=require("./CommunicatorContext.cjs"),M=(r,o
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@intlayer/editor"),a=require("solid-js"),l=require("./CommunicatorContext.cjs"),M=(r,o)=>{const t=l.useCommunicator();if(!t)throw new Error("useCrossFrameMessageListener must be used within a CommunicatorProvider");const{allowedOrigins:s,postMessage:d,senderId:n}=t;return a.onMount(()=>{if(o){const e=i=>{const{type:u,data:c,senderId:m}=i.data;u===r&&m!==n&&(typeof s>"u"||s?.some(p=>g.compareUrls(p,i.origin))||s?.includes("*"))&&o(c)};window.addEventListener("message",e),a.onCleanup(()=>window.removeEventListener("message",e))}}),e=>{d({type:r,data:e,senderId:n})}};exports.useCrossFrameMessageListener=M;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./client/getBrowserLocale.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./client/getBrowserLocale.cjs"),r=require("./client/IntlayerProvider.cjs"),t=require("./client/t.cjs"),i=require("./client/useDictionary.cjs"),n=require("./client/useDictionaryAsync.cjs"),a=require("./client/useDictionaryDynamic.cjs"),c=require("./client/useIntlayer.cjs"),s=require("./client/useLoadDynamic.cjs"),l=require("./client/useLocale.cjs"),u=require("./client/useLocaleBase.cjs"),e=require("./client/useLocaleStorage.cjs"),y=require("./markdown/MarkdownProvider.cjs");require("@intlayer/core");require("@intlayer/editor");require("./editor/contexts/ConfigurationContext.cjs");require("./editor/contexts/DictionariesRecordContext.cjs");require("./editor/contexts/EditedContentContext.cjs");require("./editor/contexts/EditorEnabledContext.cjs");require("solid-js");require("./editor/contexts/CommunicatorContext.cjs");require("./editor/contexts/FocusDictionaryContext.cjs");exports.getBrowserLocale=o.getBrowserLocale;exports.IntlayerClientContext=r.IntlayerClientContext;exports.IntlayerProvider=r.IntlayerProvider;exports.IntlayerProviderContent=r.IntlayerProviderContent;exports.useIntlayerContext=r.useIntlayerContext;exports.t=t.t;exports.useDictionary=i.useDictionary;exports.useDictionaryAsync=n.useDictionaryAsync;exports.useDictionaryDynamic=a.useDictionaryDynamic;exports.useIntlayer=c.useIntlayer;exports.useLoadDynamic=s.useLoadDynamic;exports.useLocale=l.useLocale;exports.useLocaleBase=u.useLocaleBase;exports.localeCookie=e.localeCookie;exports.localeInStorage=e.localeInStorage;exports.setLocaleCookie=e.setLocaleCookie;exports.setLocaleInStorage=e.setLocaleInStorage;exports.useLocaleCookie=e.useLocaleCookie;exports.useLocaleStorage=e.useLocaleStorage;exports.MarkdownProvider=y.MarkdownProvider;
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@intlayer/core"),l=require("@intlayer/types"),i=require("./editor/ContentSelectorWrapper.cjs"),P=require("./editor/useEditedContentRenderer.cjs"),a=require("./IntlayerNode.cjs");require("./markdown/MarkdownProvider.cjs");const c=require("./markdown/MarkdownRenderer.cjs"),h=require("./solidElement/renderSolidElement.cjs"),n=require("solid-js"),k={id:"intlayer-node-plugin",canHandle:e=>typeof e=="bigint"||typeof e=="string"||typeof e=="number",transform:(e,{plugins:t,...r})=>a.renderIntlayerNode({...r,value:r.children,children:n.createComponent(i.ContentSelectorRenderer,n.mergeProps(r,{get children(){return n.createComponent(P.EditedContentRenderer,n.mergeProps(r,{get children(){return r.children}}))}}))})},f={id:"solid-node-plugin",canHandle:e=>typeof e=="object"&&typeof e.props<"u",transform:(e,{plugins:t,...r})=>a.renderIntlayerNode({...r,value:"[[solid-element]]",children:n.createComponent(i.ContentSelectorRenderer,n.mergeProps(r,{get children(){return h.renderSolidElement(e)}}))})},g={id:"markdown-string-plugin",canHandle:e=>typeof e=="string",transform:(e,t,r)=>{const{plugins:u,...o}=t,p=y.getMarkdownMetadata(e),m=r(p,{plugins:[{id:"markdown-metadata-plugin",canHandle:d=>typeof d=="string"||typeof d=="number"||typeof d=="boolean"||!d,transform:(d,s)=>a.renderIntlayerNode({...s,value:d,children:n.createComponent(i.ContentSelectorRenderer,n.mergeProps(o,{get children(){return n.createComponent(c.MarkdownMetadataRenderer,n.mergeProps(o,{get metadataKeyPath(){return s.keyPath},children:e}))}}))})}],dictionaryKey:o.dictionaryKey,keyPath:[]});return a.renderIntlayerNode({...t,value:e,children:n.createComponent(i.ContentSelectorRenderer,n.mergeProps(o,{get children(){return n.createComponent(c.MarkdownRenderer,n.mergeProps(o,{children:e}))}})),additionalProps:{metadata:m}})}},w={id:"markdown-plugin",canHandle:e=>typeof e=="object"&&e?.nodeType===l.NodeType.Markdown,transform:(e,t,r)=>{const u=[...t.keyPath,{type:l.NodeType.Markdown}],o=e[l.NodeType.Markdown];return r(o,{...t,children:o,keyPath:u,plugins:[g,...t.plugins??[]]})}},C={translation:!0,enumeration:!0,condition:!0,insertion:!0,nested:!0,solidNode:!0,intlayerNode:!0,markdown:!0};exports.interpreterPluginsEnabledState=C;exports.intlayerNodePlugins=k;exports.markdownPlugin=w;exports.markdownStringPlugin=g;exports.solidNodePlugins=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../web-Ch-xTpJg.js"),c=o=>{if(typeof o=="string")return o;const i=(r=>{if(r?.props&&typeof r.props.children=="object"){const p=[],{children:s}=r.props;return Object.keys(s??{}).forEach(e=>{p.push(c(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../web-Ch-xTpJg.js"),c=o=>{if(typeof o=="string")return o;const i=(r=>{if(r?.props&&typeof r.props.children=="object"){const p=[],{children:s}=r.props;return Object.keys(s??{}).forEach(e=>{p.push(c(s?.[e]))}),{...r,props:{...r.props,children:p}}}return{...r,props:{...r.props,children:r.props?.children??[]}}})(o),{type:t,props:n}=i;return d.Dynamic({component:t??"span",...n,children:n.children})};exports.renderSolidElement=c;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import s from "@intlayer/config/built";
|
|
2
2
|
import { localeResolver as v } from "@intlayer/core";
|
|
3
|
-
import { createContext as y, createComponent as n, useContext as
|
|
4
|
-
import { IntlayerEditorProvider as
|
|
5
|
-
import { localeCookie as d,
|
|
3
|
+
import { createContext as y, createComponent as n, useContext as I, createSignal as w, createEffect as c } from "solid-js";
|
|
4
|
+
import { IntlayerEditorProvider as b } from "../editor/IntlayerEditorProvider.mjs";
|
|
5
|
+
import { localeCookie as d, setLocaleInStorage as A } from "./useLocaleStorage.mjs";
|
|
6
6
|
const f = y({
|
|
7
7
|
locale: () => d ?? s?.internationalization?.defaultLocale,
|
|
8
8
|
setLocale: () => null,
|
|
9
9
|
disableEditor: !1
|
|
10
|
-
}),
|
|
10
|
+
}), R = () => I(f), x = (t) => {
|
|
11
11
|
const {
|
|
12
12
|
internationalization: u
|
|
13
13
|
} = s ?? {}, {
|
|
14
14
|
defaultLocale: L,
|
|
15
15
|
locales: a
|
|
16
|
-
} = u ?? {}, m = t.locale ?? d ?? t.defaultLocale ?? L, [o, l] =
|
|
16
|
+
} = u ?? {}, m = t.locale ?? d ?? t.defaultLocale ?? L, [o, l] = w(m);
|
|
17
17
|
c(() => {
|
|
18
18
|
if (typeof window < "u") {
|
|
19
19
|
const e = (r) => {
|
|
@@ -37,7 +37,7 @@ const f = y({
|
|
|
37
37
|
console.error(`Locale ${e} is not available`);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
l(e),
|
|
40
|
+
l(e), A(e, t.isCookieEnabled);
|
|
41
41
|
}
|
|
42
42
|
}, g = t.setLocale ?? C, E = () => v(t.locale ?? o());
|
|
43
43
|
return n(f.Provider, {
|
|
@@ -52,14 +52,14 @@ const f = y({
|
|
|
52
52
|
return t.children;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
},
|
|
55
|
+
}, k = (t) => n(b, {
|
|
56
56
|
get children() {
|
|
57
57
|
return n(x, t);
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
export {
|
|
61
61
|
f as IntlayerClientContext,
|
|
62
|
-
|
|
62
|
+
k as IntlayerProvider,
|
|
63
63
|
x as IntlayerProviderContent,
|
|
64
|
-
|
|
64
|
+
R as useIntlayerContext
|
|
65
65
|
};
|
|
@@ -1,99 +1,95 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
lookupCookie: t?.cookieName,
|
|
18
|
-
htmlTag: document.documentElement
|
|
19
|
-
};
|
|
20
|
-
}, S = () => {
|
|
21
|
-
try {
|
|
22
|
-
if (typeof window > "u") return !1;
|
|
23
|
-
const t = "intlayer.translate.boo";
|
|
24
|
-
return window.localStorage.setItem(t, "foo"), window.localStorage.removeItem(t), !0;
|
|
25
|
-
} catch {
|
|
26
|
-
return !1;
|
|
27
|
-
}
|
|
28
|
-
}, w = () => {
|
|
29
|
-
try {
|
|
30
|
-
if (typeof window > "u") return !1;
|
|
31
|
-
const t = "intlayer.translate.boo";
|
|
32
|
-
return window.sessionStorage.setItem(t, "foo"), window.sessionStorage.removeItem(t), !0;
|
|
33
|
-
} catch {
|
|
34
|
-
return !1;
|
|
35
|
-
}
|
|
36
|
-
}, y = (t, r) => {
|
|
37
|
-
const e = {}, u = {
|
|
1
|
+
import s from "@intlayer/config/built";
|
|
2
|
+
import { localeDetector as u, getLocaleFromStorage as m } from "@intlayer/core";
|
|
3
|
+
import { Locales as p } from "@intlayer/types";
|
|
4
|
+
var v = /* @__PURE__ */ ((e) => (e.Querystring = "querystring", e.Storage = "storage", e.Navigator = "navigator", e.HtmlTag = "htmlTag", e))(v || {});
|
|
5
|
+
const h = () => ({
|
|
6
|
+
order: [
|
|
7
|
+
"querystring",
|
|
8
|
+
"storage",
|
|
9
|
+
"navigator",
|
|
10
|
+
"htmlTag"
|
|
11
|
+
/* HtmlTag */
|
|
12
|
+
],
|
|
13
|
+
lookupQuerystring: "locale",
|
|
14
|
+
htmlTag: typeof document < "u" ? document.documentElement : null
|
|
15
|
+
}), y = (e, a) => {
|
|
16
|
+
const r = {}, d = {
|
|
38
17
|
querystring: () => {
|
|
39
18
|
if (typeof window > "u") return;
|
|
40
|
-
const
|
|
41
|
-
|
|
19
|
+
const t = window.location.search || "", n = new URLSearchParams(t).get(a.lookupQuerystring ?? "");
|
|
20
|
+
n && (r.querystring = n);
|
|
42
21
|
},
|
|
43
|
-
|
|
44
|
-
if (typeof
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
22
|
+
storage: () => {
|
|
23
|
+
if (typeof window > "u") return;
|
|
24
|
+
const t = m({
|
|
25
|
+
getCookie: (o) => {
|
|
26
|
+
try {
|
|
27
|
+
const n = document.cookie.split(";"), i = `${o}=`, g = n.find((f) => f.trim().startsWith(i));
|
|
28
|
+
if (g)
|
|
29
|
+
return g.split("=")[1].trim();
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
getSessionStorage: (o) => {
|
|
34
|
+
try {
|
|
35
|
+
return window.sessionStorage.getItem(o) ?? void 0;
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
getLocaleStorage: (o) => {
|
|
40
|
+
try {
|
|
41
|
+
return window.localStorage.getItem(o) ?? void 0;
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
t && (r.storage = t);
|
|
60
47
|
},
|
|
61
48
|
navigator: () => {
|
|
62
|
-
typeof navigator > "u"
|
|
49
|
+
if (typeof navigator > "u") return;
|
|
50
|
+
const {
|
|
51
|
+
internationalization: t
|
|
52
|
+
} = s, o = navigator.languages ?? [navigator.language], n = u({
|
|
53
|
+
"accept-language": o.join(",")
|
|
54
|
+
}, t.locales, t.defaultLocale);
|
|
55
|
+
n && (r.navigator = n);
|
|
63
56
|
},
|
|
64
57
|
htmlTag: () => {
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
|
|
58
|
+
const t = a.htmlTag;
|
|
59
|
+
if (t && typeof t.getAttribute == "function") {
|
|
60
|
+
const o = t.getAttribute("lang");
|
|
61
|
+
if (o) {
|
|
62
|
+
const {
|
|
63
|
+
internationalization: n
|
|
64
|
+
} = s, i = u({
|
|
65
|
+
"accept-language": o
|
|
66
|
+
}, n.locales, n.defaultLocale);
|
|
67
|
+
r.htmlTag = i;
|
|
68
|
+
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
}),
|
|
75
|
-
},
|
|
72
|
+
return e.forEach((t) => {
|
|
73
|
+
d[t]?.();
|
|
74
|
+
}), r;
|
|
75
|
+
}, w = (e, a) => {
|
|
76
76
|
const {
|
|
77
|
-
internationalization:
|
|
78
|
-
} =
|
|
79
|
-
for (const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return n;
|
|
84
|
-
if (n?.includes("-") && (e?.locales).includes(n.split("-")[0]))
|
|
85
|
-
return n.split("-")[0];
|
|
86
|
-
}
|
|
77
|
+
internationalization: r
|
|
78
|
+
} = s;
|
|
79
|
+
for (const l of a) {
|
|
80
|
+
const c = e[l];
|
|
81
|
+
if (c && r.locales.includes(c))
|
|
82
|
+
return c;
|
|
87
83
|
}
|
|
88
|
-
return
|
|
89
|
-
},
|
|
90
|
-
const
|
|
91
|
-
...
|
|
92
|
-
...
|
|
93
|
-
},
|
|
94
|
-
return
|
|
84
|
+
return r?.defaultLocale ?? p.ENGLISH;
|
|
85
|
+
}, q = (e = {}) => {
|
|
86
|
+
const a = {
|
|
87
|
+
...h(),
|
|
88
|
+
...e
|
|
89
|
+
}, r = y(a.order ?? [], a);
|
|
90
|
+
return w(r, a.order ?? []);
|
|
95
91
|
};
|
|
96
92
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
v as LanguageDetector,
|
|
94
|
+
q as getBrowserLocale
|
|
99
95
|
};
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { getBrowserLocale as r } from "./getBrowserLocale.mjs";
|
|
2
|
-
import { IntlayerClientContext as a, IntlayerProvider as n, IntlayerProviderContent as
|
|
3
|
-
import { t as
|
|
4
|
-
import { useDictionary as
|
|
2
|
+
import { IntlayerClientContext as a, IntlayerProvider as n, IntlayerProviderContent as l, useIntlayerContext as c } from "./IntlayerProvider.mjs";
|
|
3
|
+
import { t as i } from "./t.mjs";
|
|
4
|
+
import { useDictionary as x } from "./useDictionary.mjs";
|
|
5
5
|
import { useDictionaryAsync as p } from "./useDictionaryAsync.mjs";
|
|
6
6
|
import { useDictionaryDynamic as u } from "./useDictionaryDynamic.mjs";
|
|
7
|
-
import { useIntlayer as
|
|
8
|
-
import { useLoadDynamic as
|
|
9
|
-
import { useLocale as
|
|
10
|
-
import { useLocaleBase as
|
|
11
|
-
import { localeCookie as
|
|
7
|
+
import { useIntlayer as C } from "./useIntlayer.mjs";
|
|
8
|
+
import { useLoadDynamic as D } from "./useLoadDynamic.mjs";
|
|
9
|
+
import { useLocale as d } from "./useLocale.mjs";
|
|
10
|
+
import { useLocaleBase as S } from "./useLocaleBase.mjs";
|
|
11
|
+
import { localeCookie as B, localeInStorage as P, setLocaleCookie as w, setLocaleInStorage as A, useLocaleCookie as b, useLocaleStorage as h } from "./useLocaleStorage.mjs";
|
|
12
12
|
export {
|
|
13
13
|
a as IntlayerClientContext,
|
|
14
14
|
n as IntlayerProvider,
|
|
15
|
-
|
|
15
|
+
l as IntlayerProviderContent,
|
|
16
16
|
r as getBrowserLocale,
|
|
17
|
-
|
|
17
|
+
B as localeCookie,
|
|
18
|
+
P as localeInStorage,
|
|
18
19
|
w as setLocaleCookie,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
A as setLocaleInStorage,
|
|
21
|
+
i as t,
|
|
22
|
+
x as useDictionary,
|
|
21
23
|
p as useDictionaryAsync,
|
|
22
24
|
u as useDictionaryDynamic,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
C as useIntlayer,
|
|
26
|
+
c as useIntlayerContext,
|
|
27
|
+
D as useLoadDynamic,
|
|
28
|
+
d as useLocale,
|
|
29
|
+
S as useLocaleBase,
|
|
30
|
+
b as useLocaleCookie,
|
|
31
|
+
h as useLocaleStorage
|
|
29
32
|
};
|
|
@@ -3,7 +3,7 @@ import { useContext as c } from "solid-js";
|
|
|
3
3
|
import { IntlayerClientContext as l } from "./IntlayerProvider.mjs";
|
|
4
4
|
import { useDictionary as s } from "./useDictionary.mjs";
|
|
5
5
|
const p = async (o, n) => {
|
|
6
|
-
const { locale: r } = c(l), a = i?.internationalization.defaultLocale, t = n ?? r() ?? a, e = await o[t]();
|
|
6
|
+
const { locale: r } = c(l), a = i?.internationalization.defaultLocale, t = n ?? r() ?? a, e = await o[t]?.();
|
|
7
7
|
return s(e, t);
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
@@ -4,9 +4,9 @@ import { IntlayerClientContext as m } from "./IntlayerProvider.mjs";
|
|
|
4
4
|
import { useDictionary as s } from "./useDictionary.mjs";
|
|
5
5
|
import { useLoadDynamic as u } from "./useLoadDynamic.mjs";
|
|
6
6
|
const L = (t, n, r) => {
|
|
7
|
-
const { locale: i } = l(m), e = c?.internationalization.defaultLocale, o = r ?? i() ?? e, a = u(
|
|
7
|
+
const { locale: i } = l(m) ?? {}, e = c?.internationalization.defaultLocale, o = r ?? i?.() ?? e, a = u(
|
|
8
8
|
`${String(n)}.${o}`,
|
|
9
|
-
t[o]()
|
|
9
|
+
t[o]?.()
|
|
10
10
|
);
|
|
11
11
|
return s(a, o);
|
|
12
12
|
};
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from "@intlayer/config/built";
|
|
2
2
|
import { useContext as l, createEffect as s } from "solid-js";
|
|
3
3
|
import { IntlayerClientContext as f } from "./IntlayerProvider.mjs";
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { setLocaleInStorage as m } from "./useLocaleStorage.mjs";
|
|
5
|
+
const b = ({
|
|
6
|
+
isCookieEnabled: a,
|
|
7
|
+
onLocaleChange: o
|
|
8
|
+
} = {}) => {
|
|
9
|
+
const { defaultLocale: n, locales: r } = c?.internationalization ?? {}, e = l(f), i = (t) => {
|
|
10
|
+
if (!r?.map(String).includes(t)) {
|
|
11
|
+
console.error(`Locale ${t} is not available`);
|
|
9
12
|
return;
|
|
10
13
|
}
|
|
11
|
-
|
|
14
|
+
e?.setLocale(t), m(
|
|
15
|
+
t,
|
|
16
|
+
a ?? e?.isCookieEnabled ?? !0
|
|
17
|
+
), o?.(t);
|
|
12
18
|
};
|
|
13
19
|
return s(() => {
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
|
|
20
|
+
if (o && e?.locale) {
|
|
21
|
+
const t = e.locale();
|
|
22
|
+
o(t);
|
|
17
23
|
}
|
|
18
24
|
}), {
|
|
19
|
-
locale:
|
|
25
|
+
locale: e?.locale,
|
|
20
26
|
// Current locale (signal accessor)
|
|
21
|
-
defaultLocale:
|
|
27
|
+
defaultLocale: n,
|
|
22
28
|
// Principal locale defined in config
|
|
23
29
|
availableLocales: r,
|
|
24
30
|
// List of the available locales defined in config
|
|
@@ -27,5 +33,5 @@ const C = ({ onLocaleChange: e } = {}) => {
|
|
|
27
33
|
};
|
|
28
34
|
};
|
|
29
35
|
export {
|
|
30
|
-
|
|
36
|
+
b as useLocale
|
|
31
37
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getLocaleFromStorage as a, localeStorageOptions as t, setLocaleInStorage as c, LocaleStorage as l } from "@intlayer/core";
|
|
2
|
+
import { createMemo as r } from "solid-js";
|
|
3
|
+
const s = a(t), S = s, n = (o, e) => c(o, {
|
|
4
|
+
...t,
|
|
5
|
+
isCookieEnabled: e
|
|
6
|
+
}), m = n, g = (o) => r(
|
|
7
|
+
() => l({
|
|
8
|
+
...t,
|
|
9
|
+
isCookieEnabled: o
|
|
10
|
+
})
|
|
11
|
+
), k = (o) => {
|
|
12
|
+
const e = g(o);
|
|
13
|
+
return {
|
|
14
|
+
localeCookie: e().getLocale(),
|
|
15
|
+
setLocaleCookie: e().setLocale
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
S as localeCookie,
|
|
20
|
+
s as localeInStorage,
|
|
21
|
+
m as setLocaleCookie,
|
|
22
|
+
n as setLocaleInStorage,
|
|
23
|
+
k as useLocaleCookie,
|
|
24
|
+
g as useLocaleStorage
|
|
25
|
+
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import n from "@intlayer/config/built";
|
|
1
2
|
import { getTranslation as r } from "@intlayer/core";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { IntlayerClientContext as
|
|
4
|
-
const
|
|
5
|
-
const { locale: o } =
|
|
6
|
-
return r(
|
|
3
|
+
import { useContext as e } from "solid-js";
|
|
4
|
+
import { IntlayerClientContext as i } from "./IntlayerProvider.mjs";
|
|
5
|
+
const s = (t) => {
|
|
6
|
+
const { locale: o } = e(i) ?? {};
|
|
7
|
+
return r(
|
|
8
|
+
t,
|
|
9
|
+
o?.() ?? n?.internationalization.defaultLocale
|
|
10
|
+
);
|
|
7
11
|
};
|
|
8
12
|
export {
|
|
9
|
-
|
|
13
|
+
s as useTranslation
|
|
10
14
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSameKeyPath as c } from "@intlayer/core";
|
|
2
2
|
import { createComponent as o, mergeProps as m, createMemo as a } from "solid-js";
|
|
3
3
|
import "@intlayer/config/built";
|
|
4
|
-
import "@intlayer/
|
|
4
|
+
import "@intlayer/types";
|
|
5
5
|
import { useIntlayerContext as d } from "../client/IntlayerProvider.mjs";
|
|
6
6
|
import "@intlayer/editor";
|
|
7
7
|
import "./contexts/ConfigurationContext.mjs";
|
|
@@ -11,7 +11,7 @@ import { useEditorEnabled as l } from "./contexts/EditorEnabledContext.mjs";
|
|
|
11
11
|
import "./contexts/CommunicatorContext.mjs";
|
|
12
12
|
import { useFocusDictionary as s } from "./contexts/FocusDictionaryContext.mjs";
|
|
13
13
|
import "../markdown/MarkdownProvider.mjs";
|
|
14
|
-
import "../client/
|
|
14
|
+
import "../client/useLocaleStorage.mjs";
|
|
15
15
|
import "../client/useLocaleBase.mjs";
|
|
16
16
|
import { ContentSelector as y } from "../UI/ContentSelector.mjs";
|
|
17
17
|
const h = (e) => {
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import s from "@intlayer/config/built";
|
|
2
|
-
import { createContext as i, useContext as
|
|
3
|
-
const d = () => "xxxx-xxxx-
|
|
2
|
+
import { createContext as i, useContext as a, createMemo as c, createComponent as x } from "solid-js";
|
|
3
|
+
const d = () => "xxxx-xxxx-xxxx-yxxx".replace(/[xy]/g, (e) => {
|
|
4
4
|
const t = Math.random() * 16 | 0;
|
|
5
|
-
return (e
|
|
5
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
6
6
|
}), {
|
|
7
7
|
editor: o
|
|
8
|
-
} = s,
|
|
8
|
+
} = s, n = i({
|
|
9
9
|
postMessage: () => null,
|
|
10
10
|
allowedOrigins: [o?.applicationURL, o?.editorURL, o?.cmsURL],
|
|
11
11
|
senderId: ""
|
|
12
|
-
}),
|
|
13
|
-
const t = d(),
|
|
12
|
+
}), u = (e) => {
|
|
13
|
+
const t = d(), r = c(() => ({
|
|
14
14
|
postMessage: e.postMessage,
|
|
15
15
|
allowedOrigins: e.allowedOrigins,
|
|
16
16
|
senderId: t
|
|
17
17
|
}));
|
|
18
|
-
return x(
|
|
18
|
+
return x(n.Provider, {
|
|
19
19
|
get value() {
|
|
20
|
-
return
|
|
20
|
+
return r();
|
|
21
21
|
},
|
|
22
22
|
get children() {
|
|
23
23
|
return e.children;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
}, g = () =>
|
|
26
|
+
}, g = () => a(n);
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
u as CommunicatorProvider,
|
|
29
29
|
g as useCommunicator
|
|
30
30
|
};
|