react-intlayer 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/dist/cjs/IntlayerNode.cjs +1 -17
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +1 -96
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  6. package/dist/cjs/client/IntlayerProvider.cjs +1 -92
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +1 -20
  9. package/dist/cjs/client/format/useCompact.cjs +1 -29
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +1 -43
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +1 -45
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useIntl.cjs +1 -45
  16. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  17. package/dist/cjs/client/format/useList.cjs +1 -40
  18. package/dist/cjs/client/format/useList.cjs.map +1 -1
  19. package/dist/cjs/client/format/useNumber.cjs +1 -41
  20. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  21. package/dist/cjs/client/format/usePercentage.cjs +1 -37
  22. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  23. package/dist/cjs/client/format/useRelativeTime.cjs +1 -37
  24. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  25. package/dist/cjs/client/format/useUnit.cjs +1 -36
  26. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  27. package/dist/cjs/client/index.cjs +1 -34
  28. package/dist/cjs/client/t.cjs +1 -40
  29. package/dist/cjs/client/t.cjs.map +1 -1
  30. package/dist/cjs/client/useDictionary.cjs +1 -27
  31. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
  33. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  34. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
  35. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  36. package/dist/cjs/client/useI18n.cjs +1 -45
  37. package/dist/cjs/client/useI18n.cjs.map +1 -1
  38. package/dist/cjs/client/useIntlayer.cjs +1 -42
  39. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  40. package/dist/cjs/client/useLoadDynamic.cjs +1 -27
  41. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  42. package/dist/cjs/client/useLocale.cjs +1 -60
  43. package/dist/cjs/client/useLocale.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleBase.cjs +1 -26
  45. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  46. package/dist/cjs/client/useLocaleStorage.cjs +1 -61
  47. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  48. package/dist/cjs/client/useRewriteURL.cjs +1 -42
  49. package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
  50. package/dist/cjs/client/useTraduction.cjs +1 -35
  51. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  52. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -55
  53. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  54. package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -61
  55. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  56. package/dist/cjs/editor/index.cjs +1 -4
  57. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -40
  58. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  59. package/dist/cjs/getDictionary.cjs +1 -19
  60. package/dist/cjs/getDictionary.cjs.map +1 -1
  61. package/dist/cjs/getIntlayer.cjs +1 -19
  62. package/dist/cjs/getIntlayer.cjs.map +1 -1
  63. package/dist/cjs/html/HTMLProvider.cjs +1 -18
  64. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  65. package/dist/cjs/html/HTMLRenderer.cjs +1 -59
  66. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  67. package/dist/cjs/html/HTMLRendererPlugin.cjs +1 -36
  68. package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
  69. package/dist/cjs/html/index.cjs +1 -12
  70. package/dist/cjs/index.cjs +1 -52
  71. package/dist/cjs/markdown/MarkdownProvider.cjs +1 -77
  72. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  73. package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -199
  74. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  75. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -33
  76. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  77. package/dist/cjs/markdown/index.cjs +1 -25
  78. package/dist/cjs/markdown/processor.cjs +1 -66
  79. package/dist/cjs/markdown/processor.cjs.map +1 -1
  80. package/dist/cjs/markdown/runtime.cjs +1 -43
  81. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  82. package/dist/cjs/plugins.cjs +1 -179
  83. package/dist/cjs/plugins.cjs.map +1 -1
  84. package/dist/cjs/reactElement/renderReactElement.cjs +1 -52
  85. package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
  86. package/dist/cjs/server/IntlayerServerProvider.cjs +1 -34
  87. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  88. package/dist/cjs/server/format/index.cjs +1 -18
  89. package/dist/cjs/server/format/useCompact.cjs +1 -27
  90. package/dist/cjs/server/format/useCompact.cjs.map +1 -1
  91. package/dist/cjs/server/format/useCurrency.cjs +1 -38
  92. package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
  93. package/dist/cjs/server/format/useDate.cjs +1 -43
  94. package/dist/cjs/server/format/useDate.cjs.map +1 -1
  95. package/dist/cjs/server/format/useIntl.cjs +1 -44
  96. package/dist/cjs/server/format/useIntl.cjs.map +1 -1
  97. package/dist/cjs/server/format/useList.cjs +1 -35
  98. package/dist/cjs/server/format/useList.cjs.map +1 -1
  99. package/dist/cjs/server/format/useNumber.cjs +1 -39
  100. package/dist/cjs/server/format/useNumber.cjs.map +1 -1
  101. package/dist/cjs/server/format/usePercentage.cjs +1 -35
  102. package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
  103. package/dist/cjs/server/format/useRelativeTime.cjs +1 -35
  104. package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
  105. package/dist/cjs/server/format/useUnit.cjs +1 -34
  106. package/dist/cjs/server/format/useUnit.cjs.map +1 -1
  107. package/dist/cjs/server/index.cjs +1 -24
  108. package/dist/cjs/server/serverContext.cjs +1 -58
  109. package/dist/cjs/server/serverContext.cjs.map +1 -1
  110. package/dist/cjs/server/t.cjs +1 -35
  111. package/dist/cjs/server/t.cjs.map +1 -1
  112. package/dist/cjs/server/useDictionary.cjs +1 -17
  113. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  114. package/dist/cjs/server/useDictionaryAsync.cjs +1 -21
  115. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  116. package/dist/cjs/server/useDictionaryDynamic.cjs +1 -22
  117. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  118. package/dist/cjs/server/useI18n.cjs +1 -38
  119. package/dist/cjs/server/useI18n.cjs.map +1 -1
  120. package/dist/cjs/server/useIntlayer.cjs +1 -17
  121. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  122. package/dist/cjs/server/useLoadDynamic.cjs +1 -14
  123. package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
  124. package/dist/cjs/server/useLocale.cjs +1 -24
  125. package/dist/cjs/server/useLocale.cjs.map +1 -1
  126. package/dist/esm/IntlayerNode.mjs +1 -15
  127. package/dist/esm/IntlayerNode.mjs.map +1 -1
  128. package/dist/esm/UI/ContentSelector.mjs +1 -94
  129. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  130. package/dist/esm/client/IntlayerProvider.mjs +1 -86
  131. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  132. package/dist/esm/client/format/index.mjs +1 -11
  133. package/dist/esm/client/format/useCompact.mjs +1 -27
  134. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  135. package/dist/esm/client/format/useCurrency.mjs +1 -41
  136. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  137. package/dist/esm/client/format/useDate.mjs +1 -43
  138. package/dist/esm/client/format/useDate.mjs.map +1 -1
  139. package/dist/esm/client/format/useIntl.mjs +1 -43
  140. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  141. package/dist/esm/client/format/useList.mjs +1 -38
  142. package/dist/esm/client/format/useList.mjs.map +1 -1
  143. package/dist/esm/client/format/useNumber.mjs +1 -39
  144. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  145. package/dist/esm/client/format/usePercentage.mjs +1 -35
  146. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  147. package/dist/esm/client/format/useRelativeTime.mjs +1 -35
  148. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  149. package/dist/esm/client/format/useUnit.mjs +1 -34
  150. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  151. package/dist/esm/client/index.mjs +1 -14
  152. package/dist/esm/client/t.mjs +1 -38
  153. package/dist/esm/client/t.mjs.map +1 -1
  154. package/dist/esm/client/useDictionary.mjs +1 -25
  155. package/dist/esm/client/useDictionary.mjs.map +1 -1
  156. package/dist/esm/client/useDictionaryAsync.mjs +1 -21
  157. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  158. package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
  159. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  160. package/dist/esm/client/useI18n.mjs +1 -43
  161. package/dist/esm/client/useI18n.mjs.map +1 -1
  162. package/dist/esm/client/useIntlayer.mjs +1 -40
  163. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  164. package/dist/esm/client/useLoadDynamic.mjs +1 -25
  165. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  166. package/dist/esm/client/useLocale.mjs +1 -57
  167. package/dist/esm/client/useLocale.mjs.map +1 -1
  168. package/dist/esm/client/useLocaleBase.mjs +1 -23
  169. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  170. package/dist/esm/client/useLocaleStorage.mjs +1 -54
  171. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  172. package/dist/esm/client/useRewriteURL.mjs +1 -39
  173. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  174. package/dist/esm/client/useTraduction.mjs +1 -33
  175. package/dist/esm/client/useTraduction.mjs.map +1 -1
  176. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -53
  177. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  178. package/dist/esm/editor/IntlayerEditorProvider.mjs +1 -58
  179. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  180. package/dist/esm/editor/index.mjs +1 -3
  181. package/dist/esm/editor/useEditedContentRenderer.mjs +1 -37
  182. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  183. package/dist/esm/getDictionary.mjs +1 -17
  184. package/dist/esm/getDictionary.mjs.map +1 -1
  185. package/dist/esm/getIntlayer.mjs +1 -17
  186. package/dist/esm/getIntlayer.mjs.map +1 -1
  187. package/dist/esm/html/HTMLProvider.mjs +1 -15
  188. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  189. package/dist/esm/html/HTMLRenderer.mjs +1 -54
  190. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  191. package/dist/esm/html/HTMLRendererPlugin.mjs +1 -34
  192. package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
  193. package/dist/esm/html/index.mjs +1 -5
  194. package/dist/esm/index.mjs +1 -21
  195. package/dist/esm/markdown/MarkdownProvider.mjs +1 -74
  196. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  197. package/dist/esm/markdown/MarkdownRenderer.mjs +1 -195
  198. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  199. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -30
  200. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  201. package/dist/esm/markdown/index.mjs +1 -7
  202. package/dist/esm/markdown/processor.mjs +1 -58
  203. package/dist/esm/markdown/processor.mjs.map +1 -1
  204. package/dist/esm/markdown/runtime.mjs +1 -39
  205. package/dist/esm/markdown/runtime.mjs.map +1 -1
  206. package/dist/esm/plugins.mjs +1 -172
  207. package/dist/esm/plugins.mjs.map +1 -1
  208. package/dist/esm/reactElement/renderReactElement.mjs +1 -50
  209. package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
  210. package/dist/esm/server/IntlayerServerProvider.mjs +1 -28
  211. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  212. package/dist/esm/server/format/index.mjs +1 -10
  213. package/dist/esm/server/format/useCompact.mjs +1 -25
  214. package/dist/esm/server/format/useCompact.mjs.map +1 -1
  215. package/dist/esm/server/format/useCurrency.mjs +1 -36
  216. package/dist/esm/server/format/useCurrency.mjs.map +1 -1
  217. package/dist/esm/server/format/useDate.mjs +1 -41
  218. package/dist/esm/server/format/useDate.mjs.map +1 -1
  219. package/dist/esm/server/format/useIntl.mjs +1 -41
  220. package/dist/esm/server/format/useIntl.mjs.map +1 -1
  221. package/dist/esm/server/format/useList.mjs +1 -33
  222. package/dist/esm/server/format/useList.mjs.map +1 -1
  223. package/dist/esm/server/format/useNumber.mjs +1 -37
  224. package/dist/esm/server/format/useNumber.mjs.map +1 -1
  225. package/dist/esm/server/format/usePercentage.mjs +1 -33
  226. package/dist/esm/server/format/usePercentage.mjs.map +1 -1
  227. package/dist/esm/server/format/useRelativeTime.mjs +1 -33
  228. package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
  229. package/dist/esm/server/format/useUnit.mjs +1 -32
  230. package/dist/esm/server/format/useUnit.mjs.map +1 -1
  231. package/dist/esm/server/index.mjs +1 -12
  232. package/dist/esm/server/serverContext.mjs +1 -54
  233. package/dist/esm/server/serverContext.mjs.map +1 -1
  234. package/dist/esm/server/t.mjs +1 -33
  235. package/dist/esm/server/t.mjs.map +1 -1
  236. package/dist/esm/server/useDictionary.mjs +1 -16
  237. package/dist/esm/server/useDictionary.mjs.map +1 -1
  238. package/dist/esm/server/useDictionaryAsync.mjs +1 -18
  239. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  240. package/dist/esm/server/useDictionaryDynamic.mjs +1 -19
  241. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  242. package/dist/esm/server/useI18n.mjs +1 -37
  243. package/dist/esm/server/useI18n.mjs.map +1 -1
  244. package/dist/esm/server/useIntlayer.mjs +1 -16
  245. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  246. package/dist/esm/server/useLoadDynamic.mjs +1 -11
  247. package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
  248. package/dist/esm/server/useLocale.mjs +1 -21
  249. package/dist/esm/server/useLocale.mjs.map +1 -1
  250. package/dist/types/IntlayerNode.d.ts +1 -1
  251. package/dist/types/client/format/useDate.d.ts +1 -1
  252. package/dist/types/client/useDictionary.d.ts +2 -2
  253. package/dist/types/client/useDictionary.d.ts.map +1 -1
  254. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  255. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  256. package/dist/types/client/useI18n.d.ts +3 -3
  257. package/dist/types/client/useI18n.d.ts.map +1 -1
  258. package/dist/types/client/useIntlayer.d.ts +2 -2
  259. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  260. package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
  261. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  262. package/dist/types/getDictionary.d.ts +1 -1
  263. package/dist/types/getIntlayer.d.ts +1 -1
  264. package/dist/types/getIntlayer.d.ts.map +1 -1
  265. package/dist/types/html/HTMLComponentTypes.d.ts +1 -1
  266. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  267. package/dist/types/index.d.ts +1 -1
  268. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  269. package/dist/types/markdown/processor.d.ts +1 -1
  270. package/dist/types/markdown/runtime.d.ts +1 -1
  271. package/dist/types/plugins.d.ts +1 -1
  272. package/dist/types/plugins.d.ts.map +1 -1
  273. package/dist/types/server/format/useCompact.d.ts +1 -1
  274. package/dist/types/server/format/useCurrency.d.ts +1 -1
  275. package/dist/types/server/format/useDate.d.ts +1 -1
  276. package/dist/types/server/format/useList.d.ts +1 -1
  277. package/dist/types/server/format/useNumber.d.ts +1 -1
  278. package/dist/types/server/format/usePercentage.d.ts +1 -1
  279. package/dist/types/server/format/useRelativeTime.d.ts +1 -1
  280. package/dist/types/server/format/useUnit.d.ts +1 -1
  281. package/dist/types/server/useDictionary.d.ts +2 -2
  282. package/dist/types/server/useDictionary.d.ts.map +1 -1
  283. package/dist/types/server/useDictionaryAsync.d.ts +2 -2
  284. package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
  285. package/dist/types/server/useDictionaryDynamic.d.ts +2 -2
  286. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  287. package/dist/types/server/useI18n.d.ts +3 -3
  288. package/dist/types/server/useI18n.d.ts.map +1 -1
  289. package/dist/types/server/useIntlayer.d.ts +2 -2
  290. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  291. package/package.json +9 -9
@@ -1,42 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
- let react = require("react");
7
- let _intlayer_core = require("@intlayer/core");
8
-
9
- //#region src/client/format/useNumber.ts
10
- /**
11
- * React client hook that provides a localized number formatter.
12
- *
13
- * Uses the current locale from {@link useLocaleBase} and returns
14
- * a function that can be used to format numbers consistently
15
- * according to the user's locale.
16
- *
17
- * @example
18
- * ```tsx
19
- * const formatNumber = useNumber();
20
- *
21
- * formatNumber(12345);
22
- * // e.g. "12,345" (en-US)
23
- * // e.g. "12 345" (fr-FR)
24
- *
25
- * formatNumber(0.75, { style: "percent" });
26
- * // e.g. "75%"
27
- * ```
28
- *
29
- * @returns {(value: string | number, options?: import("../createNumber").NumberProps) => string}
30
- * A number formatting function bound to the active locale.
31
- */
32
- const useNumber = () => {
33
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
34
- return (0, react.useCallback)((...args) => (0, _intlayer_core.number)(args[0], {
35
- ...args[1],
36
- locale: args[1]?.locale ?? locale
37
- }), [locale]);
38
- };
39
-
40
- //#endregion
41
- exports.useNumber = useNumber;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.number)(e[0],{...e[1],locale:e[1]?.locale??r}),[r])};exports.useNumber=r;
42
2
  //# sourceMappingURL=useNumber.cjs.map
@@ -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';\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,oCACK,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":"yOA4BA,MAAa,MAAkB,CAC7B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,QACK,EAAK,GAAI,CACd,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,38 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
- let react = require("react");
7
- let _intlayer_core = require("@intlayer/core");
8
-
9
- //#region src/client/format/usePercentage.ts
10
- /**
11
- * React hook to provide a percentage formatter function
12
- * based on the current application locale.
13
- *
14
- * This hook retrieves the active locale using {@link useLocaleBase}
15
- * and memoizes a `createPercentage` instance for that locale.
16
- *
17
- * @example
18
- * ```tsx
19
- * const formatPercentage = usePercentage();
20
- *
21
- * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });
22
- * // "87.5%" (depending on locale)
23
- * ```
24
- *
25
- * @returns {(value: string | number, options?: Omit<PercentageOptions, "value">) => string}
26
- * A function that formats numbers or numeric strings into localized percentages.
27
- */
28
- const usePercentage = () => {
29
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
30
- return (0, react.useCallback)((...args) => (0, _intlayer_core.percentage)(args[0], {
31
- ...args[1],
32
- locale: args[1]?.locale ?? locale
33
- }), [locale]);
34
- };
35
-
36
- //#endregion
37
- exports.usePercentage = usePercentage;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.percentage)(e[0],{...e[1],locale:e[1]?.locale??r}),[r])};exports.usePercentage=r;
38
2
  //# sourceMappingURL=usePercentage.cjs.map
@@ -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';\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,wCACS,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":"yOAwBA,MAAa,MAAsB,CACjC,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,YACS,EAAK,GAAI,CAClB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,38 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
- let react = require("react");
7
- let _intlayer_core = require("@intlayer/core");
8
-
9
- //#region src/client/format/useRelativeTime.ts
10
- /**
11
- * Client-side React hook for accessing a localized relative time formatter.
12
- *
13
- * This hook:
14
- * - Reads the current locale from {@link useLocaleBase}.
15
- * - Creates a new relative time formatter with {@link createRelativeTime}.
16
- * - Returns a function that can format time differences into localized strings.
17
- *
18
- * Example:
19
- * ```tsx
20
- * const relativeTime = useRelativeTime();
21
- * const formatted = relativeTime(new Date("2024-08-01"), new Date());
22
- * // e.g., "2 weeks ago"
23
- * ```
24
- *
25
- * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
26
- * bound to the current client locale.
27
- */
28
- const useRelativeTime = () => {
29
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
30
- return (0, react.useCallback)((...args) => (0, _intlayer_core.relativeTime)(args[0], args[1], {
31
- ...args[2],
32
- locale: args[2]?.locale ?? locale
33
- }), [locale]);
34
- };
35
-
36
- //#endregion
37
- exports.useRelativeTime = useRelativeTime;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.relativeTime)(e[0],e[1],{...e[2],locale:e[2]?.locale??r}),[r])};exports.useRelativeTime=r;
38
2
  //# sourceMappingURL=useRelativeTime.cjs.map
@@ -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';\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,0CACW,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":"yOAwBA,MAAa,MAAwB,CACnC,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,cACW,EAAK,GAAI,EAAK,GAAI,CAC7B,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,37 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
- let react = require("react");
7
- let _intlayer_core = require("@intlayer/core");
8
-
9
- //#region src/client/format/useUnit.ts
10
- /**
11
- * React hook that provides a unit formatting function
12
- * based on the current locale from {@link useLocaleBase}.
13
- *
14
- * This hook wraps {@link createUnit} to return a formatter
15
- * that can convert values into human-readable localized units
16
- * (e.g., "10 km", "5 lbs").
17
- *
18
- * @example
19
- * ```tsx
20
- * const formatUnit = useUnit();
21
- * const distance = formatUnit(10, { unit: "kilometer" });
22
- * // "10 km" (depending on locale)
23
- * ```
24
- *
25
- * @returns {Function} A unit formatting function that accepts a value and optional formatting options.
26
- */
27
- const useUnit = () => {
28
- const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
29
- return (0, react.useCallback)((...args) => (0, _intlayer_core.units)(args[0], {
30
- ...args[1],
31
- locale: args[1]?.locale ?? locale
32
- }), [locale]);
33
- };
34
-
35
- //#endregion
36
- exports.useUnit = useUnit;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.units)(e[0],{...e[1],locale:e[1]?.locale??r}),[r])};exports.useUnit=r;
37
2
  //# sourceMappingURL=useUnit.cjs.map
@@ -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';\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,mCACI,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":"yOAuBA,MAAa,MAAgB,CAC3B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,OACI,EAAK,GAAI,CACb,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
@@ -1,34 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
3
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
4
- const require_client_t = require('./t.cjs');
5
- const require_client_useDictionary = require('./useDictionary.cjs');
6
- const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
7
- const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
8
- const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
9
- const require_client_useI18n = require('./useI18n.cjs');
10
- const require_client_useIntlayer = require('./useIntlayer.cjs');
11
- const require_client_useLocale = require('./useLocale.cjs');
12
- const require_client_useLocaleBase = require('./useLocaleBase.cjs');
13
- const require_client_useRewriteURL = require('./useRewriteURL.cjs');
14
-
15
- exports.IntlayerClientContext = require_client_IntlayerProvider.IntlayerClientContext;
16
- exports.IntlayerProvider = require_client_IntlayerProvider.IntlayerProvider;
17
- exports.IntlayerProviderContent = require_client_IntlayerProvider.IntlayerProviderContent;
18
- exports.localeCookie = require_client_useLocaleStorage.localeCookie;
19
- exports.localeInStorage = require_client_useLocaleStorage.localeInStorage;
20
- exports.setLocaleCookie = require_client_useLocaleStorage.setLocaleCookie;
21
- exports.setLocaleInStorage = require_client_useLocaleStorage.setLocaleInStorage;
22
- exports.t = require_client_t.t;
23
- exports.useDictionary = require_client_useDictionary.useDictionary;
24
- exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
25
- exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
26
- exports.useI18n = require_client_useI18n.useI18n;
27
- exports.useIntlayer = require_client_useIntlayer.useIntlayer;
28
- exports.useIntlayerContext = require_client_IntlayerProvider.useIntlayerContext;
29
- exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
30
- exports.useLocale = require_client_useLocale.useLocale;
31
- exports.useLocaleBase = require_client_useLocaleBase.useLocaleBase;
32
- exports.useLocaleCookie = require_client_useLocaleStorage.useLocaleCookie;
33
- exports.useLocaleStorage = require_client_useLocaleStorage.useLocaleStorage;
34
- exports.useRewriteURL = require_client_useRewriteURL.useRewriteURL;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useLocaleStorage.cjs`),t=require(`./IntlayerProvider.cjs`),n=require(`./t.cjs`),r=require(`./useDictionary.cjs`),i=require(`./useDictionaryAsync.cjs`),a=require(`./useLoadDynamic.cjs`),o=require(`./useDictionaryDynamic.cjs`),s=require(`./useI18n.cjs`),c=require(`./useIntlayer.cjs`),l=require(`./useLocale.cjs`),u=require(`./useLocaleBase.cjs`),d=require(`./useRewriteURL.cjs`);exports.IntlayerClientContext=t.IntlayerClientContext,exports.IntlayerProvider=t.IntlayerProvider,exports.IntlayerProviderContent=t.IntlayerProviderContent,exports.localeCookie=e.localeCookie,exports.localeInStorage=e.localeInStorage,exports.setLocaleCookie=e.setLocaleCookie,exports.setLocaleInStorage=e.setLocaleInStorage,exports.t=n.t,exports.useDictionary=r.useDictionary,exports.useDictionaryAsync=i.useDictionaryAsync,exports.useDictionaryDynamic=o.useDictionaryDynamic,exports.useI18n=s.useI18n,exports.useIntlayer=c.useIntlayer,exports.useIntlayerContext=t.useIntlayerContext,exports.useLoadDynamic=a.useLoadDynamic,exports.useLocale=l.useLocale,exports.useLocaleBase=u.useLocaleBase,exports.useLocaleCookie=e.useLocaleCookie,exports.useLocaleStorage=e.useLocaleStorage,exports.useRewriteURL=d.useRewriteURL;
@@ -1,41 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
- let react = require("react");
7
- let _intlayer_core = require("@intlayer/core");
8
-
9
- //#region src/client/t.ts
10
- /**
11
- * Client-side translation function that returns the translation of the provided multilang content.
12
- *
13
- * If the locale is not provided, it will use the locale from the client context.
14
- *
15
- * @param multilangContent - An object mapping locales to their respective content.
16
- * @param locale - Optional locale to override the current context locale.
17
- * @returns The translation for the specified locale.
18
- *
19
- * @example
20
- * ```tsx
21
- * import { t } from 'react-intlayer';
22
- *
23
- * const MyComponent = () => {
24
- * const greeting = t({
25
- * en: 'Hello',
26
- * fr: 'Bonjour',
27
- * es: 'Hola',
28
- * });
29
- *
30
- * return <h1>{greeting}</h1>;
31
- * };
32
- * ```
33
- */
34
- const t = (multilangContent, locale) => {
35
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
36
- return (0, _intlayer_core.getTranslation)(multilangContent, locale ?? currentLocale);
37
- };
38
-
39
- //#endregion
40
- exports.t = t;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/interpreter`);const r=(r,i)=>{let{locale:a}=(0,t.useContext)(e.IntlayerClientContext);return(0,n.getTranslation)(r,i??a)};exports.t=r;
41
2
  //# sourceMappingURL=t.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\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,2CAA+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 { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\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":"sOA+BA,MAAa,GACX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAGnE,OAAA,EAAA,EAAA,gBAA+B,EAFV,GAAU,EAE+B"}
@@ -1,28 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
- const require_getDictionary = require('../getDictionary.cjs');
7
- let react = require("react");
8
-
9
- //#region src/client/useDictionary.ts
10
- /**
11
- * On the server side, Hook that transform a dictionary and return the content
12
- *
13
- * If the locale is not provided, it will use the locale from the client context
14
- */
15
- const useDictionary = (dictionary, locale) => {
16
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
17
- return (0, react.useMemo)(() => {
18
- return require_getDictionary.getDictionary(dictionary, locale ?? currentLocale);
19
- }, [
20
- dictionary,
21
- currentLocale,
22
- locale
23
- ]);
24
- };
25
-
26
- //#endregion
27
- exports.useDictionary = useDictionary;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./IntlayerProvider.cjs`),t=require(`../getDictionary.cjs`);let n=require(`react`);const r=(r,i)=>{let{locale:a}=(0,n.useContext)(e.IntlayerClientContext);return(0,n.useMemo)(()=>t.getDictionary(r,i??a),[r,a,i])};exports.useDictionary=r;
28
2
  //# sourceMappingURL=useDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\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, 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;EAAY;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\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, currentLocale, locale]);\n};\n"],"mappings":"gOAgBA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAEnE,OAAA,EAAA,EAAA,aAGSC,EAAAA,cAAoB,EAFN,GAAU,EAE0B,CACxD,CAAC,EAAY,EAAe,EAAO,CAAC"}
@@ -1,25 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
- const require_client_useDictionary = require('./useDictionary.cjs');
7
- let react = require("react");
8
- let _intlayer_config_built = require("@intlayer/config/built");
9
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
10
-
11
- //#region src/client/useDictionaryAsync.ts
12
- /**
13
- * On the server side, Hook that transform a dictionary and return the content
14
- *
15
- * If the locale is not provided, it will use the locale from the client context
16
- */
17
- const useDictionaryAsync = async (dictionaryPromise, locale) => {
18
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
19
- const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.default?.internationalization.defaultLocale, [currentLocale, locale]);
20
- return require_client_useDictionary.useDictionary(await (0, react.useMemo)(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
21
- };
22
-
23
- //#endregion
24
- exports.useDictionaryAsync = useDictionaryAsync;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./IntlayerProvider.cjs`),n=require(`./useDictionary.cjs`);let r=require(`react`),i=require(`@intlayer/config/built`);i=e.__toESM(i);const a=async(e,a)=>{let{locale:o}=(0,r.useContext)(t.IntlayerClientContext),s=(0,r.useMemo)(()=>a??o??i.default?.internationalization.defaultLocale,[o,a]);return n.useDictionary(await(0,r.useMemo)(async()=>await e[s]?.(),[e,s]),s)};exports.useDictionaryAsync=a;
25
2
  //# sourceMappingURL=useDictionaryAsync.cjs.map
@@ -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 {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\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 {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\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":"oRAkBA,MAAa,EAAqB,MAIhC,EACA,IACe,CACf,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAE7D,GAAA,EAAA,EAAA,aAEF,GACA,GACAC,EAAAA,SAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAUD,OAAOC,EAAAA,cARY,MAAA,EAAA,EAAA,SACjB,SACG,MAAM,EACL,MACG,CACP,CAAC,EAAmB,EAAa,CAClC,CAEsC,EAAkB"}
@@ -1,26 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
- const require_client_useDictionary = require('./useDictionary.cjs');
7
- const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
8
- let react = require("react");
9
- let _intlayer_config_built = require("@intlayer/config/built");
10
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
11
-
12
- //#region src/client/useDictionaryDynamic.ts
13
- /**
14
- * On the server side, Hook that transform a dictionary and return the content
15
- *
16
- * If the locale is not provided, it will use the locale from the client context
17
- */
18
- const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
19
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
20
- const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale ?? _intlayer_config_built.default?.internationalization.defaultLocale, [currentLocale, locale]);
21
- return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
22
- };
23
-
24
- //#endregion
25
- exports.useDictionaryDynamic = useDictionaryDynamic;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./IntlayerProvider.cjs`),n=require(`./useDictionary.cjs`),r=require(`./useLoadDynamic.cjs`);let i=require(`react`),a=require(`@intlayer/config/built`);a=e.__toESM(a);const o=(e,o,s)=>{let{locale:c}=(0,i.useContext)(t.IntlayerClientContext),l=(0,i.useMemo)(()=>s??c??a.default?.internationalization.defaultLocale,[c,s]);return n.useDictionary(r.useLoadDynamic(`${String(o)}.${l}`,e[l]?.()),l)};exports.useDictionaryDynamic=o;
26
2
  //# sourceMappingURL=useDictionaryDynamic.cjs.map
@@ -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 {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\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 {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\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":"sTAmBA,MAAa,GAIX,EACA,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,GAAA,EAAA,EAAA,aAEF,GACA,GACAC,EAAAA,SAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAOD,OAAOC,EAAAA,cALYC,EAAAA,eACjB,GAAG,OAAO,EAAI,CAAC,GAAG,IACjB,EAA0B,MAAiB,CAC7C,CAEgC,EAAa"}
@@ -1,46 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
- let react = require("react");
7
- let _intlayer_core = require("@intlayer/core");
8
-
9
- //#region src/client/useI18n.ts
10
- /**
11
- * Hook that provides a translation function `t()` for accessing nested content by key.
12
- * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.
13
- *
14
- * @param namespace - The dictionary key to scope translations to
15
- * @param locale - Optional locale override. If not provided, uses the current context locale
16
- * @returns A translation function `t(key)` that returns the translated content for the given key
17
- *
18
- * @example
19
- * ```tsx
20
- * const t = useI18n('IndexPage');
21
- * const title = t('title'); // Returns translated string for 'IndexPage.title'
22
- * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'
23
- * // For attributes like `aria-label`, use `.value` to get the plain string
24
- * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'
25
- * ```
26
- */
27
- const useI18n = (namespace, locale) => {
28
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
29
- const localeTarget = (0, react.useMemo)(() => locale ?? currentLocale, [currentLocale, locale]);
30
- const dictionaryContent = (0, react.useMemo)(() => (0, _intlayer_core.getIntlayer)(namespace, localeTarget), [namespace, localeTarget]);
31
- const t = (path) => {
32
- if (!path) return dictionaryContent;
33
- const pathArray = path.split(".");
34
- let current = dictionaryContent;
35
- for (const key of pathArray) {
36
- current = current?.[key];
37
- if (current === void 0) return dictionaryContent;
38
- }
39
- return current;
40
- };
41
- return t;
42
- };
43
-
44
- //#endregion
45
- exports.useI18n = useI18n;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/interpreter`);const r=(r,i)=>{let{locale:a}=(0,t.useContext)(e.IntlayerClientContext),o=(0,t.useMemo)(()=>i??a,[a,i]),s=(0,t.useMemo)(()=>(0,n.getIntlayer)(r,o),[r,o]);return e=>{if(!e)return s;let t=e.split(`.`),n=s;for(let e of t)if(n=n?.[e],n===void 0)return s;return n}};exports.useI18n=r;
46
2
  //# sourceMappingURL=useI18n.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer, type ValidDotPathsFor } from '@intlayer/core';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n LocalesValues,\n} from '@intlayer/types';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,WAIX,WACA,WACG;CACH,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;CACnE,MAAM,wCACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAID,MAAM,6EAEsB,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 {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n LocalesValues,\n} from '@intlayer/types';\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":"sOAgCA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,GAAA,EAAA,EAAA,aACE,GAAU,EAChB,CAAC,EAAe,EAAO,CACxB,CAIK,GAAA,EAAA,EAAA,cAAA,EAAA,EAAA,aAEsB,EAAW,EAAkB,CACrD,CAAC,EAAW,EAAa,CAC1B,CA2BH,MAtBE,IAEsE,CACtE,GAAI,CAAC,EAEH,OAAO,EAGT,IAAM,EAAa,EAAgB,MAAM,IAAI,CACzC,EAAe,EAEnB,IAAK,IAAM,KAAO,EAEhB,GADA,EAAU,IAAU,GAChB,IAAY,IAAA,GAEd,OAAO,EAIX,OAAO"}
@@ -1,43 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
- const require_getIntlayer = require('../getIntlayer.cjs');
7
- let react = require("react");
8
-
9
- //#region src/client/useIntlayer.ts
10
- /**
11
- * Client-side hook that picks one dictionary by its key and returns its content.
12
- *
13
- * If the locale is not provided, it will use the locale from the client context.
14
- *
15
- * @param key - The unique key of the dictionary to retrieve.
16
- * @param locale - Optional locale to override the current context locale.
17
- * @returns The dictionary content for the specified locale.
18
- *
19
- * @example
20
- * ```tsx
21
- * import { useIntlayer } from 'react-intlayer';
22
- *
23
- * const MyComponent = () => {
24
- * const content = useIntlayer('my-dictionary-key');
25
- *
26
- * return <div>{content.myField.value}</div>;
27
- * };
28
- * ```
29
- */
30
- const useIntlayer = (key, locale) => {
31
- const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
32
- return (0, react.useMemo)(() => {
33
- return require_getIntlayer.getIntlayer(key, locale ?? currentLocale);
34
- }, [
35
- key,
36
- currentLocale,
37
- locale
38
- ]);
39
- };
40
-
41
- //#endregion
42
- exports.useIntlayer = useIntlayer;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./IntlayerProvider.cjs`),t=require(`../getIntlayer.cjs`);let n=require(`react`);const r=(r,i)=>{let{locale:a}=(0,n.useContext)(e.IntlayerClientContext);return(0,n.useMemo)(()=>t.getIntlayer(r,i??a),[r,a,i])};exports.useIntlayer=r;
43
2
  //# sourceMappingURL=useIntlayer.cjs.map
@@ -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';\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';\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":"8NA+BA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAEnE,OAAA,EAAA,EAAA,aAGSC,EAAAA,YAAkB,EAFJ,GAAW,EAEW,CAC1C,CAAC,EAAK,EAAe,EAAO,CAAC"}
@@ -1,28 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/client/useLoadDynamic.ts
4
- const createSuspender = (promise) => {
5
- let status = "pending";
6
- let result;
7
- const suspender = promise.then((r) => {
8
- status = "success";
9
- result = r;
10
- }, (e) => {
11
- status = "error";
12
- result = e;
13
- });
14
- return { read() {
15
- if (status === "pending") throw suspender;
16
- if (status === "error") throw result;
17
- return result;
18
- } };
19
- };
20
- const cache = /* @__PURE__ */ new Map();
21
- const useLoadDynamic = (key, promise) => {
22
- if (!cache.has(key)) cache.set(key, createSuspender(promise));
23
- return cache.get(key).read();
24
- };
25
-
26
- //#endregion
27
- exports.useLoadDynamic = useLoadDynamic;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{let t=`pending`,n,r=e.then(e=>{t=`success`,n=e},e=>{t=`error`,n=e});return{read(){if(t===`pending`)throw r;if(t===`error`)throw n;return n}}},t=new Map,n=(n,r)=>(t.has(n)||t.set(n,e(r)),t.get(n).read());exports.useLoadDynamic=n;
28
2
  //# sourceMappingURL=useLoadDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";;;AAEA,MAAM,mBAAsB,YAAwB;CAClD,IAAI,SAAiB;CACrB,IAAI;CACJ,MAAM,YAAY,QAAQ,MACvB,MAAM;AACL,WAAS;AACT,WAAS;KAEV,MAAM;AACL,WAAS;AACT,WAAS;GAEZ;AAED,QAAO,EACL,OAAO;AACL,MAAI,WAAW,UAAW,OAAM;AAChC,MAAI,WAAW,QAAS,OAAM;AAC9B,SAAO;IAEV;;AAGH,MAAM,wBAAQ,IAAI,KAAiD;AAEnE,MAAa,kBAAqB,KAAa,YAA2B;AACxE,KAAI,CAAC,MAAM,IAAI,IAAI,CACjB,OAAM,IAAI,KAAK,gBAAgB,QAAQ,CAAC;AAG1C,QAAQ,MAAM,IAAI,IAAI,CAAyC,MAAM"}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":"mEAEA,MAAM,EAAsB,GAAwB,CAClD,IAAI,EAAiB,UACjB,EACE,EAAY,EAAQ,KACvB,GAAM,CACL,EAAS,UACT,EAAS,GAEV,GAAM,CACL,EAAS,QACT,EAAS,GAEZ,CAED,MAAO,CACL,MAAO,CACL,GAAI,IAAW,UAAW,MAAM,EAChC,GAAI,IAAW,QAAS,MAAM,EAC9B,OAAO,GAEV,EAGG,EAAQ,IAAI,IAEL,GAAqB,EAAa,KACxC,EAAM,IAAI,EAAI,EACjB,EAAM,IAAI,EAAK,EAAgB,EAAQ,CAAC,CAGlC,EAAM,IAAI,EAAI,CAAyC,MAAM"}