react-intlayer 5.7.5 → 5.7.6

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 (62) hide show
  1. package/dist/cjs/UI/ContentSelector.cjs +6 -2
  2. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  3. package/dist/cjs/client/index.cjs +3 -0
  4. package/dist/cjs/client/index.cjs.map +1 -1
  5. package/dist/cjs/client/useDictionary.cjs +0 -5
  6. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  7. package/dist/cjs/client/useI18n.cjs +51 -0
  8. package/dist/cjs/client/useI18n.cjs.map +1 -0
  9. package/dist/cjs/client/useIntlayer.cjs +0 -6
  10. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  11. package/dist/cjs/editor/ContentSelectorWrapper.cjs +30 -1
  12. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  13. package/dist/cjs/editor/IntlayerEditorProvider.cjs +0 -17
  14. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  15. package/dist/cjs/index.cjs +2 -0
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/server/index.cjs +3 -0
  18. package/dist/cjs/server/index.cjs.map +1 -1
  19. package/dist/cjs/server/useI18n.cjs +50 -0
  20. package/dist/cjs/server/useI18n.cjs.map +1 -0
  21. package/dist/esm/UI/ContentSelector.mjs +6 -2
  22. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  23. package/dist/esm/client/index.mjs +2 -0
  24. package/dist/esm/client/index.mjs.map +1 -1
  25. package/dist/esm/client/useDictionary.mjs +0 -5
  26. package/dist/esm/client/useDictionary.mjs.map +1 -1
  27. package/dist/esm/client/useI18n.mjs +27 -0
  28. package/dist/esm/client/useI18n.mjs.map +1 -0
  29. package/dist/esm/client/useIntlayer.mjs +0 -6
  30. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  31. package/dist/esm/editor/ContentSelectorWrapper.mjs +36 -2
  32. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  33. package/dist/esm/editor/IntlayerEditorProvider.mjs +0 -18
  34. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  35. package/dist/esm/index.mjs +2 -0
  36. package/dist/esm/index.mjs.map +1 -1
  37. package/dist/esm/server/index.mjs +2 -0
  38. package/dist/esm/server/index.mjs.map +1 -1
  39. package/dist/esm/server/useI18n.mjs +26 -0
  40. package/dist/esm/server/useI18n.mjs.map +1 -0
  41. package/dist/types/UI/ContentSelector.d.ts +2 -0
  42. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  43. package/dist/types/client/index.d.ts +1 -0
  44. package/dist/types/client/index.d.ts.map +1 -1
  45. package/dist/types/client/useDictionary.d.ts +1 -1
  46. package/dist/types/client/useDictionary.d.ts.map +1 -1
  47. package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
  48. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  49. package/dist/types/client/useI18n.d.ts +23 -0
  50. package/dist/types/client/useI18n.d.ts.map +1 -0
  51. package/dist/types/client/useIntlayer.d.ts +2 -0
  52. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  53. package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
  54. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  55. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  56. package/dist/types/index.d.ts +1 -1
  57. package/dist/types/index.d.ts.map +1 -1
  58. package/dist/types/server/index.d.ts +1 -0
  59. package/dist/types/server/index.d.ts.map +1 -1
  60. package/dist/types/server/useI18n.d.ts +21 -0
  61. package/dist/types/server/useI18n.d.ts.map +1 -0
  62. package/package.json +13 -13
@@ -27,7 +27,9 @@ var import_react = require("react");
27
27
  const DEFAULT_PRESS_DETECT_DURATION = 250;
28
28
  const ContentSelector = ({
29
29
  children,
30
- onPress: onSelect,
30
+ onPress,
31
+ onHover,
32
+ onUnhover,
31
33
  onClickOutside: onUnselect,
32
34
  pressDuration = DEFAULT_PRESS_DETECT_DURATION,
33
35
  isSelecting: isSelectingProp,
@@ -40,7 +42,7 @@ const ContentSelector = ({
40
42
  const isChildrenString = typeof children === "string";
41
43
  const handleOnLongPress = () => {
42
44
  setIsSelectingState(true);
43
- onSelect();
45
+ onPress();
44
46
  };
45
47
  const startPressTimer = () => {
46
48
  pressTimerRef.current = setTimeout(() => {
@@ -59,8 +61,10 @@ const ContentSelector = ({
59
61
  };
60
62
  const handleMouseEnter = () => {
61
63
  setIsHovered(true);
64
+ onHover?.();
62
65
  };
63
66
  const handleMouseUp = () => {
67
+ onUnhover?.();
64
68
  setIsHovered(false);
65
69
  clearPressTimer();
66
70
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\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} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\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 const isChildrenString = typeof children === 'string';\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: isChildrenString ? 'inline' : 'inline-block',\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;AAsGI;AApGJ,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;AACvE,QAAM,mBAAmB,OAAO,aAAa;AAE7C,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,mBAAmB,WAAW;AAAA,QACvC,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 useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\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 const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\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 onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\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: isChildrenString ? 'inline' : 'inline-block',\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;AA4GI;AA1GJ,mBAQO;AAEP,MAAM,gCAAgC;AAW/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,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;AACvE,QAAM,mBAAmB,OAAO,aAAa;AAE7C,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,YAAQ;AAAA,EACV;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;AACjB,cAAU;AAAA,EACZ;AAEA,QAAM,gBAAgB,MAAM;AAC1B,gBAAY;AACZ,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,mBAAmB,WAAW;AAAA,QACvC,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":[]}
@@ -28,6 +28,7 @@ __export(client_exports, {
28
28
  useDictionary: () => import_useDictionary.useDictionary,
29
29
  useDictionaryAsync: () => import_useDictionaryAsync.useDictionaryAsync,
30
30
  useDictionaryDynamic: () => import_useDictionaryDynamic.useDictionaryDynamic,
31
+ useI18n: () => import_useI18n.useI18n,
31
32
  useIntlayer: () => import_useIntlayer.useIntlayer,
32
33
  useIntlayerAsync: () => import_useIntlayerAsync.useIntlayerAsync,
33
34
  useIntlayerContext: () => import_IntlayerProvider.useIntlayerContext,
@@ -43,6 +44,7 @@ var import_t = require('./t.cjs');
43
44
  var import_useDictionary = require('./useDictionary.cjs');
44
45
  var import_useDictionaryAsync = require('./useDictionaryAsync.cjs');
45
46
  var import_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
47
+ var import_useI18n = require('./useI18n.cjs');
46
48
  var import_useIntlayer = require('./useIntlayer.cjs');
47
49
  var import_useIntlayerAsync = require('./useIntlayerAsync.cjs');
48
50
  var import_useLoadDynamic = require('./useLoadDynamic.cjs');
@@ -61,6 +63,7 @@ var import_useLocaleCookie = require('./useLocaleCookie.cjs');
61
63
  useDictionary,
62
64
  useDictionaryAsync,
63
65
  useDictionaryDynamic,
66
+ useI18n,
64
67
  useIntlayer,
65
68
  useIntlayerAsync,
66
69
  useIntlayerContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { getBrowserLocale } from './getBrowserLocale';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n type IntlayerProviderProps,\n} from './IntlayerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\nexport { useLocaleBase } from './useLocaleBase';\nexport {\n localeCookie,\n setLocaleCookie,\n useLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,8BAMO;AACP,eAAkB;AAClB,2BAA8B;AAC9B,gCAAmC;AACnC,kCAAqC;AACrC,yBAA4B;AAC5B,8BAAiC;AACjC,4BAA+B;AAC/B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { getBrowserLocale } from './getBrowserLocale';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n type IntlayerProviderProps,\n} from './IntlayerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useI18n } from './useI18n';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\nexport { useLocaleBase } from './useLocaleBase';\nexport {\n localeCookie,\n setLocaleCookie,\n useLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AACjC,8BAMO;AACP,eAAkB;AAClB,2BAA8B;AAC9B,gCAAmC;AACnC,kCAAqC;AACrC,qBAAwB;AACxB,yBAA4B;AAC5B,8BAAiC;AACjC,4BAA+B;AAC/B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;","names":[]}
@@ -22,17 +22,12 @@ __export(useDictionary_exports, {
22
22
  useDictionary: () => useDictionary
23
23
  });
24
24
  module.exports = __toCommonJS(useDictionary_exports);
25
- var import_editor_react = require("@intlayer/editor-react");
26
25
  var import_react = require("react");
27
26
  var import_getDictionary = require('../getDictionary.cjs');
28
27
  var import_IntlayerProvider = require('./IntlayerProvider.cjs');
29
28
  const useDictionary = (dictionary, locale) => {
30
29
  const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
31
30
  const localeTarget = locale ?? currentLocale;
32
- const { changedContent } = (0, import_editor_react.useChangedContent)();
33
- if (changedContent?.[dictionary.key]) {
34
- return (0, import_getDictionary.getDictionary)(changedContent?.[dictionary.key], localeTarget);
35
- }
36
31
  return (0, import_getDictionary.getDictionary)(dictionary, localeTarget);
37
32
  };
38
33
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const { changedContent } = useChangedContent();\n\n if (changedContent?.[dictionary.key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[dictionary.key], localeTarget);\n }\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAkC;AAClC,mBAA2B;AAC3B,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,EAAE,eAAe,QAAI,uCAAkB;AAE7C,MAAI,iBAAiB,WAAW,GAAG,GAAG;AAEpC,eAAO,oCAAc,iBAAiB,WAAW,GAAG,GAAG,YAAY;AAAA,EACrE;AAEA,aAAO,oCAAgC,YAAY,YAAY;AACjE;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA2B;AAC3B,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,aAAO,oCAAgC,YAAY,YAAY;AACjE;","names":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var useI18n_exports = {};
21
+ __export(useI18n_exports, {
22
+ useI18n: () => useI18n
23
+ });
24
+ module.exports = __toCommonJS(useI18n_exports);
25
+ var import_react = require("react");
26
+ var import_IntlayerProvider = require('./IntlayerProvider.cjs');
27
+ const useI18n = (namespace, locale) => {
28
+ const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
29
+ const localeTarget = locale ?? currentLocale;
30
+ let dictionaryContent;
31
+ const t = (path) => {
32
+ if (!path) {
33
+ return dictionaryContent;
34
+ }
35
+ const pathArray = path.split(".");
36
+ let current = dictionaryContent;
37
+ for (const key of pathArray) {
38
+ current = current?.[key];
39
+ if (current === void 0) {
40
+ return dictionaryContent;
41
+ }
42
+ }
43
+ return current;
44
+ };
45
+ return t;
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ useI18n
50
+ });
51
+ //# sourceMappingURL=useI18n.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n DictionaryKeys,\n GetSubPath,\n ValidDotPathsFor,\n} from '@intlayer/core';\nimport type { DeepTransformContent } from '../plugins';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n // Get the dictionary content for the namespace\n let dictionaryContent: DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n\n // Return the translation function\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']>,\n P\n > => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,mBAA2B;AAC3B,8BAAsC;AAmB/B,MAAM,UAAU,CACrB,WACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAG/B,MAAI;AAKJ,QAAM,IAAI,CACR,SAIG;AACH,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAC3B,gBAAU,UAAU,GAAG;AACvB,UAAI,YAAY,QAAW;AAEzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -22,18 +22,12 @@ __export(useIntlayer_exports, {
22
22
  useIntlayer: () => useIntlayer
23
23
  });
24
24
  module.exports = __toCommonJS(useIntlayer_exports);
25
- var import_editor_react = require("@intlayer/editor-react");
26
25
  var import_react = require("react");
27
- var import_getDictionary = require('../getDictionary.cjs');
28
26
  var import_getIntlayer = require('../getIntlayer.cjs');
29
27
  var import_IntlayerProvider = require('./IntlayerProvider.cjs');
30
28
  const useIntlayer = (key, locale) => {
31
29
  const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
32
- const { changedContent } = (0, import_editor_react.useChangedContent)();
33
30
  const localeTarget = locale ?? currentLocale;
34
- if (changedContent?.[key]) {
35
- return (0, import_getDictionary.getDictionary)(changedContent?.[key], localeTarget);
36
- }
37
31
  return (0, import_getIntlayer.getIntlayer)(key, localeTarget);
38
32
  };
39
33
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const { changedContent } = useChangedContent();\n const localeTarget = locale ?? currentLocale;\n\n if (changedContent?.[key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[key], localeTarget);\n }\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAkC;AAGlC,mBAA2B;AAC3B,2BAA8B;AAC9B,yBAA4B;AAE5B,8BAAsC;AAO/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,EAAE,eAAe,QAAI,uCAAkB;AAC7C,QAAM,eAAe,UAAU;AAE/B,MAAI,iBAAiB,GAAG,GAAG;AAEzB,eAAO,oCAAc,iBAAiB,GAAG,GAAG,YAAY;AAAA,EAC1D;AAEA,aAAO,gCAAY,KAAK,YAAY;AACtC;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n *\n * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getIntlayer(key, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,mBAA2B;AAC3B,yBAA4B;AAE5B,8BAAsC;AAS/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,aAAO,gCAAY,KAAK,YAAY;AACtC;","names":[]}
@@ -34,6 +34,7 @@ const ContentSelectorWrapperContent = ({
34
34
  keyPath
35
35
  }) => {
36
36
  const { focusedContent, setFocusedContent } = (0, import_editor_react.useFocusDictionary)();
37
+ const { postMessage, senderId } = (0, import_editor_react.useCommunicator)();
37
38
  const handleSelect = (0, import_react.useCallback)(
38
39
  () => setFocusedContent({
39
40
  dictionaryKey,
@@ -41,11 +42,39 @@ const ContentSelectorWrapperContent = ({
41
42
  }),
42
43
  [dictionaryKey, keyPath]
43
44
  );
45
+ const handleHover = (0, import_react.useCallback)(
46
+ () => postMessage({
47
+ type: `${import_editor_react.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
48
+ data: {
49
+ dictionaryKey,
50
+ keyPath
51
+ },
52
+ senderId
53
+ }),
54
+ [dictionaryKey, keyPath]
55
+ );
56
+ const handleUnhover = (0, import_react.useCallback)(
57
+ () => postMessage({
58
+ type: `${import_editor_react.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
59
+ data: null,
60
+ senderId
61
+ }),
62
+ [senderId]
63
+ );
44
64
  const isSelected = (0, import_react.useMemo)(
45
65
  () => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && (0, import_core.isSameKeyPath)(focusedContent?.keyPath ?? [], keyPath)) ?? false,
46
66
  [focusedContent, keyPath, dictionaryKey]
47
67
  );
48
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentSelector.ContentSelector, { onPress: handleSelect, isSelecting: isSelected, children });
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_ContentSelector.ContentSelector,
70
+ {
71
+ onPress: handleSelect,
72
+ onHover: handleHover,
73
+ onUnhover: handleUnhover,
74
+ isSelecting: isSelected,
75
+ children
76
+ }
77
+ );
49
78
  };
50
79
  const ContentSelectorRenderer = ({
51
80
  children,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport { useFocusDictionary, useEditorEnabled } from '@intlayer/editor-react';\nimport { type HTMLAttributes, useCallback, useMemo, type FC } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath]\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, dictionaryKey]\n );\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected}>\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCI;AAnCJ,kBAA8C;AAC9C,0BAAqD;AACrD,mBAAmE;AACnE,oBAAmC;AACnC,6BAAgC;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,QAAI,wCAAmB;AAEjE,QAAM,mBAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;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,SAAS,aAAa;AAAA,EACzC;AAEA,SACE,4CAAC,0CAAgB,SAAS,cAAc,aAAa,YAClD,UACH;AAEJ;AAEO,MAAM,0BAA2D,CAAC;AAAA,EACvE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AACrC,QAAM,EAAE,cAAc,QAAI,kCAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,4CAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n MessageKey,\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { type FC, type HTMLAttributes, useCallback, useMemo } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { postMessage, senderId } = useCommunicator();\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath]\n );\n\n const handleHover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: {\n dictionaryKey,\n keyPath,\n },\n senderId,\n }),\n [dictionaryKey, keyPath]\n );\n\n const handleUnhover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n }),\n [senderId]\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, dictionaryKey]\n );\n\n return (\n <ContentSelector\n onPress={handleSelect}\n onHover={handleHover}\n onUnhover={handleUnhover}\n isSelecting={isSelected}\n >\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkEI;AAhEJ,kBAA8C;AAC9C,0BAKO;AACP,mBAAmE;AACnE,oBAAmC;AACnC,6BAAgC;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,QAAI,wCAAmB;AACjE,QAAM,EAAE,aAAa,SAAS,QAAI,qCAAgB;AAElD,QAAM,mBAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;AAEA,QAAM,kBAAc;AAAA,IAClB,MACE,YAAY;AAAA,MACV,MAAM,GAAG,+BAAW,gCAAgC;AAAA,MACpD,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;AAEA,QAAM,oBAAgB;AAAA,IACpB,MACE,YAAY;AAAA,MACV,MAAM,GAAG,+BAAW,gCAAgC;AAAA,MACpD,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,IACH,CAAC,QAAQ;AAAA,EACX;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,SAAS,aAAa;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MAEZ;AAAA;AAAA,EACH;AAEJ;AAEO,MAAM,0BAA2D,CAAC;AAAA,EACvE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AACrC,QAAM,EAAE,cAAc,QAAI,kCAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,4CAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
@@ -33,10 +33,8 @@ __export(IntlayerEditorProvider_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(IntlayerEditorProvider_exports);
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_api = require("@intlayer/api");
37
36
  var import_built = __toESM(require("@intlayer/config/built"));
38
37
  var import_editor_react = require("@intlayer/editor-react");
39
- var import_react = require("react");
40
38
  const IntlayerEditorHooksEnabled = () => {
41
39
  (0, import_editor_react.useCrossURLPathSetter)();
42
40
  (0, import_editor_react.useIframeClickInterceptor)();
@@ -45,21 +43,6 @@ const IntlayerEditorHooksEnabled = () => {
45
43
  const { editor } = import_built.default;
46
44
  const IntlayerEditorHook = () => {
47
45
  const { enabled } = (0, import_editor_react.useEditorEnabled)();
48
- const { setChangedContent } = (0, import_editor_react.useChangedContentActions)();
49
- (0, import_react.useEffect)(() => {
50
- if (!editor.hotReload) return;
51
- if (!editor.clientId) return;
52
- if (!editor.clientSecret) return;
53
- const eventSource = new import_api.IntlayerEventListener();
54
- try {
55
- eventSource.initialize().then(() => {
56
- eventSource.onDictionaryChange = (dictionary) => setChangedContent(dictionary.key, dictionary.content);
57
- });
58
- } catch (error) {
59
- console.error("Error initializing IntlayerEventListener:", error);
60
- }
61
- return () => eventSource.cleanup();
62
- }, []);
63
46
  return enabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorHooksEnabled, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
64
47
  };
65
48
  const IntlayerEditorProvider = ({ children }) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useChangedContentActions,\n useCrossURLPathSetter,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener();\n try {\n eventSource.initialize().then(() => {\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n });\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n\n return () => eventSource.cleanup();\n }, []);\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\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 }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBS;AAtBT,iBAAsC;AACtC,mBAA0B;AAC1B,0BAMO;AACP,mBAA2D;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,iDAAsB;AAKtB,qDAA0B;AAE1B,SAAO,2EAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI,aAAAA;AAEnB,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AAKrC,QAAM,EAAE,kBAAkB,QAAI,8CAAyB;AAEvD,8BAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,UAAM,cAAc,IAAI,iCAAsB;AAC9C,QAAI;AACF,kBAAY,WAAW,EAAE,KAAK,MAAM;AAClC,oBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAAA,MACxD,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,6CAA6C,KAAK;AAAA,IAClE;AAEA,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,UAAU,4CAAC,8BAA2B,IAAK,2EAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,cAAM,aAAa,OAAO,SAAS,OAAO;AAC1C,YAAI,CAAC,WAAY;AAEjB,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL,eAAe,aAAAA;AAAA,MAEf;AAAA,oDAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["configuration"]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useCrossURLPathSetter,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\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 }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBS;AApBT,mBAA0B;AAC1B,0BAKO;AAGP,MAAM,6BAAiC,MAAM;AAI3C,iDAAsB;AAKtB,qDAA0B;AAE1B,SAAO,2EAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI,aAAAA;AAEnB,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,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,cAAM,aAAa,OAAO,SAAS,OAAO;AAC1C,YAAI,CAAC,WAAY;AAEjB,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL,eAAe,aAAAA;AAAA,MAEf;AAAA,oDAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["configuration"]}
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  useDictionary: () => import_client.useDictionary,
30
30
  useDictionaryAsync: () => import_client.useDictionaryAsync,
31
31
  useDictionaryDynamic: () => import_client.useDictionaryDynamic,
32
+ useI18n: () => import_client.useI18n,
32
33
  useIntlayer: () => import_client.useIntlayer,
33
34
  useIntlayerAsync: () => import_client.useIntlayerAsync,
34
35
  useIntlayerContext: () => import_client.useIntlayerContext,
@@ -53,6 +54,7 @@ var import_markdown = require('./markdown/index.cjs');
53
54
  useDictionary,
54
55
  useDictionaryAsync,
55
56
  useDictionaryDynamic,
57
+ useI18n,
56
58
  useIntlayer,
57
59
  useIntlayerAsync,
58
60
  useIntlayerContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n getBrowserLocale,\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n localeCookie,\n setLocaleCookie,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useIntlayer,\n useIntlayerAsync,\n useIntlayerContext,\n useLoadDynamic,\n useLocale,\n useLocaleBase,\n useLocaleCookie,\n type IntlayerProviderProps,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAmBO;AAEP,sBAAiC;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n getBrowserLocale,\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n localeCookie,\n setLocaleCookie,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useIntlayerAsync,\n useIntlayerContext,\n useLoadDynamic,\n useLocale,\n useLocaleBase,\n useLocaleCookie,\n type IntlayerProviderProps,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAoBO;AAEP,sBAAiC;","names":[]}
@@ -25,6 +25,7 @@ __export(server_exports, {
25
25
  useDictionary: () => import_useDictionary.useDictionary,
26
26
  useDictionaryAsync: () => import_useDictionaryAsync.useDictionaryAsync,
27
27
  useDictionaryDynamic: () => import_useDictionaryDynamic.useDictionaryDynamic,
28
+ useI18n: () => import_useI18n.useI18n,
28
29
  useIntlayer: () => import_useIntlayer.useIntlayer,
29
30
  useLoadDynamic: () => import_useLoadDynamic.useLoadDynamic,
30
31
  useLocale: () => import_useLocale.useLocale
@@ -35,6 +36,7 @@ var import_t = require('./t.cjs');
35
36
  var import_useDictionary = require('./useDictionary.cjs');
36
37
  var import_useDictionaryAsync = require('./useDictionaryAsync.cjs');
37
38
  var import_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
39
+ var import_useI18n = require('./useI18n.cjs');
38
40
  var import_useIntlayer = require('./useIntlayer.cjs');
39
41
  var import_useLoadDynamic = require('./useLoadDynamic.cjs');
40
42
  var import_useLocale = require('./useLocale.cjs');
@@ -47,6 +49,7 @@ var import_useLocale = require('./useLocale.cjs');
47
49
  useDictionary,
48
50
  useDictionaryAsync,
49
51
  useDictionaryDynamic,
52
+ useI18n,
50
53
  useIntlayer,
51
54
  useLoadDynamic,
52
55
  useLocale
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServerContext as IntlayerServer,\n IntlayerServerProvider,\n locale,\n} from './IntlayerServerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useIntlayer } from './useIntlayer';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAIO;AACP,eAAkB;AAClB,2BAA8B;AAC9B,gCAAmC;AACnC,kCAAqC;AACrC,yBAA4B;AAC5B,4BAA+B;AAC/B,uBAA0B;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServerContext as IntlayerServer,\n IntlayerServerProvider,\n locale,\n} from './IntlayerServerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useI18n } from './useI18n';\nexport { useIntlayer } from './useIntlayer';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAIO;AACP,eAAkB;AAClB,2BAA8B;AAC9B,gCAAmC;AACnC,kCAAqC;AACrC,qBAAwB;AACxB,yBAA4B;AAC5B,4BAA+B;AAC/B,uBAA0B;","names":[]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useI18n_exports = {};
20
+ __export(useI18n_exports, {
21
+ useI18n: () => useI18n
22
+ });
23
+ module.exports = __toCommonJS(useI18n_exports);
24
+ var import_getIntlayer = require('../getIntlayer.cjs');
25
+ var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
26
+ var import_serverContext = require('./serverContext.cjs');
27
+ const useI18n = (namespace, locale) => {
28
+ const localeTarget = locale ?? (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
29
+ const dictionaryContent = (0, import_getIntlayer.getIntlayer)(namespace, localeTarget);
30
+ const t = (path) => {
31
+ if (!path) {
32
+ return dictionaryContent;
33
+ }
34
+ const pathArray = path.split(".");
35
+ let current = dictionaryContent;
36
+ for (const key of pathArray) {
37
+ current = current?.[key];
38
+ if (current === void 0) {
39
+ return dictionaryContent;
40
+ }
41
+ }
42
+ return current;
43
+ };
44
+ return t;
45
+ };
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ useI18n
49
+ });
50
+ //# sourceMappingURL=useI18n.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/useI18n.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type {\n DictionaryKeys,\n GetSubPath,\n ValidDotPathsFor,\n} from '@intlayer/core';\nimport type { DeepTransformContent } from '../plugins';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n // Get the dictionary content for the namespace\n const dictionaryContent = getIntlayer(namespace, localeTarget);\n\n // Return the translation function\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']>,\n P\n > => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,yBAA4B;AAC5B,oCAAsC;AACtC,2BAAiC;AAiB1B,MAAM,UAAU,CACrB,WACA,WACG;AACH,QAAM,eACJ,cAAU,uCAAgC,mDAAqB;AAGjE,QAAM,wBAAoB,gCAAY,WAAW,YAAY;AAG7D,QAAM,IAAI,CACR,SAIG;AACH,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAC3B,gBAAU,UAAU,GAAG;AACvB,UAAI,YAAY,QAAW;AAEzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -9,7 +9,9 @@ import {
9
9
  const DEFAULT_PRESS_DETECT_DURATION = 250;
10
10
  const ContentSelector = ({
11
11
  children,
12
- onPress: onSelect,
12
+ onPress,
13
+ onHover,
14
+ onUnhover,
13
15
  onClickOutside: onUnselect,
14
16
  pressDuration = DEFAULT_PRESS_DETECT_DURATION,
15
17
  isSelecting: isSelectingProp,
@@ -22,7 +24,7 @@ const ContentSelector = ({
22
24
  const isChildrenString = typeof children === "string";
23
25
  const handleOnLongPress = () => {
24
26
  setIsSelectingState(true);
25
- onSelect();
27
+ onPress();
26
28
  };
27
29
  const startPressTimer = () => {
28
30
  pressTimerRef.current = setTimeout(() => {
@@ -41,8 +43,10 @@ const ContentSelector = ({
41
43
  };
42
44
  const handleMouseEnter = () => {
43
45
  setIsHovered(true);
46
+ onHover?.();
44
47
  };
45
48
  const handleMouseUp = () => {
49
+ onUnhover?.();
46
50
  setIsHovered(false);
47
51
  clearPressTimer();
48
52
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\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} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\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 const isChildrenString = typeof children === 'string';\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: isChildrenString ? 'inline' : 'inline-block',\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":";AAsGI;AApGJ;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;AACvE,QAAM,mBAAmB,OAAO,aAAa;AAE7C,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,mBAAmB,WAAW;AAAA,QACvC,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 useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\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 const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\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 onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\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: isChildrenString ? 'inline' : 'inline-block',\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":";AA4GI;AA1GJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,gCAAgC;AAW/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,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;AACvE,QAAM,mBAAmB,OAAO,aAAa;AAE7C,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,YAAQ;AAAA,EACV;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;AACjB,cAAU;AAAA,EACZ;AAEA,QAAM,gBAAgB,MAAM;AAC1B,gBAAY;AACZ,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,mBAAmB,WAAW;AAAA,QACvC,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":[]}
@@ -9,6 +9,7 @@ import { t } from "./t.mjs";
9
9
  import { useDictionary } from "./useDictionary.mjs";
10
10
  import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
11
11
  import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
12
+ import { useI18n } from "./useI18n.mjs";
12
13
  import { useIntlayer } from "./useIntlayer.mjs";
13
14
  import { useIntlayerAsync } from "./useIntlayerAsync.mjs";
14
15
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
@@ -30,6 +31,7 @@ export {
30
31
  useDictionary,
31
32
  useDictionaryAsync,
32
33
  useDictionaryDynamic,
34
+ useI18n,
33
35
  useIntlayer,
34
36
  useIntlayerAsync,
35
37
  useIntlayerContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { getBrowserLocale } from './getBrowserLocale';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n type IntlayerProviderProps,\n} from './IntlayerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\nexport { useLocaleBase } from './useLocaleBase';\nexport {\n localeCookie,\n setLocaleCookie,\n useLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS;AAClB,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { getBrowserLocale } from './getBrowserLocale';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n type IntlayerProviderProps,\n} from './IntlayerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useI18n } from './useI18n';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\nexport { useLocaleBase } from './useLocaleBase';\nexport {\n localeCookie,\n setLocaleCookie,\n useLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS;AAClB,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -1,15 +1,10 @@
1
1
  "use client";
2
- import { useChangedContent } from "@intlayer/editor-react";
3
2
  import { useContext } from "react";
4
3
  import { getDictionary } from "../getDictionary.mjs";
5
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
6
5
  const useDictionary = (dictionary, locale) => {
7
6
  const { locale: currentLocale } = useContext(IntlayerClientContext);
8
7
  const localeTarget = locale ?? currentLocale;
9
- const { changedContent } = useChangedContent();
10
- if (changedContent?.[dictionary.key]) {
11
- return getDictionary(changedContent?.[dictionary.key], localeTarget);
12
- }
13
8
  return getDictionary(dictionary, localeTarget);
14
9
  };
15
10
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const { changedContent } = useChangedContent();\n\n if (changedContent?.[dictionary.key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[dictionary.key], localeTarget);\n }\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAE7C,MAAI,iBAAiB,WAAW,GAAG,GAAG;AAEpC,WAAO,cAAc,iBAAiB,WAAW,GAAG,GAAG,YAAY;AAAA,EACrE;AAEA,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useContext } from "react";
3
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
4
+ const useI18n = (namespace, locale) => {
5
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
6
+ const localeTarget = locale ?? currentLocale;
7
+ let dictionaryContent;
8
+ const t = (path) => {
9
+ if (!path) {
10
+ return dictionaryContent;
11
+ }
12
+ const pathArray = path.split(".");
13
+ let current = dictionaryContent;
14
+ for (const key of pathArray) {
15
+ current = current?.[key];
16
+ if (current === void 0) {
17
+ return dictionaryContent;
18
+ }
19
+ }
20
+ return current;
21
+ };
22
+ return t;
23
+ };
24
+ export {
25
+ useI18n
26
+ };
27
+ //# sourceMappingURL=useI18n.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n DictionaryKeys,\n GetSubPath,\n ValidDotPathsFor,\n} from '@intlayer/core';\nimport type { DeepTransformContent } from '../plugins';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n // Get the dictionary content for the namespace\n let dictionaryContent: DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n\n // Return the translation function\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']>,\n P\n > => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";AAWA,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAmB/B,MAAM,UAAU,CACrB,WACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAG/B,MAAI;AAKJ,QAAM,IAAI,CACR,SAIG;AACH,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAC3B,gBAAU,UAAU,GAAG;AACvB,UAAI,YAAY,QAAW;AAEzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1,16 +1,10 @@
1
1
  "use client";
2
- import { useChangedContent } from "@intlayer/editor-react";
3
2
  import { useContext } from "react";
4
- import { getDictionary } from "../getDictionary.mjs";
5
3
  import { getIntlayer } from "../getIntlayer.mjs";
6
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
7
5
  const useIntlayer = (key, locale) => {
8
6
  const { locale: currentLocale } = useContext(IntlayerClientContext);
9
- const { changedContent } = useChangedContent();
10
7
  const localeTarget = locale ?? currentLocale;
11
- if (changedContent?.[key]) {
12
- return getDictionary(changedContent?.[key], localeTarget);
13
- }
14
8
  return getIntlayer(key, localeTarget);
15
9
  };
16
10
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const { changedContent } = useChangedContent();\n const localeTarget = locale ?? currentLocale;\n\n if (changedContent?.[key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[key], localeTarget);\n }\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,yBAAyB;AAGlC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AAO/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAC7C,QAAM,eAAe,UAAU;AAE/B,MAAI,iBAAiB,GAAG,GAAG;AAEzB,WAAO,cAAc,iBAAiB,GAAG,GAAG,YAAY;AAAA,EAC1D;AAEA,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n *\n * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getIntlayer(key, localeTarget) as any;\n};\n"],"mappings":";AAMA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AAS/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
@@ -1,7 +1,12 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { isSameKeyPath } from "@intlayer/core";
4
- import { useFocusDictionary, useEditorEnabled } from "@intlayer/editor-react";
4
+ import {
5
+ MessageKey,
6
+ useCommunicator,
7
+ useEditorEnabled,
8
+ useFocusDictionary
9
+ } from "@intlayer/editor-react";
5
10
  import { useCallback, useMemo } from "react";
6
11
  import { useIntlayerContext } from "../client/index.mjs";
7
12
  import { ContentSelector } from "../UI/ContentSelector.mjs";
@@ -11,6 +16,7 @@ const ContentSelectorWrapperContent = ({
11
16
  keyPath
12
17
  }) => {
13
18
  const { focusedContent, setFocusedContent } = useFocusDictionary();
19
+ const { postMessage, senderId } = useCommunicator();
14
20
  const handleSelect = useCallback(
15
21
  () => setFocusedContent({
16
22
  dictionaryKey,
@@ -18,11 +24,39 @@ const ContentSelectorWrapperContent = ({
18
24
  }),
19
25
  [dictionaryKey, keyPath]
20
26
  );
27
+ const handleHover = useCallback(
28
+ () => postMessage({
29
+ type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
30
+ data: {
31
+ dictionaryKey,
32
+ keyPath
33
+ },
34
+ senderId
35
+ }),
36
+ [dictionaryKey, keyPath]
37
+ );
38
+ const handleUnhover = useCallback(
39
+ () => postMessage({
40
+ type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
41
+ data: null,
42
+ senderId
43
+ }),
44
+ [senderId]
45
+ );
21
46
  const isSelected = useMemo(
22
47
  () => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ?? false,
23
48
  [focusedContent, keyPath, dictionaryKey]
24
49
  );
25
- return /* @__PURE__ */ jsx(ContentSelector, { onPress: handleSelect, isSelecting: isSelected, children });
50
+ return /* @__PURE__ */ jsx(
51
+ ContentSelector,
52
+ {
53
+ onPress: handleSelect,
54
+ onHover: handleHover,
55
+ onUnhover: handleUnhover,
56
+ isSelecting: isSelected,
57
+ children
58
+ }
59
+ );
26
60
  };
27
61
  const ContentSelectorRenderer = ({
28
62
  children,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport { useFocusDictionary, useEditorEnabled } from '@intlayer/editor-react';\nimport { type HTMLAttributes, useCallback, useMemo, type FC } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath]\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, dictionaryKey]\n );\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected}>\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";AAqCI;AAnCJ,SAAyB,qBAAqB;AAC9C,SAAS,oBAAoB,wBAAwB;AACrD,SAA8B,aAAa,eAAwB;AACnE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AAEjE,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;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,SAAS,aAAa;AAAA,EACzC;AAEA,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAClD,UACH;AAEJ;AAEO,MAAM,0BAA2D,CAAC;AAAA,EACvE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,cAAc,IAAI,mBAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n MessageKey,\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { type FC, type HTMLAttributes, useCallback, useMemo } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { postMessage, senderId } = useCommunicator();\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath]\n );\n\n const handleHover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: {\n dictionaryKey,\n keyPath,\n },\n senderId,\n }),\n [dictionaryKey, keyPath]\n );\n\n const handleUnhover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n }),\n [senderId]\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, dictionaryKey]\n );\n\n return (\n <ContentSelector\n onPress={handleSelect}\n onHover={handleHover}\n onUnhover={handleUnhover}\n isSelecting={isSelected}\n >\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";AAkEI;AAhEJ,SAAyB,qBAAqB;AAC9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAuC,aAAa,eAAe;AACnE,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,aAAa,SAAS,IAAI,gBAAgB;AAElD,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,YAAY;AAAA,MACV,MAAM,GAAG,WAAW,gCAAgC;AAAA,MACpD,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,OAAO;AAAA,EACzB;AAEA,QAAM,gBAAgB;AAAA,IACpB,MACE,YAAY;AAAA,MACV,MAAM,GAAG,WAAW,gCAAgC;AAAA,MACpD,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,IACH,CAAC,QAAQ;AAAA,EACX;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,SAAS,aAAa;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MAEZ;AAAA;AAAA,EACH;AAEJ;AAEO,MAAM,0BAA2D,CAAC;AAAA,EACvE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,cAAc,IAAI,mBAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
@@ -1,15 +1,12 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { IntlayerEventListener } from "@intlayer/api";
4
3
  import configuration from "@intlayer/config/built";
5
4
  import {
6
5
  EditorProvider,
7
- useChangedContentActions,
8
6
  useCrossURLPathSetter,
9
7
  useEditorEnabled,
10
8
  useIframeClickInterceptor
11
9
  } from "@intlayer/editor-react";
12
- import { useEffect } from "react";
13
10
  const IntlayerEditorHooksEnabled = () => {
14
11
  useCrossURLPathSetter();
15
12
  useIframeClickInterceptor();
@@ -18,21 +15,6 @@ const IntlayerEditorHooksEnabled = () => {
18
15
  const { editor } = configuration;
19
16
  const IntlayerEditorHook = () => {
20
17
  const { enabled } = useEditorEnabled();
21
- const { setChangedContent } = useChangedContentActions();
22
- useEffect(() => {
23
- if (!editor.hotReload) return;
24
- if (!editor.clientId) return;
25
- if (!editor.clientSecret) return;
26
- const eventSource = new IntlayerEventListener();
27
- try {
28
- eventSource.initialize().then(() => {
29
- eventSource.onDictionaryChange = (dictionary) => setChangedContent(dictionary.key, dictionary.content);
30
- });
31
- } catch (error) {
32
- console.error("Error initializing IntlayerEventListener:", error);
33
- }
34
- return () => eventSource.cleanup();
35
- }, []);
36
18
  return enabled ? /* @__PURE__ */ jsx(IntlayerEditorHooksEnabled, {}) : /* @__PURE__ */ jsx(Fragment, {});
37
19
  };
38
20
  const IntlayerEditorProvider = ({ children }) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useChangedContentActions,\n useCrossURLPathSetter,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener();\n try {\n eventSource.initialize().then(() => {\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n });\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n\n return () => eventSource.cleanup();\n }, []);\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\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 }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AAwBS,wBAoCL,YApCK;AAtBT,SAAS,6BAA6B;AACtC,OAAO,mBAAmB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,wBAAsB;AAKtB,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI;AAEnB,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAKrC,QAAM,EAAE,kBAAkB,IAAI,yBAAyB;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,UAAM,cAAc,IAAI,sBAAsB;AAC9C,QAAI;AACF,kBAAY,WAAW,EAAE,KAAK,MAAM;AAClC,oBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAAA,MACxD,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,6CAA6C,KAAK;AAAA,IAClE;AAEA,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,UAAU,oBAAC,8BAA2B,IAAK,gCAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,cAAM,aAAa,OAAO,SAAS,OAAO;AAC1C,YAAI,CAAC,WAAY;AAEjB,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useCrossURLPathSetter,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\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 }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AAsBS,wBAaL,YAbK;AApBT,OAAO,mBAAmB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,MAAM,6BAAiC,MAAM;AAI3C,wBAAsB;AAKtB,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI;AAEnB,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,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,cAAM,aAAa,OAAO,SAAS,OAAO;AAC1C,YAAI,CAAC,WAAY;AAEjB,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -9,6 +9,7 @@ import {
9
9
  useDictionary,
10
10
  useDictionaryAsync,
11
11
  useDictionaryDynamic,
12
+ useI18n,
12
13
  useIntlayer,
13
14
  useIntlayerAsync,
14
15
  useIntlayerContext,
@@ -30,6 +31,7 @@ export {
30
31
  useDictionary,
31
32
  useDictionaryAsync,
32
33
  useDictionaryDynamic,
34
+ useI18n,
33
35
  useIntlayer,
34
36
  useIntlayerAsync,
35
37
  useIntlayerContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n getBrowserLocale,\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n localeCookie,\n setLocaleCookie,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useIntlayer,\n useIntlayerAsync,\n useIntlayerContext,\n useLoadDynamic,\n useLocale,\n useLocaleBase,\n useLocaleCookie,\n type IntlayerProviderProps,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,wBAAwB;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n getBrowserLocale,\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n localeCookie,\n setLocaleCookie,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useIntlayerAsync,\n useIntlayerContext,\n useLoadDynamic,\n useLocale,\n useLocaleBase,\n useLocaleCookie,\n type IntlayerProviderProps,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,wBAAwB;","names":[]}
@@ -7,6 +7,7 @@ import { t } from "./t.mjs";
7
7
  import { useDictionary } from "./useDictionary.mjs";
8
8
  import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
9
9
  import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
10
+ import { useI18n } from "./useI18n.mjs";
10
11
  import { useIntlayer } from "./useIntlayer.mjs";
11
12
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
12
13
  import { useLocale } from "./useLocale.mjs";
@@ -18,6 +19,7 @@ export {
18
19
  useDictionary,
19
20
  useDictionaryAsync,
20
21
  useDictionaryDynamic,
22
+ useI18n,
21
23
  useIntlayer,
22
24
  useLoadDynamic,
23
25
  useLocale
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServerContext as IntlayerServer,\n IntlayerServerProvider,\n locale,\n} from './IntlayerServerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useIntlayer } from './useIntlayer';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\n"],"mappings":"AAAA;AAAA,EAC2B;AAAA,EACzB;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAClB,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServerContext as IntlayerServer,\n IntlayerServerProvider,\n locale,\n} from './IntlayerServerProvider';\nexport { t } from './t';\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryAsync } from './useDictionaryAsync';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useI18n } from './useI18n';\nexport { useIntlayer } from './useIntlayer';\nexport { useLoadDynamic } from './useLoadDynamic';\nexport { useLocale } from './useLocale';\n"],"mappings":"AAAA;AAAA,EAC2B;AAAA,EACzB;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAClB,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;","names":[]}
@@ -0,0 +1,26 @@
1
+ import { getIntlayer } from "../getIntlayer.mjs";
2
+ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
3
+ import { getServerContext } from "./serverContext.mjs";
4
+ const useI18n = (namespace, locale) => {
5
+ const localeTarget = locale ?? getServerContext(IntlayerServerContext);
6
+ const dictionaryContent = getIntlayer(namespace, localeTarget);
7
+ const t = (path) => {
8
+ if (!path) {
9
+ return dictionaryContent;
10
+ }
11
+ const pathArray = path.split(".");
12
+ let current = dictionaryContent;
13
+ for (const key of pathArray) {
14
+ current = current?.[key];
15
+ if (current === void 0) {
16
+ return dictionaryContent;
17
+ }
18
+ }
19
+ return current;
20
+ };
21
+ return t;
22
+ };
23
+ export {
24
+ useI18n
25
+ };
26
+ //# sourceMappingURL=useI18n.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/useI18n.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type {\n DictionaryKeys,\n GetSubPath,\n ValidDotPathsFor,\n} from '@intlayer/core';\nimport type { DeepTransformContent } from '../plugins';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n // Get the dictionary content for the namespace\n const dictionaryContent = getIntlayer(namespace, localeTarget);\n\n // Return the translation function\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']>,\n P\n > => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":"AASA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAiB1B,MAAM,UAAU,CACrB,WACA,WACG;AACH,QAAM,eACJ,UAAU,iBAAgC,qBAAqB;AAGjE,QAAM,oBAAoB,YAAY,WAAW,YAAY;AAG7D,QAAM,IAAI,CACR,SAIG;AACH,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAC3B,gBAAU,UAAU,GAAG;AACvB,UAAI,YAAY,QAAW;AAEzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,8 @@
1
1
  import { type FC, type HTMLAttributes } from 'react';
2
2
  type ContentSelectorProps = {
3
3
  onPress: () => void;
4
+ onHover?: () => void;
5
+ onUnhover?: () => void;
4
6
  onClickOutside?: () => void;
5
7
  pressDuration?: number;
6
8
  isSelecting?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.d.ts","sourceRoot":"","sources":["../../../src/UI/ContentSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AAIf,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;AAEpD,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAkHpD,CAAC"}
1
+ {"version":3,"file":"ContentSelector.d.ts","sourceRoot":"","sources":["../../../src/UI/ContentSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AAIf,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;AAEpD,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAsHpD,CAAC"}
@@ -4,6 +4,7 @@ export { t } from './t';
4
4
  export { useDictionary } from './useDictionary';
5
5
  export { useDictionaryAsync } from './useDictionaryAsync';
6
6
  export { useDictionaryDynamic } from './useDictionaryDynamic';
7
+ export { useI18n } from './useI18n';
7
8
  export { useIntlayer } from './useIntlayer';
8
9
  export { useIntlayerAsync } from './useIntlayerAsync';
9
10
  export { useLoadDynamic } from './useLoadDynamic';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
@@ -5,5 +5,5 @@ import type { Dictionary } from '@intlayer/core';
5
5
  *
6
6
  * If the locale is not provided, it will use the locale from the client context
7
7
  */
8
- export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => any;
8
+ export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<T["content"], import("../plugins").IInterpreterPluginState>;
9
9
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,QAYvB,CAAC"}
1
+ {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,8GAMvB,CAAC"}
@@ -5,5 +5,5 @@ import type { Dictionary, DictionaryKeys, LanguageContent } from '@intlayer/core
5
5
  *
6
6
  * If the locale is not provided, it will use the locale from the client context
7
7
  */
8
- export declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: LanguageContent<() => Promise<T>>, key: K, locale?: LocalesValues) => any;
8
+ export declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: LanguageContent<() => Promise<T>>, key: K, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<T["content"], import("../plugins").IInterpreterPluginState>;
9
9
  //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionaryDynamic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAMxB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,cAAc,EAExB,mBAAmB,eAAe,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EACpD,KAAK,CAAC,EACN,SAAS,aAAa,QAcvB,CAAC"}
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionaryDynamic.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAMxB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,cAAc,EAExB,mBAAmB,eAAe,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EACpD,KAAK,CAAC,EACN,SAAS,aAAa,8GAcvB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { DictionaryKeys, GetSubPath, ValidDotPathsFor } from '@intlayer/core';
3
+ import type { DeepTransformContent } from '../plugins';
4
+ import type { IntlayerDictionaryTypesConnector } from 'intlayer';
5
+ /**
6
+ * Hook that provides a translation function `t()` for accessing nested content by key.
7
+ * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.
8
+ *
9
+ * @param namespace - The dictionary key to scope translations to
10
+ * @param locale - Optional locale override. If not provided, uses the current context locale
11
+ * @returns A translation function `t(key)` that returns the translated content for the given key
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const t = useI18n('IndexPage');
16
+ * const title = t('title'); // Returns translated string for 'IndexPage.title'
17
+ * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'
18
+ * // For attributes like `aria-label`, use `.value` to get the plain string
19
+ * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'
20
+ * ```
21
+ */
22
+ export declare const useI18n: <T extends DictionaryKeys>(namespace: T, locale?: LocalesValues) => <P extends ValidDotPathsFor<T>>(path: P) => GetSubPath<DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>, P>;
23
+ //# sourceMappingURL=useI18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../../src/client/useI18n.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAIjE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,cAAc,EAC9C,WAAW,CAAC,EACZ,SAAS,aAAa,MAWX,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,QAChC,CAAC,KACN,UAAU,CACX,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EACpE,CAAC,CAqBJ,CAAC"}
@@ -6,6 +6,8 @@ import type { DeepTransformContent } from '../plugins';
6
6
  * On the client side, Hook that picking one dictionary by its key and return the content
7
7
  *
8
8
  * If the locale is not provided, it will use the locale from the client context
9
+ *
10
+ * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content
9
11
  */
10
12
  export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
11
13
  //# sourceMappingURL=useIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAIjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAClD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAWrE,CAAC"}
1
+ {"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAGjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAClD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAKrE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type NodeProps } from '@intlayer/core';
2
- import { type HTMLAttributes, type FC } from 'react';
2
+ import { type FC, type HTMLAttributes } from 'react';
3
3
  export type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
4
4
  export declare const ContentSelectorRenderer: FC<ContentSelectorWrapperProps>;
5
5
  //# sourceMappingURL=ContentSelectorWrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,KAAK,cAAc,EAAwB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3E,MAAM,MAAM,2BAA2B,GAAG,SAAS,GACjD,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC;AAkCnD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,2BAA2B,CAgBnE,CAAC"}
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAO/D,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,cAAc,EAAwB,MAAM,OAAO,CAAC;AAI3E,MAAM,MAAM,2BAA2B,GAAG,SAAS,GACjD,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC;AA+DnD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,2BAA2B,CAgBnE,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;AA+CnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAgDxD,CAAC"}
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAwBxD,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAgDxD,CAAC"}
@@ -3,7 +3,7 @@ declare module '@intlayer/core' {
3
3
  interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {
4
4
  }
5
5
  }
6
- export { getBrowserLocale, IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, localeCookie, setLocaleCookie, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useIntlayerAsync, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, type IntlayerProviderProps, } from './client/index';
6
+ export { getBrowserLocale, IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, localeCookie, setLocaleCookie, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntlayer, useIntlayerAsync, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, type IntlayerProviderProps, } from './client/index';
7
7
  export { type IntlayerNode } from './IntlayerNode';
8
8
  export { MarkdownProvider } from './markdown/index';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;KAAG;CACzE;AAED,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,CAAC,EACD,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;KAAG;CACzE;AAED,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,CAAC,EACD,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -3,6 +3,7 @@ export { t } from './t';
3
3
  export { useDictionary } from './useDictionary';
4
4
  export { useDictionaryAsync } from './useDictionaryAsync';
5
5
  export { useDictionaryDynamic } from './useDictionaryDynamic';
6
+ export { useI18n } from './useI18n';
6
7
  export { useIntlayer } from './useIntlayer';
7
8
  export { useLoadDynamic } from './useLoadDynamic';
8
9
  export { useLocale } from './useLocale';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,cAAc,EACvC,sBAAsB,EACtB,MAAM,GACP,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,cAAc,EACvC,sBAAsB,EACtB,MAAM,GACP,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { DictionaryKeys, GetSubPath, ValidDotPathsFor } from '@intlayer/core';
3
+ import type { DeepTransformContent } from '../plugins';
4
+ import type { IntlayerDictionaryTypesConnector } from 'intlayer';
5
+ /**
6
+ * Hook that provides a translation function `t()` for accessing nested content by key.
7
+ * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.
8
+ *
9
+ * @param namespace - The dictionary key to scope translations to
10
+ * @param locale - Optional locale override. If not provided, uses the current context locale
11
+ * @returns A translation function `t(key)` that returns the translated content for the given key
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const t = useI18n('IndexPage');
16
+ * const title = t('title'); // Returns translated string for 'IndexPage.title'
17
+ * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'
18
+ * ```
19
+ */
20
+ export declare const useI18n: <T extends DictionaryKeys>(namespace: T, locale?: LocalesValues) => <P extends ValidDotPathsFor<T>>(path: P) => GetSubPath<DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>, P>;
21
+ //# sourceMappingURL=useI18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../../src/server/useI18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAKjE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,cAAc,EAC9C,WAAW,CAAC,EACZ,SAAS,aAAa,MASX,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,QAChC,CAAC,KACN,UAAU,CACX,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EACpE,CAAC,CAqBJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "5.7.5",
3
+ "version": "5.7.6",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -69,11 +69,11 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "js-cookie": "^3.0.5",
72
- "@intlayer/api": "5.7.5",
73
- "@intlayer/config": "5.7.5",
74
- "@intlayer/core": "5.7.5",
75
- "@intlayer/dictionaries-entry": "5.7.5",
76
- "@intlayer/editor-react": "5.7.5"
72
+ "@intlayer/api": "5.7.6",
73
+ "@intlayer/config": "5.7.6",
74
+ "@intlayer/core": "5.7.6",
75
+ "@intlayer/dictionaries-entry": "5.7.6",
76
+ "@intlayer/editor-react": "5.7.6"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@craco/types": "^7.1.0",
@@ -95,17 +95,17 @@
95
95
  "@utils/ts-config": "1.0.4",
96
96
  "@utils/ts-config-types": "1.0.4",
97
97
  "@utils/tsup-config": "1.0.4",
98
- "@intlayer/backend": "5.7.5"
98
+ "@intlayer/backend": "5.7.6"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "react": ">=16.0.0",
102
102
  "react-dom": ">=16.0.0",
103
- "@intlayer/dictionaries-entry": "5.7.5",
104
- "@intlayer/editor-react": "5.7.5",
105
- "@intlayer/api": "5.7.5",
106
- "@intlayer/core": "5.7.5",
107
- "@intlayer/config": "5.7.5",
108
- "intlayer": "5.7.5"
103
+ "@intlayer/api": "5.7.6",
104
+ "@intlayer/core": "5.7.6",
105
+ "@intlayer/config": "5.7.6",
106
+ "@intlayer/editor-react": "5.7.6",
107
+ "@intlayer/dictionaries-entry": "5.7.6",
108
+ "intlayer": "5.7.6"
109
109
  },
110
110
  "engines": {
111
111
  "node": ">=14.18"