react-intlayer 4.0.4 → 4.1.0

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.
Files changed (45) hide show
  1. package/dist/cjs/UI/ContentSelector.cjs +2 -2
  2. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  3. package/dist/cjs/client/IntlayerProvider.cjs +11 -5
  4. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  5. package/dist/cjs/editor/ContentSelectorWrapper.cjs +9 -11
  6. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  7. package/dist/cjs/editor/IntlayerEditorProvider.cjs +36 -15
  8. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  9. package/dist/esm/UI/ContentSelector.mjs +2 -2
  10. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  11. package/dist/esm/client/IntlayerProvider.mjs +13 -8
  12. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  13. package/dist/esm/client/index.mjs +10 -10
  14. package/dist/esm/client/t.mjs +2 -2
  15. package/dist/esm/client/useContent.mjs +2 -2
  16. package/dist/esm/client/useDictionary.mjs +2 -2
  17. package/dist/esm/client/useIntlayer.mjs +2 -2
  18. package/dist/esm/client/useIntlayerAsync.mjs +3 -3
  19. package/dist/esm/client/useLocale.mjs +2 -2
  20. package/dist/esm/client/useLocaleBase.mjs +1 -1
  21. package/dist/esm/client/useTraduction.mjs +2 -2
  22. package/dist/esm/editor/ContentSelectorWrapper.mjs +10 -12
  23. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  24. package/dist/esm/editor/IntlayerEditorProvider.mjs +38 -17
  25. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  26. package/dist/esm/editor/index.mjs +2 -2
  27. package/dist/esm/editor/renderContentEditor.mjs +1 -1
  28. package/dist/esm/getDictionary.mjs +2 -2
  29. package/dist/esm/getIntlayer.mjs +2 -2
  30. package/dist/esm/getIntlayerAsync.mjs +1 -1
  31. package/dist/esm/index.mjs +4 -4
  32. package/dist/esm/processDictionary/index.mjs +2 -2
  33. package/dist/esm/recursiveTransformContent.mjs +1 -1
  34. package/dist/esm/server/IntlayerServerProvider.mjs +1 -1
  35. package/dist/esm/server/getLocaleTranslation.mjs +2 -2
  36. package/dist/esm/server/index.mjs +6 -6
  37. package/dist/esm/server/t.mjs +3 -3
  38. package/dist/esm/server/useDictionary.mjs +3 -3
  39. package/dist/esm/server/useIntlayer.mjs +3 -3
  40. package/dist/esm/server/useTraduction.mjs +3 -3
  41. package/dist/types/client/IntlayerProvider.d.ts +0 -3
  42. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  43. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  44. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  45. package/package.json +16 -16
@@ -24,7 +24,7 @@ __export(ContentSelector_exports, {
24
24
  module.exports = __toCommonJS(ContentSelector_exports);
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
26
  var import_react = require("react");
27
- const DEFAULT_PRESS_DETECT_DURATION = 400;
27
+ const DEFAULT_PRESS_DETECT_DURATION = 250;
28
28
  const ContentSelector = ({
29
29
  children,
30
30
  onPress: onSelect,
@@ -99,7 +99,7 @@ const ContentSelector = ({
99
99
  outlineOffset: "4px",
100
100
  outlineStyle: "solid",
101
101
  outlineColor: isSelectingProp || isSelectingState || isHovered ? "inherit" : "transparent",
102
- transition: "all 200ms 100ms ease-in-out"
102
+ transition: "all 100ms 50ms ease-in-out"
103
103
  },
104
104
  role: "button",
105
105
  tabIndex: 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 200ms 100ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqGI;AAnGJ,mBAQO;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,aAAS,qBAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAS,eAAe;AACxE,QAAM,oBAAgB,qBAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,yBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,8BAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqGI;AAnGJ,mBAQO;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,aAAS,qBAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAS,eAAe;AACxE,QAAM,oBAAgB,qBAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,yBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,8BAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -26,23 +26,25 @@ __export(IntlayerProvider_exports, {
26
26
  module.exports = __toCommonJS(IntlayerProvider_exports);
27
27
  var import_jsx_runtime = require("react/jsx-runtime");
28
28
  var import_client = require("@intlayer/config/client");
29
+ var import_editor_react = require("@intlayer/editor-react");
29
30
  var import_react = require("react");
30
- var import_useLocaleCookie = require('./useLocaleCookie.cjs');
31
31
  var import_IntlayerEditorProvider = require('../editor/IntlayerEditorProvider.cjs');
32
32
  var import_PoweredByMeta = require('./PoweredByMeta.cjs');
33
+ var import_useLocaleCookie = require('./useLocaleCookie.cjs');
33
34
  const IntlayerClientContext = (0, import_react.createContext)({
34
35
  locale: import_useLocaleCookie.localeCookie ?? (0, import_client.getConfiguration)().internationalization.defaultLocale,
35
36
  setLocale: () => null
36
37
  });
37
38
  const useIntlayerContext = () => (0, import_react.useContext)(IntlayerClientContext);
38
- const IntlayerProvider = ({
39
+ const IntlayerProviderContent = ({
39
40
  locale,
40
41
  children,
41
42
  setLocale: setLocaleProp
42
43
  }) => {
43
44
  const { internationalization } = (0, import_client.getConfiguration)();
44
45
  const { defaultLocale, locales: availableLocales } = internationalization;
45
- const [currentLocale, setCurrentLocale] = (0, import_react.useState)(
46
+ const [currentLocale, setCurrentLocale] = (0, import_editor_react.useCrossFrameState)(
47
+ "INTLAYER_CURRENT_LOCALE",
46
48
  locale ?? import_useLocaleCookie.localeCookie ?? defaultLocale
47
49
  );
48
50
  const setLocaleBase = (0, import_react.useCallback)(
@@ -57,16 +59,20 @@ const IntlayerProvider = ({
57
59
  },
58
60
  [availableLocales, currentLocale, locale]
59
61
  );
60
- const setLocale = setLocaleProp ?? setLocaleBase;
62
+ const setLocale = (0, import_react.useMemo)(
63
+ () => setLocaleProp ?? setLocaleBase,
64
+ [setLocaleProp, setLocaleBase]
65
+ );
61
66
  const value = (0, import_react.useMemo)(
62
67
  () => ({ locale: currentLocale, setLocale }),
63
68
  [currentLocale, setLocale]
64
69
  );
65
70
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(IntlayerClientContext.Provider, { value, children: [
66
71
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PoweredByMeta.PoweredByMeta, {}),
67
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_IntlayerEditorProvider.IntlayerEditorProvider, { children })
72
+ children
68
73
  ] });
69
74
  };
75
+ const IntlayerProvider = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_IntlayerEditorProvider.IntlayerEditorProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerProviderContent, { ...props }) });
70
76
  // Annotate the CommonJS export names for ESM import in node:
71
77
  0 && (module.exports = {
72
78
  IntlayerClientContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <PoweredByMeta />\n <IntlayerEditorProvider>{children}</IntlayerEditorProvider>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EI;AA3EJ,oBAA+C;AAC/C,mBAQO;AACP,6BAA8C;AAC9C,oCAAuC;AACvC,2BAA8B;AAUvB,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AAUjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,QAAI,gCAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC,UAAU,uCAAgB;AAAA,EAC5B;AAEA,QAAM,oBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,kDAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,YAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,6CAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,gDAAC,sCAAc;AAAA,IACf,4CAAC,wDAAwB,UAAS;AAAA,KACpC;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { useCrossFrameState } from '@intlayer/editor-react';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nconst IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n 'INTLAYER_CURRENT_LOCALE',\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = useMemo(\n () => setLocaleProp ?? setLocaleBase,\n [setLocaleProp, setLocaleBase]\n );\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <PoweredByMeta />\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkFI;AAhFJ,oBAA+C;AAC/C,0BAAmC;AACnC,mBAQO;AACP,oCAAuC;AACvC,2BAA8B;AAC9B,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AAUxE,MAAM,0BAAqD,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,QAAI,gCAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC;AAAA,IACA,UAAU,uCAAgB;AAAA,EAC5B;AAEA,QAAM,oBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,kDAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,gBAAY;AAAA,IAChB,MAAM,iBAAiB;AAAA,IACvB,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,QAAM,YAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,6CAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,gDAAC,sCAAc;AAAA,IACd;AAAA,KACH;AAEJ;AAEO,MAAM,mBAA8C,CAAC,UAC1D,4CAAC,wDACC,sDAAC,2BAAyB,GAAG,OAAO,GACtC;","names":[]}
@@ -27,14 +27,13 @@ var import_core = require("@intlayer/core");
27
27
  var import_editor_react = require("@intlayer/editor-react");
28
28
  var import_react = require("react");
29
29
  var import_ContentSelector = require('../UI/ContentSelector.cjs');
30
- const ContentSelectorWrapper = ({
30
+ const ContentSelectorWrapperContent = ({
31
31
  children,
32
32
  dictionaryKey,
33
33
  dictionaryPath,
34
34
  keyPath,
35
35
  ...props
36
36
  }) => {
37
- const { enabled } = (0, import_editor_react.useEditorEnabled)();
38
37
  const { focusedContent, setFocusedContent } = (0, import_editor_react.useFocusDictionary)();
39
38
  const { getEditedContentValue } = (0, import_editor_react.useEditedContentActions)();
40
39
  const editedValue = (0, import_react.useMemo)(
@@ -61,16 +60,15 @@ const ContentSelectorWrapper = ({
61
60
  setDisplayedChildren(children);
62
61
  }
63
62
  }, [editedValue, focusedContent, children]);
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelector.ContentSelector, { onPress: handleSelect, isSelecting: isSelected, ...props, children: displayedChildren });
64
+ };
65
+ const ContentSelectorWrapper = ({
66
+ children,
67
+ ...props
68
+ }) => {
69
+ const { enabled } = (0, import_editor_react.useEditorEnabled)();
64
70
  if (enabled) {
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
- import_ContentSelector.ContentSelector,
67
- {
68
- onPress: handleSelect,
69
- isSelecting: isSelected,
70
- ...props,
71
- children: displayedChildren
72
- }
73
- );
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentSelectorWrapperContent, { ...props, children });
74
72
  }
75
73
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
76
74
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\ntype ContentData = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport type ContentSelectorWrapperProps = ContentData &\n HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n if (enabled) {\n return (\n <ContentSelector\n onPress={handleSelect}\n isSelecting={isSelected}\n {...props}\n >\n {displayedChildren}\n </ContentSelector>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6EM;AA3EN,kBAA4C;AAC5C,0BAIO;AACP,mBAQO;AACP,6BAAgC;AAWzB,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AACrC,QAAM,EAAE,gBAAgB,kBAAkB,QAAI,wCAAmB;AACjE,QAAM,EAAE,sBAAsB,QAAI,6CAAwB;AAE1D,QAAM,kBAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,QAC5C,uBAAoB,QAAQ;AAE9B,QAAM,mBAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,gBAAgB,SAAS,iBAAiB;AAAA,EAC5D;AAEA,QAAM,iBAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,SACzC,2BAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,8BAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,MAAI,SAAS;AACX,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,aAAa;AAAA,QACZ,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO,2EAAG,UAAS;AACrB;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\ntype ContentData = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport type ContentSelectorWrapperProps = ContentData &\n HTMLAttributes<HTMLDivElement>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n\n if (enabled) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2EI;AAzEJ,kBAA4C;AAC5C,0BAIO;AACP,mBAQO;AACP,6BAAgC;AAWhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,QAAI,wCAAmB;AACjE,QAAM,EAAE,sBAAsB,QAAI,6CAAwB;AAE1D,QAAM,kBAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,QAC5C,uBAAoB,QAAQ;AAE9B,QAAM,mBAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,gBAAgB,SAAS,iBAAiB;AAAA,EAC5D;AAEA,QAAM,iBAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,SACzC,2BAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,8BAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,SACE,4CAAC,0CAAgB,SAAS,cAAc,aAAa,YAAa,GAAG,OAClE,6BACH;AAEJ;AAEO,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AAErC,MAAI,SAAS;AACX,WACE,4CAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO,2EAAG,UAAS;AACrB;","names":[]}
@@ -37,32 +37,53 @@ var import_client = require("@intlayer/config/client");
37
37
  var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
38
38
  var import_editor_react = require("@intlayer/editor-react");
39
39
  var import_react = require("react");
40
- const IntlayerEditorProviderEnabled = () => {
40
+ const IntlayerEditorHooksEnabled = () => {
41
41
  (0, import_editor_react.useCrossURLPathState)(void 0, {
42
42
  receive: false,
43
43
  emit: true
44
44
  });
45
- const { setConfiguration } = (0, import_editor_react.useConfigurationActions)();
46
45
  const { setLocaleDictionaries } = (0, import_editor_react.useDictionariesRecordActions)();
47
46
  (0, import_react.useEffect)(() => {
48
47
  setLocaleDictionaries(import_dictionaries_entry.default);
49
- const config = (0, import_client.getConfiguration)();
50
- setConfiguration(config);
51
48
  }, [setLocaleDictionaries]);
52
49
  (0, import_editor_react.useIframeClickInterceptor)();
53
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
54
51
  };
55
- const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
56
- import_editor_react.EditorProvider,
57
- {
58
- postMessage: (data) => window.parent?.postMessage(data, "*"),
59
- allowedOrigins: ["*"],
60
- children: [
61
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorProviderEnabled, {}),
62
- children
63
- ]
64
- }
65
- );
52
+ const IntlayerEditorHook = () => {
53
+ const { enabled } = (0, import_editor_react.useEditorEnabled)();
54
+ return enabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorHooksEnabled, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
55
+ };
56
+ const IntlayerEditorProvider = ({ children }) => {
57
+ const configuration = (0, import_client.getConfiguration)();
58
+ const { editor } = configuration;
59
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
60
+ import_editor_react.EditorProvider,
61
+ {
62
+ postMessage: (data) => {
63
+ if (typeof window === "undefined") return;
64
+ window?.postMessage(
65
+ data,
66
+ // Use to restrict the origin of the editor for security reasons.
67
+ // Correspond to the current application URL to synchronize the locales states.
68
+ editor.applicationURL
69
+ );
70
+ window.parent?.postMessage(
71
+ data,
72
+ // Use to restrict the origin of the editor for security reasons.
73
+ // Correspond to the current editor URL.
74
+ editor.editorURL
75
+ );
76
+ },
77
+ allowedOrigins: [editor.editorURL, editor.applicationURL],
78
+ mode: "client",
79
+ configuration,
80
+ children: [
81
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorHook, {}),
82
+ children
83
+ ]
84
+ }
85
+ );
86
+ };
66
87
  // Annotate the CommonJS export names for ESM import in node:
67
88
  0 && (module.exports = {
68
89
  IntlayerEditorProvider
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useConfigurationActions,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nconst IntlayerEditorProviderEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Configuration Messages\n */\n const { setConfiguration } = useConfigurationActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(dictionaries);\n\n const config = getConfiguration();\n setConfiguration(config);\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <EditorProvider\n postMessage={(data) => window.parent?.postMessage(data, '*')}\n allowedOrigins={['*']}\n >\n <IntlayerEditorProviderEnabled />\n {children}\n </EditorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6CS;AA3CT,oBAAiC;AACjC,gCAAyB;AACzB,0BAMO;AACP,mBAA2D;AAO3D,MAAM,gCAAoC,MAAM;AAI9C,gDAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,iBAAiB,QAAI,6CAAwB;AACrD,QAAM,EAAE,sBAAsB,QAAI,kDAA6B;AAE/D,8BAAU,MAAM;AACd,0BAAsB,0BAAAA,OAAY;AAElC,UAAM,aAAS,gCAAiB;AAChC,qBAAiB,MAAM;AAAA,EACzB,GAAG,CAAC,qBAAqB,CAAC;AAK1B,qDAA0B;AAE1B,SAAO,2EAAE;AACX;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MACvE;AAAA,EAAC;AAAA;AAAA,IACC,aAAa,CAAC,SAAS,OAAO,QAAQ,YAAY,MAAM,GAAG;AAAA,IAC3D,gBAAgB,CAAC,GAAG;AAAA,IAEpB;AAAA,kDAAC,iCAA8B;AAAA,MAC9B;AAAA;AAAA;AACH;","names":["dictionaries"]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useConfigurationState,\n useIframeClickInterceptor,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(dictionaries);\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n const configuration = getConfiguration();\n\n const { editor } = configuration;\n\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current editor URL.\n editor.editorURL\n );\n }}\n allowedOrigins={[editor.editorURL, editor.applicationURL]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CS;AAxCT,oBAAiC;AAMjC,gCAAyB;AACzB,0BAOO;AACP,mBAA2D;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,gDAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,sBAAsB,QAAI,kDAA6B;AAE/D,8BAAU,MAAM;AACd,0BAAsB,0BAAAA,OAAY;AAAA,EACpC,GAAG,CAAC,qBAAqB,CAAC;AAK1B,qDAA0B;AAE1B,SAAO,2EAAE;AACX;AAEA,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AAErC,SAAO,UAAU,4CAAC,8BAA2B,IAAK,2EAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,QAAM,oBAAgB,gCAAiB;AAEvC,QAAM,EAAE,OAAO,IAAI;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA,UAGA,OAAO;AAAA,QACT;AACA,eAAO,QAAQ;AAAA,UACb;AAAA;AAAA;AAAA,UAGA,OAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,OAAO,WAAW,OAAO,cAAc;AAAA,MACxD,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,oDAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["dictionaries"]}
@@ -6,7 +6,7 @@ import {
6
6
  useRef,
7
7
  useCallback
8
8
  } from "react";
9
- const DEFAULT_PRESS_DETECT_DURATION = 400;
9
+ const DEFAULT_PRESS_DETECT_DURATION = 250;
10
10
  const ContentSelector = ({
11
11
  children,
12
12
  onPress: onSelect,
@@ -81,7 +81,7 @@ const ContentSelector = ({
81
81
  outlineOffset: "4px",
82
82
  outlineStyle: "solid",
83
83
  outlineColor: isSelectingProp || isSelectingState || isHovered ? "inherit" : "transparent",
84
- transition: "all 200ms 100ms ease-in-out"
84
+ transition: "all 100ms 50ms ease-in-out"
85
85
  },
86
86
  role: "button",
87
87
  tabIndex: 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 200ms 100ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";AAqGI;AAnGJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,eAAe;AACxE,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,YAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";AAqGI;AAnGJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,eAAe;AACxE,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,YAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -1,29 +1,30 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { getConfiguration } from "@intlayer/config/client";
4
+ import { useCrossFrameState } from "@intlayer/editor-react";
4
5
  import {
5
6
  createContext,
6
7
  useContext,
7
8
  useMemo,
8
- useState,
9
9
  useCallback
10
10
  } from "react";
11
- import { localeCookie, setLocaleCookie } from './useLocaleCookie.mjs';
12
- import { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider.mjs';
13
- import { PoweredByMeta } from './PoweredByMeta.mjs';
11
+ import { IntlayerEditorProvider } from "../editor/IntlayerEditorProvider.mjs";
12
+ import { PoweredByMeta } from "./PoweredByMeta.mjs";
13
+ import { localeCookie, setLocaleCookie } from "./useLocaleCookie.mjs";
14
14
  const IntlayerClientContext = createContext({
15
15
  locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,
16
16
  setLocale: () => null
17
17
  });
18
18
  const useIntlayerContext = () => useContext(IntlayerClientContext);
19
- const IntlayerProvider = ({
19
+ const IntlayerProviderContent = ({
20
20
  locale,
21
21
  children,
22
22
  setLocale: setLocaleProp
23
23
  }) => {
24
24
  const { internationalization } = getConfiguration();
25
25
  const { defaultLocale, locales: availableLocales } = internationalization;
26
- const [currentLocale, setCurrentLocale] = useState(
26
+ const [currentLocale, setCurrentLocale] = useCrossFrameState(
27
+ "INTLAYER_CURRENT_LOCALE",
27
28
  locale ?? localeCookie ?? defaultLocale
28
29
  );
29
30
  const setLocaleBase = useCallback(
@@ -38,16 +39,20 @@ const IntlayerProvider = ({
38
39
  },
39
40
  [availableLocales, currentLocale, locale]
40
41
  );
41
- const setLocale = setLocaleProp ?? setLocaleBase;
42
+ const setLocale = useMemo(
43
+ () => setLocaleProp ?? setLocaleBase,
44
+ [setLocaleProp, setLocaleBase]
45
+ );
42
46
  const value = useMemo(
43
47
  () => ({ locale: currentLocale, setLocale }),
44
48
  [currentLocale, setLocale]
45
49
  );
46
50
  return /* @__PURE__ */ jsxs(IntlayerClientContext.Provider, { value, children: [
47
51
  /* @__PURE__ */ jsx(PoweredByMeta, {}),
48
- /* @__PURE__ */ jsx(IntlayerEditorProvider, { children })
52
+ children
49
53
  ] });
50
54
  };
55
+ const IntlayerProvider = (props) => /* @__PURE__ */ jsx(IntlayerEditorProvider, { children: /* @__PURE__ */ jsx(IntlayerProviderContent, { ...props }) });
51
56
  export {
52
57
  IntlayerClientContext,
53
58
  IntlayerProvider,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <PoweredByMeta />\n <IntlayerEditorProvider>{children}</IntlayerEditorProvider>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";AA6EI,SACE,KADF;AA3EJ,SAAS,wBAAsC;AAC/C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,uBAAuB;AAC9C,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAUvB,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAUjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,qBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,wBAAC,iBAAc;AAAA,IACf,oBAAC,0BAAwB,UAAS;AAAA,KACpC;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { useCrossFrameState } from '@intlayer/editor-react';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nconst IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n 'INTLAYER_CURRENT_LOCALE',\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = useMemo(\n () => setLocaleProp ?? setLocaleBase,\n [setLocaleProp, setLocaleBase]\n );\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <PoweredByMeta />\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";AAkFI,SACE,KADF;AAhFJ,SAAS,wBAAsC;AAC/C,SAAS,0BAA0B;AACnC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAC9B,SAAS,cAAc,uBAAuB;AAUvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAUxE,MAAM,0BAAqD,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC;AAAA,IACA,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY;AAAA,IAChB,MAAM,iBAAiB;AAAA,IACvB,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,qBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,wBAAC,iBAAc;AAAA,IACd;AAAA,KACH;AAEJ;AAEO,MAAM,mBAA8C,CAAC,UAC1D,oBAAC,0BACC,8BAAC,2BAAyB,GAAG,OAAO,GACtC;","names":[]}
@@ -2,20 +2,20 @@ import {
2
2
  IntlayerClientContext,
3
3
  useIntlayerContext,
4
4
  IntlayerProvider
5
- } from './IntlayerProvider.mjs';
6
- import { useIntlayer } from './useIntlayer.mjs';
7
- import { useIntlayerAsync } from './useIntlayerAsync.mjs';
8
- import { useDictionary } from './useDictionary.mjs';
9
- import { useLocaleBase } from './useLocaleBase.mjs';
10
- import { useLocale } from './useLocale.mjs';
11
- import { useTraduction } from './useTraduction.mjs';
5
+ } from "./IntlayerProvider.mjs";
6
+ import { useIntlayer } from "./useIntlayer.mjs";
7
+ import { useIntlayerAsync } from "./useIntlayerAsync.mjs";
8
+ import { useDictionary } from "./useDictionary.mjs";
9
+ import { useLocaleBase } from "./useLocaleBase.mjs";
10
+ import { useLocale } from "./useLocale.mjs";
11
+ import { useTraduction } from "./useTraduction.mjs";
12
12
  import {
13
13
  useLocaleCookie,
14
14
  localeCookie,
15
15
  setLocaleCookie
16
- } from './useLocaleCookie.mjs';
17
- import { getBrowserLocale } from './getBrowserLocale.mjs';
18
- import { t } from './t.mjs';
16
+ } from "./useLocaleCookie.mjs";
17
+ import { getBrowserLocale } from "./getBrowserLocale.mjs";
18
+ import { t } from "./t.mjs";
19
19
  export {
20
20
  IntlayerClientContext,
21
21
  IntlayerProvider,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useContext } from "react";
3
- import { getTranslation } from '../getTranslation.mjs';
4
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
3
+ import { getTranslation } from "../getTranslation.mjs";
4
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  const t = (multilangContent, locale) => {
6
6
  const { locale: currentLocale } = useContext(IntlayerClientContext);
7
7
  const localeTarget = locale ?? currentLocale;
@@ -1,5 +1,5 @@
1
- import { useLocaleBase } from './useLocaleBase.mjs';
2
- import { useTraduction } from './useTraduction.mjs';
1
+ import { useLocaleBase } from "./useLocaleBase.mjs";
2
+ import { useTraduction } from "./useTraduction.mjs";
3
3
  const useContent = (languageContent) => {
4
4
  const { locale } = useLocaleBase();
5
5
  const content = useTraduction(languageContent);
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useContext } from "react";
3
- import { getDictionary } from '../getDictionary.mjs';
4
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
3
+ import { getDictionary } from "../getDictionary.mjs";
4
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  const useDictionary = (dictionary, locale, isRenderEditor = false) => {
6
6
  const { locale: currentLocale } = useContext(IntlayerClientContext);
7
7
  const localeTarget = locale ?? currentLocale;
@@ -2,8 +2,8 @@
2
2
  import { useContext } from "react";
3
3
  import {
4
4
  getIntlayer
5
- } from '../getIntlayer.mjs';
6
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
5
+ } from "../getIntlayer.mjs";
6
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
7
7
  const useIntlayer = (key, locale, isRenderEditor = true) => {
8
8
  const { locale: currentLocale } = useContext(IntlayerClientContext);
9
9
  const localeTarget = locale ?? currentLocale;
@@ -2,9 +2,9 @@
2
2
  import { useContext, useEffect, useMemo, useState } from "react";
3
3
  import {
4
4
  getIntlayer
5
- } from '../getIntlayer.mjs';
6
- import { getIntlayerAsync } from '../getIntlayerAsync.mjs';
7
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
5
+ } from "../getIntlayer.mjs";
6
+ import { getIntlayerAsync } from "../getIntlayerAsync.mjs";
7
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
8
8
  const useIntlayerAsync = (key, locale, isRenderEditor = true) => {
9
9
  const { locale: currentLocale } = useContext(IntlayerClientContext);
10
10
  const localeTarget = locale ?? currentLocale;
@@ -2,8 +2,8 @@
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
3
  import { localeList } from "@intlayer/core";
4
4
  import { useCallback, useContext } from "react";
5
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
6
- import { useLocaleCookie } from './useLocaleCookie.mjs';
5
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
6
+ import { useLocaleCookie } from "./useLocaleCookie.mjs";
7
7
  const useLocale = ({ onLocaleChange } = {}) => {
8
8
  const {
9
9
  /**
@@ -2,7 +2,7 @@
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
3
  import { localeList } from "@intlayer/core";
4
4
  import { useContext } from "react";
5
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
5
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
6
6
  const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
7
7
  const useLocaleBase = () => {
8
8
  const { locale, setLocale } = useContext(IntlayerClientContext);
@@ -1,6 +1,6 @@
1
1
  import { useContext } from "react";
2
- import { getTranslation } from '../getTranslation.mjs';
3
- import { IntlayerClientContext } from './IntlayerProvider.mjs';
2
+ import { getTranslation } from "../getTranslation.mjs";
3
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
4
  const useTraduction = (languageContent) => {
5
5
  const { locale } = useContext(IntlayerClientContext);
6
6
  return getTranslation(languageContent, locale);
@@ -12,15 +12,14 @@ import {
12
12
  useState,
13
13
  useMemo
14
14
  } from "react";
15
- import { ContentSelector } from '../UI/ContentSelector.mjs';
16
- const ContentSelectorWrapper = ({
15
+ import { ContentSelector } from "../UI/ContentSelector.mjs";
16
+ const ContentSelectorWrapperContent = ({
17
17
  children,
18
18
  dictionaryKey,
19
19
  dictionaryPath,
20
20
  keyPath,
21
21
  ...props
22
22
  }) => {
23
- const { enabled } = useEditorEnabled();
24
23
  const { focusedContent, setFocusedContent } = useFocusDictionary();
25
24
  const { getEditedContentValue } = useEditedContentActions();
26
25
  const editedValue = useMemo(
@@ -47,16 +46,15 @@ const ContentSelectorWrapper = ({
47
46
  setDisplayedChildren(children);
48
47
  }
49
48
  }, [editedValue, focusedContent, children]);
49
+ return /* @__PURE__ */ jsx(ContentSelector, { onPress: handleSelect, isSelecting: isSelected, ...props, children: displayedChildren });
50
+ };
51
+ const ContentSelectorWrapper = ({
52
+ children,
53
+ ...props
54
+ }) => {
55
+ const { enabled } = useEditorEnabled();
50
56
  if (enabled) {
51
- return /* @__PURE__ */ jsx(
52
- ContentSelector,
53
- {
54
- onPress: handleSelect,
55
- isSelecting: isSelected,
56
- ...props,
57
- children: displayedChildren
58
- }
59
- );
57
+ return /* @__PURE__ */ jsx(ContentSelectorWrapperContent, { ...props, children });
60
58
  }
61
59
  return /* @__PURE__ */ jsx(Fragment, { children });
62
60
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\ntype ContentData = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport type ContentSelectorWrapperProps = ContentData &\n HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n if (enabled) {\n return (\n <ContentSelector\n onPress={handleSelect}\n isSelecting={isSelected}\n {...props}\n >\n {displayedChildren}\n </ContentSelector>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AA6EM,SAUG,UAVH;AA3EN,SAAS,qBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAWzB,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,gBAAgB,SAAS,iBAAiB;AAAA,EAC5D;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,MAAI,SAAS;AACX,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,aAAa;AAAA,QACZ,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\ntype ContentData = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport type ContentSelectorWrapperProps = ContentData &\n HTMLAttributes<HTMLDivElement>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n\n if (enabled) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AA2EI,SAoBK,UApBL;AAzEJ,SAAS,qBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAWhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,gBAAgB,SAAS,iBAAiB;AAAA,EAC5D;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAAa,GAAG,OAClE,6BACH;AAEJ;AAEO,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,MAAI,SAAS;AACX,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
@@ -6,36 +6,57 @@ import {
6
6
  EditorProvider,
7
7
  useCrossURLPathState,
8
8
  useDictionariesRecordActions,
9
- useConfigurationActions,
10
- useIframeClickInterceptor
9
+ useIframeClickInterceptor,
10
+ useEditorEnabled
11
11
  } from "@intlayer/editor-react";
12
12
  import { useEffect } from "react";
13
- const IntlayerEditorProviderEnabled = () => {
13
+ const IntlayerEditorHooksEnabled = () => {
14
14
  useCrossURLPathState(void 0, {
15
15
  receive: false,
16
16
  emit: true
17
17
  });
18
- const { setConfiguration } = useConfigurationActions();
19
18
  const { setLocaleDictionaries } = useDictionariesRecordActions();
20
19
  useEffect(() => {
21
20
  setLocaleDictionaries(dictionaries);
22
- const config = getConfiguration();
23
- setConfiguration(config);
24
21
  }, [setLocaleDictionaries]);
25
22
  useIframeClickInterceptor();
26
23
  return /* @__PURE__ */ jsx(Fragment, {});
27
24
  };
28
- const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ jsxs(
29
- EditorProvider,
30
- {
31
- postMessage: (data) => window.parent?.postMessage(data, "*"),
32
- allowedOrigins: ["*"],
33
- children: [
34
- /* @__PURE__ */ jsx(IntlayerEditorProviderEnabled, {}),
35
- children
36
- ]
37
- }
38
- );
25
+ const IntlayerEditorHook = () => {
26
+ const { enabled } = useEditorEnabled();
27
+ return enabled ? /* @__PURE__ */ jsx(IntlayerEditorHooksEnabled, {}) : /* @__PURE__ */ jsx(Fragment, {});
28
+ };
29
+ const IntlayerEditorProvider = ({ children }) => {
30
+ const configuration = getConfiguration();
31
+ const { editor } = configuration;
32
+ return /* @__PURE__ */ jsxs(
33
+ EditorProvider,
34
+ {
35
+ postMessage: (data) => {
36
+ if (typeof window === "undefined") return;
37
+ window?.postMessage(
38
+ data,
39
+ // Use to restrict the origin of the editor for security reasons.
40
+ // Correspond to the current application URL to synchronize the locales states.
41
+ editor.applicationURL
42
+ );
43
+ window.parent?.postMessage(
44
+ data,
45
+ // Use to restrict the origin of the editor for security reasons.
46
+ // Correspond to the current editor URL.
47
+ editor.editorURL
48
+ );
49
+ },
50
+ allowedOrigins: [editor.editorURL, editor.applicationURL],
51
+ mode: "client",
52
+ configuration,
53
+ children: [
54
+ /* @__PURE__ */ jsx(IntlayerEditorHook, {}),
55
+ children
56
+ ]
57
+ }
58
+ );
59
+ };
39
60
  export {
40
61
  IntlayerEditorProvider
41
62
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useConfigurationActions,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nconst IntlayerEditorProviderEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Configuration Messages\n */\n const { setConfiguration } = useConfigurationActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(dictionaries);\n\n const config = getConfiguration();\n setConfiguration(config);\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <EditorProvider\n postMessage={(data) => window.parent?.postMessage(data, '*')}\n allowedOrigins={['*']}\n >\n <IntlayerEditorProviderEnabled />\n {children}\n </EditorProvider>\n);\n"],"mappings":";AA6CS,wBAIP,YAJO;AA3CT,SAAS,wBAAwB;AACjC,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAO3D,MAAM,gCAAoC,MAAM;AAI9C,uBAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd,0BAAsB,YAAY;AAElC,UAAM,SAAS,iBAAiB;AAChC,qBAAiB,MAAM;AAAA,EACzB,GAAG,CAAC,qBAAqB,CAAC;AAK1B,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MACvE;AAAA,EAAC;AAAA;AAAA,IACC,aAAa,CAAC,SAAS,OAAO,QAAQ,YAAY,MAAM,GAAG;AAAA,IAC3D,gBAAgB,CAAC,GAAG;AAAA,IAEpB;AAAA,0BAAC,iCAA8B;AAAA,MAC9B;AAAA;AAAA;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useConfigurationState,\n useIframeClickInterceptor,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(dictionaries);\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n const configuration = getConfiguration();\n\n const { editor } = configuration;\n\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current editor URL.\n editor.editorURL\n );\n }}\n allowedOrigins={[editor.editorURL, editor.applicationURL]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AA4CS,wBAeL,YAfK;AAxCT,SAAS,wBAAwB;AAMjC,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,uBAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd,0BAAsB,YAAY;AAAA,EACpC,GAAG,CAAC,qBAAqB,CAAC;AAK1B,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEA,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,SAAO,UAAU,oBAAC,8BAA2B,IAAK,gCAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,EAAE,OAAO,IAAI;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA,UAGA,OAAO;AAAA,QACT;AACA,eAAO,QAAQ;AAAA,UACb;AAAA;AAAA;AAAA,UAGA,OAAO;AAAA,QACT;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,OAAO,WAAW,OAAO,cAAc;AAAA,MACxD,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -1,3 +1,3 @@
1
- export * from './ContentSelectorWrapper.mjs';
2
- export * from './renderContentEditor.mjs';
1
+ export * from "./ContentSelectorWrapper.mjs";
2
+ export * from "./renderContentEditor.mjs";
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import {
3
3
  ContentSelectorWrapper
4
- } from './ContentSelectorWrapper.mjs';
4
+ } from "./ContentSelectorWrapper.mjs";
5
5
  const renderIntlayerEditor = (props) => {
6
6
  const Result = /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content });
7
7
  return { ...Result, value: props.content };
@@ -1,7 +1,7 @@
1
- import { processDictionary } from './processDictionary/index.mjs';
1
+ import { processDictionary } from "./processDictionary/index.mjs";
2
2
  import {
3
3
  recursiveTransformContent
4
- } from './recursiveTransformContent.mjs';
4
+ } from "./recursiveTransformContent.mjs";
5
5
  const getDictionary = (dictionary, locale, isRenderEditor = false) => {
6
6
  const result = processDictionary(
7
7
  dictionary.content,
@@ -1,8 +1,8 @@
1
1
  import dictionaries from "@intlayer/dictionaries-entry";
2
- import { processDictionary } from './processDictionary/index.mjs';
2
+ import { processDictionary } from "./processDictionary/index.mjs";
3
3
  import {
4
4
  recursiveTransformContent
5
- } from './recursiveTransformContent.mjs';
5
+ } from "./recursiveTransformContent.mjs";
6
6
  const getIntlayer = (key, locale, isRenderEditor = false) => {
7
7
  const dictionary = dictionaries[key];
8
8
  if (!dictionary) {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { fetchDistantDictionary } from "@intlayer/api";
3
- import { getDictionary } from './getDictionary.mjs';
3
+ import { getDictionary } from "./getDictionary.mjs";
4
4
  const getIntlayerAsync = async (key, locale, isRenderEditor = true) => {
5
5
  const jsonDistantDictionary = await fetchDistantDictionary(key);
6
6
  if (jsonDistantDictionary) {
@@ -1,4 +1,4 @@
1
- import { getTranslation } from './getTranslation.mjs';
1
+ import { getTranslation } from "./getTranslation.mjs";
2
2
  import {
3
3
  IntlayerProvider,
4
4
  IntlayerClientContext,
@@ -14,9 +14,9 @@ import {
14
14
  getBrowserLocale,
15
15
  useLocaleBase,
16
16
  t
17
- } from './client/index.mjs';
18
- import { getDictionary } from './getDictionary.mjs';
19
- import { getIntlayer } from './getIntlayer.mjs';
17
+ } from "./client/index.mjs";
18
+ import { getDictionary } from "./getDictionary.mjs";
19
+ import { getIntlayer } from "./getIntlayer.mjs";
20
20
  export {
21
21
  IntlayerClientContext,
22
22
  IntlayerProvider,
@@ -4,8 +4,8 @@ import {
4
4
  findMatchingCondition
5
5
  } from "@intlayer/core";
6
6
  import { createElement } from "react";
7
- import { getEnumeration } from '../getEnumeration.mjs';
8
- import { getTranslation } from '../getTranslation.mjs';
7
+ import { getEnumeration } from "../getEnumeration.mjs";
8
+ import { getTranslation } from "../getTranslation.mjs";
9
9
  const {
10
10
  internationalization: { defaultLocale }
11
11
  } = getConfiguration();
@@ -1,7 +1,7 @@
1
1
  import { isValidElement } from "react";
2
2
  import {
3
3
  renderIntlayerEditor
4
- } from './editor/renderContentEditor.mjs';
4
+ } from "./editor/renderContentEditor.mjs";
5
5
  const recursiveTransformContent = (value, isRenderEditor = false) => {
6
6
  if (typeof value === "function") {
7
7
  return (props) => recursiveTransformContent(value(props), isRenderEditor);
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
- import { createServerContext, getServerContext } from './serverContext.mjs';
3
+ import { createServerContext, getServerContext } from "./serverContext.mjs";
4
4
  const { defaultLocale } = getConfiguration().internationalization;
5
5
  const IntlayerServerContext = createServerContext(defaultLocale);
6
6
  const useIntlayer = () => getServerContext(IntlayerServerContext);
@@ -1,7 +1,7 @@
1
1
  import { getConfiguration } from "@intlayer/config/client";
2
2
  import { getTranslationContent } from "@intlayer/core";
3
- import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
4
- import { getServerContext } from './serverContext.mjs';
3
+ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
4
+ import { getServerContext } from "./serverContext.mjs";
5
5
  const getLocaleTranslation = (languageContent) => {
6
6
  const locale = getServerContext(IntlayerServerContext);
7
7
  const content = getTranslationContent(
@@ -1,13 +1,13 @@
1
- import { getLocaleTranslation } from './getLocaleTranslation.mjs';
2
- import { useTraduction } from './useTraduction.mjs';
1
+ import { getLocaleTranslation } from "./getLocaleTranslation.mjs";
2
+ import { useTraduction } from "./useTraduction.mjs";
3
3
  import {
4
4
  IntlayerServerContext,
5
5
  locale,
6
6
  IntlayerServerProvider
7
- } from './IntlayerServerProvider.mjs';
8
- import { useIntlayer } from './useIntlayer.mjs';
9
- import { useDictionary } from './useDictionary.mjs';
10
- import { t } from './t.mjs';
7
+ } from "./IntlayerServerProvider.mjs";
8
+ import { useIntlayer } from "./useIntlayer.mjs";
9
+ import { useDictionary } from "./useDictionary.mjs";
10
+ import { t } from "./t.mjs";
11
11
  export {
12
12
  IntlayerServerContext as IntlayerServer,
13
13
  IntlayerServerProvider,
@@ -1,6 +1,6 @@
1
- import { getTranslation } from '../getTranslation.mjs';
2
- import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
3
- import { getServerContext } from './serverContext.mjs';
1
+ import { getTranslation } from "../getTranslation.mjs";
2
+ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { getServerContext } from "./serverContext.mjs";
4
4
  const t = (multilangContent, locale) => {
5
5
  const currentLocale = getServerContext(IntlayerServerContext);
6
6
  const localeTarget = locale ?? currentLocale;
@@ -1,6 +1,6 @@
1
- import { getDictionary } from '../getDictionary.mjs';
2
- import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
3
- import { getServerContext } from './serverContext.mjs';
1
+ import { getDictionary } from "../getDictionary.mjs";
2
+ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { getServerContext } from "./serverContext.mjs";
4
4
  const useDictionary = (dictionary, locale, isRenderEditor = false) => {
5
5
  const localeTarget = locale ?? getServerContext(IntlayerServerContext);
6
6
  return getDictionary(dictionary, localeTarget, isRenderEditor);
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getIntlayer
3
- } from '../getIntlayer.mjs';
4
- import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
5
- import { getServerContext } from './serverContext.mjs';
3
+ } from "../getIntlayer.mjs";
4
+ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
5
+ import { getServerContext } from "./serverContext.mjs";
6
6
  const useIntlayer = (key, locale, isRenderEditor = true) => {
7
7
  const localeTarget = locale ?? getServerContext(IntlayerServerContext);
8
8
  return getIntlayer(key, localeTarget, isRenderEditor);
@@ -1,6 +1,6 @@
1
- import { getTranslation } from '../getTranslation.mjs';
2
- import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
3
- import { getServerContext } from './serverContext.mjs';
1
+ import { getTranslation } from "../getTranslation.mjs";
2
+ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { getServerContext } from "./serverContext.mjs";
4
4
  const useTraduction = (languageContent) => {
5
5
  const locale = getServerContext(IntlayerServerContext);
6
6
  return getTranslation(languageContent, locale);
@@ -16,9 +16,6 @@ export type IntlayerProviderProps = PropsWithChildren & {
16
16
  locale?: Locales;
17
17
  setLocale?: (locale: Locales) => void;
18
18
  };
19
- /**
20
- * Provider that store the current locale on the client side
21
- */
22
19
  export declare const IntlayerProvider: FC<IntlayerProviderProps>;
23
20
  export {};
24
21
  //# sourceMappingURL=IntlayerProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAKf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAwCtD,CAAC"}
1
+ {"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAKf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAmDF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAItD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAM7D,OAAO,EAKL,KAAK,EAAE,EAEP,cAAc,EACf,MAAM,OAAO,CAAC;AAGf,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,WAAW,GACnD,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjC,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CA4DlE,CAAC"}
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAM7D,OAAO,EAKL,KAAK,EAAE,EAEP,cAAc,EACf,MAAM,OAAO,CAAC;AAGf,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,WAAW,GACnD,cAAc,CAAC,cAAc,CAAC,CAAC;AAuDjC,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAelE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAqCnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAQxD,CAAC"}
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAkCnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CA+BxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "4.0.4",
3
+ "version": "4.1.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -71,11 +71,11 @@
71
71
  ],
72
72
  "dependencies": {
73
73
  "js-cookie": "^3.0.5",
74
- "@intlayer/editor-react": "4.0.4",
75
- "@intlayer/core": "4.0.4",
76
- "@intlayer/api": "4.0.4",
77
- "@intlayer/config": "4.0.4",
78
- "@intlayer/dictionaries-entry": "4.0.4"
74
+ "@intlayer/api": "4.1.0",
75
+ "@intlayer/core": "4.1.0",
76
+ "@intlayer/dictionaries-entry": "4.1.0",
77
+ "@intlayer/config": "4.1.0",
78
+ "@intlayer/editor-react": "4.1.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@craco/types": "^7.1.0",
@@ -92,22 +92,22 @@
92
92
  "tsc-alias": "^1.8.10",
93
93
  "tsup": "^8.3.5",
94
94
  "typescript": "^5.7.3",
95
- "@intlayer/backend": "4.0.4",
96
- "@utils/ts-config": "1.0.4",
95
+ "@intlayer/backend": "4.1.0",
97
96
  "@utils/eslint-config": "1.0.4",
98
- "@utils/ts-config-types": "1.0.4",
99
- "@utils/tsup-config": "1.0.4"
97
+ "@utils/ts-config": "1.0.4",
98
+ "@utils/tsup-config": "1.0.4",
99
+ "@utils/ts-config-types": "1.0.4"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "react": ">=16.0.0",
103
103
  "react-dom": ">=16.0.0",
104
104
  "vite": ">=4.0.0",
105
- "@intlayer/api": "4.0.4",
106
- "@intlayer/dictionaries-entry": "4.0.4",
107
- "@intlayer/core": "4.0.4",
108
- "intlayer": "4.0.4",
109
- "@intlayer/config": "4.0.4",
110
- "@intlayer/editor-react": "4.0.4"
105
+ "@intlayer/api": "4.1.0",
106
+ "@intlayer/core": "4.1.0",
107
+ "@intlayer/config": "4.1.0",
108
+ "@intlayer/dictionaries-entry": "4.1.0",
109
+ "@intlayer/editor-react": "4.1.0",
110
+ "intlayer": "4.1.0"
111
111
  },
112
112
  "engines": {
113
113
  "node": ">=14.18"