react-intlayer 8.5.1 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/cjs/client/IntlayerProvider.cjs +1 -1
  2. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/client/format/useCompact.cjs +1 -1
  4. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  5. package/dist/cjs/client/format/useCurrency.cjs +1 -1
  6. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  7. package/dist/cjs/client/format/useDate.cjs +1 -1
  8. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  9. package/dist/cjs/client/format/useIntl.cjs +1 -1
  10. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  11. package/dist/cjs/client/format/useList.cjs +1 -1
  12. package/dist/cjs/client/format/useList.cjs.map +1 -1
  13. package/dist/cjs/client/format/useNumber.cjs +1 -1
  14. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  15. package/dist/cjs/client/format/usePercentage.cjs +1 -1
  16. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  17. package/dist/cjs/client/format/useRelativeTime.cjs +1 -1
  18. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  19. package/dist/cjs/client/format/useUnit.cjs +1 -1
  20. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  21. package/dist/cjs/client/t.cjs +1 -1
  22. package/dist/cjs/client/t.cjs.map +1 -1
  23. package/dist/cjs/client/useDictionary.cjs +1 -1
  24. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  25. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  26. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  27. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  28. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  29. package/dist/cjs/client/useI18n.cjs +1 -1
  30. package/dist/cjs/client/useI18n.cjs.map +1 -1
  31. package/dist/cjs/client/useIntlayer.cjs +1 -1
  32. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  33. package/dist/cjs/client/useLocale.cjs +1 -1
  34. package/dist/cjs/client/useLocale.cjs.map +1 -1
  35. package/dist/cjs/client/useLocaleBase.cjs +1 -1
  36. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  37. package/dist/cjs/client/useLocaleStorage.cjs +3 -3
  38. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  39. package/dist/cjs/client/useTraduction.cjs +1 -1
  40. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  41. package/dist/cjs/editor/ContentSelector.cjs +1 -1
  42. package/dist/cjs/editor/useEditor.cjs +2 -2
  43. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  44. package/dist/cjs/html/HTMLRenderer.cjs +6 -14
  45. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  46. package/dist/cjs/html/HTMLRendererPlugin.cjs +3 -11
  47. package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
  48. package/dist/cjs/plugins.cjs +24 -18
  49. package/dist/cjs/plugins.cjs.map +1 -1
  50. package/dist/esm/client/IntlayerProvider.mjs +1 -1
  51. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  52. package/dist/esm/client/format/useCompact.mjs +1 -1
  53. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  54. package/dist/esm/client/format/useCurrency.mjs +1 -1
  55. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  56. package/dist/esm/client/format/useDate.mjs +1 -1
  57. package/dist/esm/client/format/useDate.mjs.map +1 -1
  58. package/dist/esm/client/format/useIntl.mjs +1 -1
  59. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  60. package/dist/esm/client/format/useList.mjs +1 -1
  61. package/dist/esm/client/format/useList.mjs.map +1 -1
  62. package/dist/esm/client/format/useNumber.mjs +1 -1
  63. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  64. package/dist/esm/client/format/usePercentage.mjs +1 -1
  65. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  66. package/dist/esm/client/format/useRelativeTime.mjs +1 -1
  67. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  68. package/dist/esm/client/format/useUnit.mjs +1 -1
  69. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  70. package/dist/esm/client/t.mjs +1 -1
  71. package/dist/esm/client/t.mjs.map +1 -1
  72. package/dist/esm/client/useDictionary.mjs +1 -1
  73. package/dist/esm/client/useDictionary.mjs.map +1 -1
  74. package/dist/esm/client/useDictionaryAsync.mjs +1 -1
  75. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  76. package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
  77. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  78. package/dist/esm/client/useI18n.mjs +1 -1
  79. package/dist/esm/client/useI18n.mjs.map +1 -1
  80. package/dist/esm/client/useIntlayer.mjs +1 -1
  81. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  82. package/dist/esm/client/useLocale.mjs +1 -1
  83. package/dist/esm/client/useLocale.mjs.map +1 -1
  84. package/dist/esm/client/useLocaleBase.mjs +1 -1
  85. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  86. package/dist/esm/client/useLocaleStorage.mjs +4 -4
  87. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  88. package/dist/esm/client/useTraduction.mjs +1 -1
  89. package/dist/esm/client/useTraduction.mjs.map +1 -1
  90. package/dist/esm/editor/ContentSelector.mjs +1 -1
  91. package/dist/esm/editor/useEditor.mjs +2 -2
  92. package/dist/esm/editor/useEditor.mjs.map +1 -1
  93. package/dist/esm/html/HTMLRenderer.mjs +7 -14
  94. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  95. package/dist/esm/html/HTMLRendererPlugin.mjs +4 -11
  96. package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
  97. package/dist/esm/plugins.mjs +24 -18
  98. package/dist/esm/plugins.mjs.map +1 -1
  99. package/dist/types/client/IntlayerProvider.d.ts +3 -3
  100. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  101. package/dist/types/client/format/useCompact.d.ts +2 -2
  102. package/dist/types/client/format/useCompact.d.ts.map +1 -1
  103. package/dist/types/client/format/useCurrency.d.ts +2 -2
  104. package/dist/types/client/format/useCurrency.d.ts.map +1 -1
  105. package/dist/types/client/format/useList.d.ts +2 -2
  106. package/dist/types/client/format/useList.d.ts.map +1 -1
  107. package/dist/types/client/format/useNumber.d.ts +3 -3
  108. package/dist/types/client/format/useNumber.d.ts.map +1 -1
  109. package/dist/types/client/format/usePercentage.d.ts +3 -3
  110. package/dist/types/client/format/usePercentage.d.ts.map +1 -1
  111. package/dist/types/client/format/useRelativeTime.d.ts +2 -2
  112. package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
  113. package/dist/types/client/format/useUnit.d.ts +2 -2
  114. package/dist/types/client/format/useUnit.d.ts.map +1 -1
  115. package/dist/types/client/t.d.ts.map +1 -1
  116. package/dist/types/client/useDictionary.d.ts +2 -2
  117. package/dist/types/client/useDictionary.d.ts.map +1 -1
  118. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  119. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  120. package/dist/types/client/useIntlayer.d.ts +3 -3
  121. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  122. package/dist/types/client/useLocale.d.ts.map +1 -1
  123. package/dist/types/client/useLocaleBase.d.ts +5 -5
  124. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  125. package/dist/types/client/useLocaleStorage.d.ts +5 -5
  126. package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
  127. package/dist/types/html/HTMLRenderer.d.ts +1 -106
  128. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  129. package/dist/types/html/HTMLRendererPlugin.d.ts +0 -5
  130. package/dist/types/html/HTMLRendererPlugin.d.ts.map +1 -1
  131. package/dist/types/index.d.ts +9 -9
  132. package/dist/types/index.d.ts.map +1 -1
  133. package/dist/types/plugins.d.ts.map +1 -1
  134. package/dist/types/server/IntlayerServerProvider.d.ts +2 -2
  135. package/dist/types/server/useDictionary.d.ts +2 -2
  136. package/dist/types/server/useDictionary.d.ts.map +1 -1
  137. package/dist/types/server/useDictionaryAsync.d.ts +2 -2
  138. package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
  139. package/dist/types/server/useDictionaryDynamic.d.ts +2 -2
  140. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  141. package/dist/types/server/useIntlayer.d.ts +3 -3
  142. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  143. package/package.json +11 -12
@@ -24,7 +24,7 @@ const IntlayerClientContext = (0, react.createContext)({
24
24
  *
25
25
  * @returns The current Intlayer context values.
26
26
  */
27
- const useIntlayerContext = () => (0, react.useContext)(IntlayerClientContext);
27
+ const useIntlayerContext = () => (0, react.useContext)(IntlayerClientContext) ?? {};
28
28
  /**
29
29
  * Provider that stores the current locale on the client side.
30
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,MAAa,iDAAqD;CAChE,QAAQA,mDAAmBC,gCAAe,sBAAsB;CAChE,iBAAiB;CACjB,iBAAiB;CAClB,CAAC;;;;;;AAOF,MAAa,iDAAsC,sBAAsB;;;;;;;;;AAoCzE,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyBA,kCAAiB,EAAE;CACpD,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,wCAFpB,cAAcD,mDAAmB,qBAAqB,oBAGhB;AAGxC,4BAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B,CAAC,WAAW,CAAC;CAEhB,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,qDAAmB,WAAW,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iEAAgC,cAAc;AAEpD,QACE,2CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,4CAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,2CAACE,8CAAD,EAAkB,GACjB,SACuB"}
1
+ {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,MAAa,iDAAqD;CAChE,QAAQA,mDAAmBC,gCAAe,sBAAsB;CAChE,iBAAiB;CACjB,iBAAiB;CAClB,CAAC;;;;;;AAOF,MAAa,iDAAsC,sBAAsB,IAAI,EAAE;;;;;;;;;AAoC/E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyBA,kCAAiB,EAAE;CACpD,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,wCAFpB,cAAcD,mDAAmB,qBAAqB,oBAGhB;AAGxC,4BAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B,CAAC,WAAW,CAAC;CAEhB,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,qDAAmB,WAAW,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iEAAgC,cAAc;AAEpD,QACE,2CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,4CAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,2CAACE,8CAAD,EAAkB,GACjB,SACuB"}
@@ -18,7 +18,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
18
18
  * ```
19
19
  */
20
20
  const useCompact = () => {
21
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
21
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
22
22
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.compact)(args[0], {
23
23
  ...args[1],
24
24
  locale: args[1]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,gDACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCompact.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,gDACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -32,7 +32,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
32
32
  * ```
33
33
  */
34
34
  const useCurrency = () => {
35
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
35
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
36
36
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.currency)(args[0], {
37
37
  ...args[1],
38
38
  locale: args[1]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,iDACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCurrency.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,iDACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -34,7 +34,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
34
34
  * @see createDate
35
35
  */
36
36
  const useDate = () => {
37
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
37
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
38
38
  return (...args) => {
39
39
  const options = typeof args[1] === "string" ? {
40
40
  ..._intlayer_core_formatters.presets[args[1]],
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.cjs","names":["IntlayerClientContext","presets"],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,SAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAa;GAAQ,GACvC;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,IAAI,UAAU;GAAQ;AAEvD,6CAAY,KAAK,IAAI,QAAsC"}
1
+ {"version":3,"file":"useDate.cjs","names":["IntlayerClientContext","presets"],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date, presets } from '@intlayer/core/formatters';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,SAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAa;GAAQ,GACvC;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,IAAI,UAAU;GAAQ;AAEvD,6CAAY,KAAK,IAAI,QAAsC"}
@@ -36,7 +36,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
36
36
  * ```
37
37
  */
38
38
  const useIntl = (locale) => {
39
- const { locale: contextLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
39
+ const { locale: contextLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
40
40
  const currentLocale = locale ?? contextLocale;
41
41
  return (0, react.useMemo)(() => (0, _intlayer_core_formatters.bindIntl)(currentLocale), [currentLocale]);
42
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;CACnE,MAAM,gBAAgB,UAAU;AAEhC,yEAA2C,cAAc,EAAE,CAAC,cAAc,CAAC"}
1
+ {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,gBAAgB,UAAU;AAEhC,yEAA2C,cAAc,EAAE,CAAC,cAAc,CAAC"}
@@ -29,7 +29,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
29
29
  * ```
30
30
  */
31
31
  const useList = () => {
32
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
32
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
33
33
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.list)(args[0], {
34
34
  ...args[1],
35
35
  locale: args[1]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"useList.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,6CACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useList.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,6CACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -30,7 +30,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
30
30
  * A number formatting function bound to the active locale.
31
31
  */
32
32
  const useNumber = () => {
33
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
33
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
34
34
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.number)(args[0], {
35
35
  ...args[1],
36
36
  locale: args[1]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"useNumber.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,+CACK,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useNumber.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,+CACK,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -26,7 +26,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
26
26
  * A function that formats numbers or numeric strings into localized percentages.
27
27
  */
28
28
  const usePercentage = () => {
29
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
29
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
30
30
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.percentage)(args[0], {
31
31
  ...args[1],
32
32
  locale: args[1]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"usePercentage.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,mDACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"usePercentage.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,mDACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -26,7 +26,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
26
26
  * bound to the current client locale.
27
27
  */
28
28
  const useRelativeTime = () => {
29
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
29
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
30
30
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.relativeTime)(args[0], args[1], {
31
31
  ...args[2],
32
32
  locale: args[2]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"useRelativeTime.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,qDACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useRelativeTime.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,qDACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -25,7 +25,7 @@ let _intlayer_core_formatters = require("@intlayer/core/formatters");
25
25
  * @returns {Function} A unit formatting function that accepts a value and optional formatting options.
26
26
  */
27
27
  const useUnit = () => {
28
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
28
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
29
29
  return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.units)(args[0], {
30
30
  ...args[1],
31
31
  locale: args[1]?.locale ?? locale
@@ -1 +1 @@
1
- {"version":3,"file":"useUnit.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,8CACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useUnit.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gCACG,GAAG,8CACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -32,7 +32,7 @@ let react = require("react");
32
32
  * ```
33
33
  */
34
34
  const t = (multilangContent, locale) => {
35
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
35
+ const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
36
36
  return (0, _intlayer_core_interpreter.getTranslation)(multilangContent, locale ?? currentLocale);
37
37
  };
38
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core/interpreter';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side translation function that returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param multilangContent - An object mapping locales to their respective content.\n * @param locale - Optional locale to override the current context locale.\n * @returns The translation for the specified locale.\n *\n * @example\n * ```tsx\n * import { t } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const greeting = t({\n * en: 'Hello',\n * fr: 'Bonjour',\n * es: 'Hola',\n * });\n *\n * return <h1>{greeting}</h1>;\n * };\n * ```\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;AAGnE,uDAA+B,kBAFV,UAAU,cAE+B"}
1
+ {"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core/interpreter';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side translation function that returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param multilangContent - An object mapping locales to their respective content.\n * @param locale - Optional locale to override the current context locale.\n * @returns The translation for the specified locale.\n *\n * @example\n * ```tsx\n * import { t } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const greeting = t({\n * en: 'Hello',\n * fr: 'Bonjour',\n * es: 'Hola',\n * });\n *\n * return <h1>{greeting}</h1>;\n * };\n * ```\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;AAGzE,uDAA+B,kBAFV,UAAU,cAE+B"}
@@ -13,7 +13,7 @@ let react = require("react");
13
13
  * If the locale is not provided, it will use the locale from the client context
14
14
  */
15
15
  const useDictionary = (dictionary, locale) => {
16
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
16
+ const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
17
17
  return (0, react.useMemo)(() => {
18
18
  return require_getDictionary.getDictionary(dictionary, locale ?? currentLocale);
19
19
  }, [
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } 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 = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;AAEnE,iCAAqB;AAGnB,SAAOC,oCAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC,WAAW;EAAK;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } 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 = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;AAEzE,iCAAqB;AAGnB,SAAOC,oCAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC,WAAW;EAAK;EAAe;EAAO,CAAC"}
@@ -15,7 +15,7 @@ let react = require("react");
15
15
  * If the locale is not provided, it will use the locale from the client context
16
16
  */
17
17
  const useDictionaryAsync = async (dictionaryPromise, locale) => {
18
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
18
+ const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
19
19
  const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.default?.internationalization.defaultLocale, [currentLocale, locale]);
20
20
  return require_client_useDictionary.useDictionary(await (0, react.useMemo)(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\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 useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,qBAAqB,OAIhC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;CAEnE,MAAM,wCAEF,UACA,iBACAC,gCAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CARY,yBACjB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEsC,aAAkB"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\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 useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,qBAAqB,OAIhC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,wCAEF,UACA,iBACAC,gCAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CARY,yBACjB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEsC,aAAkB"}
@@ -16,7 +16,7 @@ let react = require("react");
16
16
  * If the locale is not provided, it will use the locale from the client context
17
17
  */
18
18
  const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
19
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
19
+ const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
20
20
  const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.default?.internationalization.defaultLocale, [currentLocale, locale]);
21
21
  return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;CACnE,MAAM,wCAEF,UACA,iBACAC,gCAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,wCAEF,UACA,iBACAC,gCAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
@@ -25,7 +25,7 @@ let react = require("react");
25
25
  * ```
26
26
  */
27
27
  const useI18n = (namespace, locale) => {
28
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
28
+ const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
29
29
  const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale, [currentLocale, locale]);
30
30
  const dictionaryContent = (0, react.useMemo)(() => (0, _intlayer_core_interpreter.getIntlayer)(namespace, localeTarget), [namespace, localeTarget]);
31
31
  const t = (path) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport type { DeepTransformContent } from '../plugins';\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 = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n namespace: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>> =\n useMemo(\n () => getIntlayer<T, L>(namespace, localeTarget as L),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,WAIX,WACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;CACnE,MAAM,wCACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAID,MAAM,yFAEsB,WAAW,aAAkB,EACrD,CAAC,WAAW,aAAa,CAC1B;CAIH,MAAM,KACJ,SAEsE;AACtE,MAAI,CAAC,KAEH,QAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAI,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAC3B,aAAU,UAAU;AACpB,OAAI,YAAY,OAEd,QAAO;;AAIX,SAAO;;AAGT,QAAO"}
1
+ {"version":3,"file":"useI18n.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport type { DeepTransformContent } from '../plugins';\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 = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n namespace: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>> =\n useMemo(\n () => getIntlayer<T, L>(namespace, localeTarget as L),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,WAIX,WACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,wCACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAID,MAAM,yFAEsB,WAAW,aAAkB,EACrD,CAAC,WAAW,aAAa,CAC1B;CAIH,MAAM,KACJ,SAEsE;AACtE,MAAI,CAAC,KAEH,QAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAI,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAC3B,aAAU,UAAU;AACpB,OAAI,YAAY,OAEd,QAAO;;AAIX,SAAO;;AAGT,QAAO"}
@@ -28,7 +28,7 @@ let react = require("react");
28
28
  * ```
29
29
  */
30
30
  const useIntlayer = (key, locale) => {
31
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
31
+ const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
32
32
  return (0, react.useMemo)(() => {
33
33
  return require_getIntlayer.getIntlayer(key, locale ?? currentLocale);
34
34
  }, [
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The dictionary content for the specified locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,eAIX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;AAEnE,iCAAqB;AAGnB,SAAOC,gCAAkB,KAFJ,UAAW,cAEW;IAC1C;EAAC;EAAK;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The dictionary content for the specified locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,eAIX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB,IAAI,EAAE;AAEzE,iCAAqB;AAGnB,SAAOC,gCAAkB,KAFJ,UAAW,cAEW;IAC1C;EAAC;EAAK;EAAe;EAAO,CAAC"}
@@ -34,7 +34,7 @@ let react = require("react");
34
34
  */
35
35
  const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
36
36
  const { defaultLocale, locales: availableLocales } = _intlayer_config_built.default?.internationalization ?? {};
37
- const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
37
+ const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
38
38
  return {
39
39
  locale,
40
40
  defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["configuration","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\ntype UseLocaleResult = {\n locale: LocalesValues;\n defaultLocale: LocalesValues;\n availableLocales: LocalesValues[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Client-side hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'react-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext);\n\n const setLocale = useCallback(\n (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n onLocaleChange?.(locale as DeclaredLocales);\n },\n [availableLocales, onLocaleChange, setLocaleState, isCookieEnabled]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,gCAAe,wBAAwB,EAAE;CAE3C,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,iDACJC,sDAAsB;AAmBrC,QAAO;EACL;EACA;EACA;EACA,mCApBC,WAA0B;AACzB,OAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;AACnD,YAAQ,MAAM,UAAU,OAAO,mBAAmB;AAClD;;AAGF,kBAAe,OAAO;AACtB,sDACE,QACA,mBAAmB,0BAA0B,KAC9C;AACD,oBAAiB,OAA0B;KAE7C;GAAC;GAAkB;GAAgB;GAAgB;GAAgB,CACpE;EAOA"}
1
+ {"version":3,"file":"useLocale.cjs","names":["configuration","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\ntype UseLocaleResult = {\n locale: LocalesValues;\n defaultLocale: LocalesValues;\n availableLocales: LocalesValues[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Client-side hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'react-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = useCallback(\n (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n onLocaleChange?.(locale as DeclaredLocales);\n },\n [availableLocales, onLocaleChange, setLocaleState, isCookieEnabled]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,gCAAe,wBAAwB,EAAE;CAE3C,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,iDACJC,sDAAsB,IAAI,EAAE;AAmB3C,QAAO;EACL;EACA;EACA;EACA,mCApBC,WAA0B;AACzB,OAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;AACnD,YAAQ,MAAM,UAAU,OAAO,mBAAmB;AAClD;;AAGF,kBAAe,OAAO;AACtB,sDACE,QACA,mBAAmB,0BAA0B,KAC9C;AACD,oBAAiB,OAA0B;KAE7C;GAAC;GAAkB;GAAgB;GAAgB;GAAgB,CACpE;EAOA"}
@@ -13,7 +13,7 @@ const { defaultLocale, locales: availableLocales } = _intlayer_config_built.defa
13
13
  * On the client side, hook to get the current locale and all related fields
14
14
  */
15
15
  const useLocaleBase = () => {
16
- const { locale, setLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
16
+ const { locale, setLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
17
17
  return {
18
18
  locale,
19
19
  defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleBase.cjs","names":["configuration","IntlayerClientContext"],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;AAMA,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+BAAc;;;;AAKhB,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,oCAAyBC,sDAAsB;AAE/D,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocaleBase.cjs","names":["configuration","IntlayerClientContext"],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;AAMA,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+BAAc;;;;AAKhB,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,oCAAyBC,sDAAsB,IAAI,EAAE;AAErE,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -11,7 +11,7 @@ let _intlayer_core_utils = require("@intlayer/core/utils");
11
11
  /**
12
12
  * Get the locale cookie
13
13
  */
14
- const localeInStorage = (0, _intlayer_core_utils.getLocaleFromStorage)(_intlayer_core_localization.localeStorageOptions);
14
+ const localeInStorage = (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_localization.localeStorageOptions);
15
15
  /**
16
16
  * @deprecated Use localeInStorage instead
17
17
  *
@@ -21,7 +21,7 @@ const localeCookie = localeInStorage;
21
21
  /**
22
22
  * Set the locale cookie
23
23
  */
24
- const setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorage)(locale, {
24
+ const setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorageClient)(locale, {
25
25
  ..._intlayer_core_localization.localeStorageOptions,
26
26
  isCookieEnabled
27
27
  });
@@ -34,7 +34,7 @@ const setLocaleCookie = setLocaleInStorage;
34
34
  /**
35
35
  * Hook that provides the locale cookie and a function to set it
36
36
  */
37
- const useLocaleStorage = (isCookieEnabled) => (0, react.useMemo)(() => (0, _intlayer_core_utils.LocaleStorage)({
37
+ const useLocaleStorage = (isCookieEnabled) => (0, react.useMemo)(() => (0, _intlayer_core_utils.LocaleStorageClient)({
38
38
  ..._intlayer_core_localization.localeStorageOptions,
39
39
  isCookieEnabled
40
40
  }), [isCookieEnabled]);
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'react';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled?: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,iEAAuCA,iDAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,iEAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,qFAGb;CACZ,GAAGA;CACH;CACD,CAAC,EACJ,CAAC,gBAAgB,CAClB;;;;;;;;AASH,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
1
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'react';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled?: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,uEAA6CA,iDAAqB;;;;;;AAM/E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,uEAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,2FAGP;CAClB,GAAGA;CACH;CACD,CAAC,EACJ,CAAC,gBAAgB,CAClB;;;;;;;;AASH,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
@@ -27,7 +27,7 @@ let react = require("react");
27
27
  * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
28
28
  */
29
29
  const useTranslation = (languageContent) => {
30
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
30
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
31
31
  return (0, react.useMemo)(() => (0, _intlayer_core_interpreter.getTranslation)(languageContent, locale), [languageContent, locale]);
32
32
  };
33
33
 
@@ -1 +1 @@
1
- {"version":3,"file":"useTraduction.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gFACuB,iBAAiB,OAAO,EAC7C,CAAC,iBAAiB,OAAO,CAC1B"}
1
+ {"version":3,"file":"useTraduction.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;AAE1D,gFACuB,iBAAiB,OAAO,EAC7C,CAAC,iBAAiB,OAAO,CAC1B"}
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
6
5
  let react = require("react");
6
+ let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
7
7
 
8
8
  //#region src/editor/ContentSelector.tsx
9
9
  const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
5
  const require_client_IntlayerProvider = require('../client/IntlayerProvider.cjs');
6
- let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
7
6
  let react = require("react");
7
+ let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
8
8
 
9
9
  //#region src/editor/useEditor.tsx
10
10
  /**
@@ -13,7 +13,7 @@ let react = require("react");
13
13
  * the editor always knows which locale the app is displaying.
14
14
  */
15
15
  const useEditor = () => {
16
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
16
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
17
17
  const managerRef = (0, react.useRef)(null);
18
18
  (0, react.useEffect)(() => {
19
19
  if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return;
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext);\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,iCAAsBA,sDAAsB;CACpD,MAAM,+BAA+C,KAAK;AAE1D,4BAAgB;AACd,MAAI,QAAQ,IAAI,4BAA4B,WAAW,CAACC,qCAAW;AAEnE,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,4BAAgB;AACd,MAAI,CAAC,UAAU,CAAC,WAAW,QAAS;AAEpC,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initializes the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (!locale || !managerRef.current) return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,iCAAsBA,sDAAsB,IAAI,EAAE;CAC1D,MAAM,+BAA+C,KAAK;AAE1D,4BAAgB;AACd,MAAI,QAAQ,IAAI,4BAA4B,WAAW,CAACC,qCAAW;AAEnE,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AAErB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;IACvD;AAEF,eAAa;AACX,cAAW,UAAU;AACrB,UAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,sBAAkB;KAClB;;IAEH,EAAE,CAAC;AAEN,4BAAgB;AACd,MAAI,CAAC,UAAU,CAAC,WAAW,QAAS;AAEpC,aAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
@@ -6,27 +6,20 @@ const require_html_HTMLProvider = require('./HTMLProvider.cjs');
6
6
  let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
7
7
  let react = require("react");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
- let _intlayer_core_transpiler = require("@intlayer/core/transpiler");
10
9
 
11
10
  //#region src/html/HTMLRenderer.tsx
12
- const createDefaultHTMLComponents = () => {
13
- const components = {};
14
- for (const tag of _intlayer_core_transpiler.HTML_TAGS) components[tag] = ({ children, ...props }) => (0, react.createElement)(tag, props, children);
15
- return components;
16
- };
17
- const defaultHTMLComponents = createDefaultHTMLComponents();
18
11
  /**
19
12
  * Renders HTML-like content to JSX with the provided components.
20
13
  *
21
14
  * This function does not use context from HTMLProvider. Use `useHTMLRenderer`
22
15
  * hook if you want to leverage provider context.
23
16
  */
24
- const renderHTML = (content, { components } = {}) => {
25
- const mergedComponents = {
26
- ...defaultHTMLComponents,
27
- ...components
28
- };
29
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: (0, _intlayer_core_interpreter.getHTML)(content, Object.fromEntries(Object.entries(mergedComponents).filter(([, Component]) => Component).map(([key, Component]) => [key, (props) => (0, react.createElement)(Component, props)]))) });
17
+ const renderHTML = (content, { components = {} } = {}) => {
18
+ const userComponents = Object.fromEntries(Object.entries(components).filter(([, Component]) => Component).map(([key, Component]) => [key, (props) => (0, react.createElement)(Component, props)]));
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: (0, _intlayer_core_interpreter.getHTML)(content, new Proxy(userComponents, { get(target, prop) {
20
+ if (typeof prop === "string" && prop in target) return target[prop];
21
+ if (typeof prop === "string" && /^[a-z][a-z0-9]*$/.test(prop)) return (props) => (0, react.createElement)(prop, props);
22
+ } })) });
30
23
  };
31
24
  /**
32
25
  * Hook that returns a function to render HTML content.
@@ -55,7 +48,6 @@ const HTMLRenderer = ({ children = "", components }) => {
55
48
 
56
49
  //#endregion
57
50
  exports.HTMLRenderer = HTMLRenderer;
58
- exports.defaultHTMLComponents = defaultHTMLComponents;
59
51
  exports.renderHTML = renderHTML;
60
52
  exports.useHTMLRenderer = useHTMLRenderer;
61
53
  //# sourceMappingURL=HTMLRenderer.cjs.map