react-intlayer 6.1.6 → 7.0.0-canary.2

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 (351) hide show
  1. package/dist/cjs/IntlayerNode.cjs +17 -46
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +96 -128
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  6. package/dist/cjs/client/IntlayerProvider.cjs +64 -93
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +17 -50
  9. package/dist/cjs/client/format/useCompact.cjs +29 -39
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +43 -39
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +45 -36
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useList.cjs +40 -39
  16. package/dist/cjs/client/format/useList.cjs.map +1 -1
  17. package/dist/cjs/client/format/useNumber.cjs +41 -39
  18. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  19. package/dist/cjs/client/format/usePercentage.cjs +37 -39
  20. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  21. package/dist/cjs/client/format/useRelativeTime.cjs +37 -39
  22. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  23. package/dist/cjs/client/format/useUnit.cjs +36 -39
  24. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  25. package/dist/cjs/client/index.cjs +31 -72
  26. package/dist/cjs/client/t.cjs +21 -34
  27. package/dist/cjs/client/t.cjs.map +1 -1
  28. package/dist/cjs/client/useDictionary.cjs +26 -36
  29. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  30. package/dist/cjs/client/useDictionaryAsync.cjs +23 -52
  31. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionaryDynamic.cjs +24 -53
  33. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  34. package/dist/cjs/client/useI18n.cjs +45 -55
  35. package/dist/cjs/client/useI18n.cjs.map +1 -1
  36. package/dist/cjs/client/useIntlayer.cjs +28 -36
  37. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  38. package/dist/cjs/client/useLoadDynamic.cjs +21 -50
  39. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  40. package/dist/cjs/client/useLocale.cjs +39 -70
  41. package/dist/cjs/client/useLocale.cjs.map +1 -1
  42. package/dist/cjs/client/useLocaleBase.cjs +25 -53
  43. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleStorage.cjs +63 -0
  45. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
  46. package/dist/cjs/client/useTraduction.cjs +34 -35
  47. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  48. package/dist/cjs/editor/ContentSelectorWrapper.cjs +55 -91
  49. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  50. package/dist/cjs/editor/IntlayerEditorProvider.cjs +45 -92
  51. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  52. package/dist/cjs/editor/index.cjs +3 -23
  53. package/dist/cjs/editor/useEditedContentRenderer.cjs +40 -59
  54. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  55. package/dist/cjs/getDictionary.cjs +15 -40
  56. package/dist/cjs/getDictionary.cjs.map +1 -1
  57. package/dist/cjs/getIntlayer.cjs +15 -36
  58. package/dist/cjs/getIntlayer.cjs.map +1 -1
  59. package/dist/cjs/index.cjs +33 -75
  60. package/dist/cjs/markdown/MarkdownProvider.cjs +19 -39
  61. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  62. package/dist/cjs/markdown/MarkdownRenderer.cjs +39 -80
  63. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  64. package/dist/cjs/markdown/index.cjs +7 -25
  65. package/dist/cjs/plugins.cjs +92 -119
  66. package/dist/cjs/plugins.cjs.map +1 -1
  67. package/dist/cjs/reactElement/renderReactElement.cjs +39 -59
  68. package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
  69. package/dist/cjs/server/IntlayerServerProvider.cjs +33 -53
  70. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  71. package/dist/cjs/server/format/index.cjs +17 -50
  72. package/dist/cjs/server/format/useCompact.cjs +25 -35
  73. package/dist/cjs/server/format/useCompact.cjs.map +1 -1
  74. package/dist/cjs/server/format/useCurrency.cjs +36 -35
  75. package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
  76. package/dist/cjs/server/format/useDate.cjs +41 -35
  77. package/dist/cjs/server/format/useDate.cjs.map +1 -1
  78. package/dist/cjs/server/format/useList.cjs +33 -35
  79. package/dist/cjs/server/format/useList.cjs.map +1 -1
  80. package/dist/cjs/server/format/useNumber.cjs +37 -35
  81. package/dist/cjs/server/format/useNumber.cjs.map +1 -1
  82. package/dist/cjs/server/format/usePercentage.cjs +33 -35
  83. package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
  84. package/dist/cjs/server/format/useRelativeTime.cjs +33 -35
  85. package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
  86. package/dist/cjs/server/format/useUnit.cjs +32 -35
  87. package/dist/cjs/server/format/useUnit.cjs.map +1 -1
  88. package/dist/cjs/server/index.cjs +21 -57
  89. package/dist/cjs/server/serverContext.cjs +40 -71
  90. package/dist/cjs/server/serverContext.cjs.map +1 -1
  91. package/dist/cjs/server/t.cjs +33 -33
  92. package/dist/cjs/server/t.cjs.map +1 -1
  93. package/dist/cjs/server/useDictionary.cjs +14 -32
  94. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  95. package/dist/cjs/server/useDictionaryAsync.cjs +18 -44
  96. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  97. package/dist/cjs/server/useDictionaryDynamic.cjs +19 -48
  98. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  99. package/dist/cjs/server/useI18n.cjs +35 -47
  100. package/dist/cjs/server/useI18n.cjs.map +1 -1
  101. package/dist/cjs/server/useIntlayer.cjs +14 -32
  102. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  103. package/dist/cjs/server/useLoadDynamic.cjs +11 -41
  104. package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
  105. package/dist/cjs/server/useLocale.cjs +21 -43
  106. package/dist/cjs/server/useLocale.cjs.map +1 -1
  107. package/dist/esm/IntlayerNode.mjs +13 -23
  108. package/dist/esm/IntlayerNode.mjs.map +1 -1
  109. package/dist/esm/UI/ContentSelector.mjs +92 -108
  110. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  111. package/dist/esm/client/IntlayerProvider.mjs +49 -53
  112. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  113. package/dist/esm/client/format/index.mjs +2 -11
  114. package/dist/esm/client/format/useCompact.mjs +25 -14
  115. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  116. package/dist/esm/client/format/useCurrency.mjs +39 -14
  117. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  118. package/dist/esm/client/format/useDate.mjs +41 -11
  119. package/dist/esm/client/format/useDate.mjs.map +1 -1
  120. package/dist/esm/client/format/useList.mjs +36 -14
  121. package/dist/esm/client/format/useList.mjs.map +1 -1
  122. package/dist/esm/client/format/useNumber.mjs +37 -14
  123. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  124. package/dist/esm/client/format/usePercentage.mjs +33 -14
  125. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  126. package/dist/esm/client/format/useRelativeTime.mjs +33 -14
  127. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  128. package/dist/esm/client/format/useUnit.mjs +32 -14
  129. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  130. package/dist/esm/client/index.mjs +5 -33
  131. package/dist/esm/client/t.mjs +17 -9
  132. package/dist/esm/client/t.mjs.map +1 -1
  133. package/dist/esm/client/useDictionary.mjs +23 -11
  134. package/dist/esm/client/useDictionary.mjs.map +1 -1
  135. package/dist/esm/client/useDictionaryAsync.mjs +18 -16
  136. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  137. package/dist/esm/client/useDictionaryDynamic.mjs +18 -16
  138. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  139. package/dist/esm/client/useI18n.mjs +41 -30
  140. package/dist/esm/client/useI18n.mjs.map +1 -1
  141. package/dist/esm/client/useIntlayer.mjs +25 -11
  142. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  143. package/dist/esm/client/useLoadDynamic.mjs +20 -26
  144. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  145. package/dist/esm/client/useLocale.mjs +35 -35
  146. package/dist/esm/client/useLocale.mjs.map +1 -1
  147. package/dist/esm/client/useLocaleBase.mjs +20 -17
  148. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  149. package/dist/esm/client/useLocaleStorage.mjs +55 -0
  150. package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  151. package/dist/esm/client/useTraduction.mjs +30 -10
  152. package/dist/esm/client/useTraduction.mjs.map +1 -1
  153. package/dist/esm/editor/ContentSelectorWrapper.mjs +48 -70
  154. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  155. package/dist/esm/editor/IntlayerEditorProvider.mjs +39 -61
  156. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  157. package/dist/esm/editor/index.mjs +3 -2
  158. package/dist/esm/editor/useEditedContentRenderer.mjs +33 -32
  159. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  160. package/dist/esm/getDictionary.mjs +13 -22
  161. package/dist/esm/getDictionary.mjs.map +1 -1
  162. package/dist/esm/getIntlayer.mjs +13 -18
  163. package/dist/esm/getIntlayer.mjs.map +1 -1
  164. package/dist/esm/index.mjs +6 -35
  165. package/dist/esm/markdown/MarkdownProvider.mjs +14 -16
  166. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  167. package/dist/esm/markdown/MarkdownRenderer.mjs +34 -57
  168. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  169. package/dist/esm/markdown/index.mjs +4 -3
  170. package/dist/esm/plugins.mjs +82 -92
  171. package/dist/esm/plugins.mjs.map +1 -1
  172. package/dist/esm/reactElement/renderReactElement.mjs +36 -34
  173. package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
  174. package/dist/esm/server/IntlayerServerProvider.mjs +22 -11
  175. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  176. package/dist/esm/server/format/index.mjs +2 -11
  177. package/dist/esm/server/format/useCompact.mjs +22 -10
  178. package/dist/esm/server/format/useCompact.mjs.map +1 -1
  179. package/dist/esm/server/format/useCurrency.mjs +33 -10
  180. package/dist/esm/server/format/useCurrency.mjs.map +1 -1
  181. package/dist/esm/server/format/useDate.mjs +38 -10
  182. package/dist/esm/server/format/useDate.mjs.map +1 -1
  183. package/dist/esm/server/format/useList.mjs +30 -10
  184. package/dist/esm/server/format/useList.mjs.map +1 -1
  185. package/dist/esm/server/format/useNumber.mjs +34 -10
  186. package/dist/esm/server/format/useNumber.mjs.map +1 -1
  187. package/dist/esm/server/format/usePercentage.mjs +30 -10
  188. package/dist/esm/server/format/usePercentage.mjs.map +1 -1
  189. package/dist/esm/server/format/useRelativeTime.mjs +30 -10
  190. package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
  191. package/dist/esm/server/format/useUnit.mjs +29 -10
  192. package/dist/esm/server/format/useUnit.mjs.map +1 -1
  193. package/dist/esm/server/index.mjs +4 -20
  194. package/dist/esm/server/serverContext.mjs +36 -35
  195. package/dist/esm/server/serverContext.mjs.map +1 -1
  196. package/dist/esm/server/t.mjs +30 -8
  197. package/dist/esm/server/t.mjs.map +1 -1
  198. package/dist/esm/server/useDictionary.mjs +12 -6
  199. package/dist/esm/server/useDictionary.mjs.map +1 -1
  200. package/dist/esm/server/useDictionaryAsync.mjs +14 -8
  201. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  202. package/dist/esm/server/useDictionaryDynamic.mjs +14 -11
  203. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  204. package/dist/esm/server/useI18n.mjs +33 -21
  205. package/dist/esm/server/useI18n.mjs.map +1 -1
  206. package/dist/esm/server/useIntlayer.mjs +12 -6
  207. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  208. package/dist/esm/server/useLoadDynamic.mjs +8 -6
  209. package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
  210. package/dist/esm/server/useLocale.mjs +18 -8
  211. package/dist/esm/server/useLocale.mjs.map +1 -1
  212. package/dist/types/IntlayerNode.d.ts +19 -12
  213. package/dist/types/IntlayerNode.d.ts.map +1 -1
  214. package/dist/types/UI/ContentSelector.d.ts +12 -9
  215. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  216. package/dist/types/client/IntlayerProvider.d.ts +21 -15
  217. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  218. package/dist/types/client/format/index.d.ts +9 -9
  219. package/dist/types/client/format/useCompact.d.ts +8 -2
  220. package/dist/types/client/format/useCompact.d.ts.map +1 -1
  221. package/dist/types/client/format/useCurrency.d.ts +8 -2
  222. package/dist/types/client/format/useCurrency.d.ts.map +1 -1
  223. package/dist/types/client/format/useDate.d.ts +7 -2
  224. package/dist/types/client/format/useDate.d.ts.map +1 -1
  225. package/dist/types/client/format/useList.d.ts +8 -2
  226. package/dist/types/client/format/useList.d.ts.map +1 -1
  227. package/dist/types/client/format/useNumber.d.ts +8 -2
  228. package/dist/types/client/format/useNumber.d.ts.map +1 -1
  229. package/dist/types/client/format/usePercentage.d.ts +8 -2
  230. package/dist/types/client/format/usePercentage.d.ts.map +1 -1
  231. package/dist/types/client/format/useRelativeTime.d.ts +9 -3
  232. package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
  233. package/dist/types/client/format/useUnit.d.ts +8 -2
  234. package/dist/types/client/format/useUnit.d.ts.map +1 -1
  235. package/dist/types/client/index.d.ts +12 -19
  236. package/dist/types/client/t.d.ts +7 -3
  237. package/dist/types/client/t.d.ts.map +1 -1
  238. package/dist/types/client/useDictionary.d.ts +9 -3
  239. package/dist/types/client/useDictionary.d.ts.map +1 -1
  240. package/dist/types/client/useDictionaryAsync.d.ts +7 -3
  241. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  242. package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
  243. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  244. package/dist/types/client/useI18n.d.ts +9 -5
  245. package/dist/types/client/useI18n.d.ts.map +1 -1
  246. package/dist/types/client/useIntlayer.d.ts +10 -5
  247. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  248. package/dist/types/client/useLoadDynamic.d.ts +4 -1
  249. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  250. package/dist/types/client/useLocale.d.ts +18 -10
  251. package/dist/types/client/useLocale.d.ts.map +1 -1
  252. package/dist/types/client/useLocaleBase.d.ts +10 -5
  253. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  254. package/dist/types/client/useLocaleStorage.d.ts +49 -0
  255. package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
  256. package/dist/types/client/useTraduction.d.ts +7 -2
  257. package/dist/types/client/useTraduction.d.ts.map +1 -1
  258. package/dist/types/editor/ContentSelectorWrapper.d.ts +8 -4
  259. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  260. package/dist/types/editor/IntlayerEditorProvider.d.ts +6 -2
  261. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  262. package/dist/types/editor/index.d.ts +2 -2
  263. package/dist/types/editor/useEditedContentRenderer.d.ts +16 -10
  264. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
  265. package/dist/types/getDictionary.d.ts +8 -4
  266. package/dist/types/getDictionary.d.ts.map +1 -1
  267. package/dist/types/getIntlayer.d.ts +8 -4
  268. package/dist/types/getIntlayer.d.ts.map +1 -1
  269. package/dist/types/index.d.ts +19 -17
  270. package/dist/types/index.d.ts.map +1 -1
  271. package/dist/types/markdown/MarkdownProvider.d.ts +8 -5
  272. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
  273. package/dist/types/markdown/MarkdownRenderer.d.ts +13 -11
  274. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  275. package/dist/types/markdown/index.d.ts +3 -3
  276. package/dist/types/plugins.d.ts +33 -27
  277. package/dist/types/plugins.d.ts.map +1 -1
  278. package/dist/types/reactElement/renderReactElement.d.ts +7 -2
  279. package/dist/types/reactElement/renderReactElement.d.ts.map +1 -1
  280. package/dist/types/server/IntlayerServerProvider.d.ts +25 -19
  281. package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
  282. package/dist/types/server/format/index.d.ts +9 -9
  283. package/dist/types/server/format/useCompact.d.ts +7 -2
  284. package/dist/types/server/format/useCompact.d.ts.map +1 -1
  285. package/dist/types/server/format/useCurrency.d.ts +7 -2
  286. package/dist/types/server/format/useCurrency.d.ts.map +1 -1
  287. package/dist/types/server/format/useDate.d.ts +7 -2
  288. package/dist/types/server/format/useDate.d.ts.map +1 -1
  289. package/dist/types/server/format/useList.d.ts +7 -2
  290. package/dist/types/server/format/useList.d.ts.map +1 -1
  291. package/dist/types/server/format/useNumber.d.ts +7 -2
  292. package/dist/types/server/format/useNumber.d.ts.map +1 -1
  293. package/dist/types/server/format/usePercentage.d.ts +7 -2
  294. package/dist/types/server/format/usePercentage.d.ts.map +1 -1
  295. package/dist/types/server/format/useRelativeTime.d.ts +7 -2
  296. package/dist/types/server/format/useRelativeTime.d.ts.map +1 -1
  297. package/dist/types/server/format/useUnit.d.ts +7 -2
  298. package/dist/types/server/format/useUnit.d.ts.map +1 -1
  299. package/dist/types/server/index.d.ts +10 -10
  300. package/dist/types/server/serverContext.d.ts +23 -27
  301. package/dist/types/server/serverContext.d.ts.map +1 -1
  302. package/dist/types/server/t.d.ts +7 -3
  303. package/dist/types/server/t.d.ts.map +1 -1
  304. package/dist/types/server/useDictionary.d.ts +9 -3
  305. package/dist/types/server/useDictionary.d.ts.map +1 -1
  306. package/dist/types/server/useDictionaryAsync.d.ts +9 -3
  307. package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
  308. package/dist/types/server/useDictionaryDynamic.d.ts +9 -3
  309. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  310. package/dist/types/server/useI18n.d.ts +9 -5
  311. package/dist/types/server/useI18n.d.ts.map +1 -1
  312. package/dist/types/server/useIntlayer.d.ts +9 -3
  313. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  314. package/dist/types/server/useLoadDynamic.d.ts +4 -1
  315. package/dist/types/server/useLoadDynamic.d.ts.map +1 -1
  316. package/dist/types/server/useLocale.d.ts +11 -4
  317. package/dist/types/server/useLocale.d.ts.map +1 -1
  318. package/package.json +43 -49
  319. package/LICENSE +0 -202
  320. package/dist/cjs/client/format/index.cjs.map +0 -1
  321. package/dist/cjs/client/getBrowserLocale.cjs +0 -173
  322. package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
  323. package/dist/cjs/client/index.cjs.map +0 -1
  324. package/dist/cjs/client/useLocaleCookie.cjs +0 -60
  325. package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
  326. package/dist/cjs/editor/index.cjs.map +0 -1
  327. package/dist/cjs/index.cjs.map +0 -1
  328. package/dist/cjs/markdown/index.cjs.map +0 -1
  329. package/dist/cjs/server/format/index.cjs.map +0 -1
  330. package/dist/cjs/server/index.cjs.map +0 -1
  331. package/dist/esm/client/format/index.mjs.map +0 -1
  332. package/dist/esm/client/getBrowserLocale.mjs +0 -138
  333. package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
  334. package/dist/esm/client/index.mjs.map +0 -1
  335. package/dist/esm/client/useLocaleCookie.mjs +0 -24
  336. package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
  337. package/dist/esm/editor/index.mjs.map +0 -1
  338. package/dist/esm/index.mjs.map +0 -1
  339. package/dist/esm/markdown/index.mjs.map +0 -1
  340. package/dist/esm/server/format/index.mjs.map +0 -1
  341. package/dist/esm/server/index.mjs.map +0 -1
  342. package/dist/types/client/format/index.d.ts.map +0 -1
  343. package/dist/types/client/getBrowserLocale.d.ts +0 -25
  344. package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
  345. package/dist/types/client/index.d.ts.map +0 -1
  346. package/dist/types/client/useLocaleCookie.d.ts +0 -17
  347. package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
  348. package/dist/types/editor/index.d.ts.map +0 -1
  349. package/dist/types/markdown/index.d.ts.map +0 -1
  350. package/dist/types/server/format/index.d.ts.map +0 -1
  351. package/dist/types/server/index.d.ts.map +0 -1
@@ -1,18 +1,36 @@
1
- "use client";
2
- import { units } from "@intlayer/core";
3
- import { useCallback, useContext } from "react";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "../IntlayerProvider.mjs";
5
+ import { useCallback, useContext } from "react";
6
+ import { units } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useUnit.ts
9
+ /**
10
+ * React hook that provides a unit formatting function
11
+ * based on the current locale from {@link useLocaleBase}.
12
+ *
13
+ * This hook wraps {@link createUnit} to return a formatter
14
+ * that can convert values into human-readable localized units
15
+ * (e.g., "10 km", "5 lbs").
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const formatUnit = useUnit();
20
+ * const distance = formatUnit(10, { unit: "kilometer" });
21
+ * // "10 km" (depending on locale)
22
+ * ```
23
+ *
24
+ * @returns {Function} A unit formatting function that accepts a value and optional formatting options.
25
+ */
5
26
  const useUnit = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => units(args[0], {
9
- ...args[1],
10
- locale: args[1]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- useUnit
27
+ const { locale } = useContext(IntlayerClientContext);
28
+ return useCallback((...args) => units(args[0], {
29
+ ...args[1],
30
+ locale: args[1]?.locale ?? locale
31
+ }), [locale]);
17
32
  };
33
+
34
+ //#endregion
35
+ export { useUnit };
18
36
  //# sourceMappingURL=useUnit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"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":";AAEA,SAAS,aAAa;AACtB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAmB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,MAAM,KAAK,CAAC,GAAG;AAAA,MACb,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"file":"useUnit.mjs","names":[],"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,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,MAAM,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,41 +1,13 @@
1
- import { getBrowserLocale } from "./getBrowserLocale.mjs";
2
- import {
3
- IntlayerClientContext,
4
- IntlayerProvider,
5
- IntlayerProviderContent,
6
- useIntlayerContext
7
- } from "./IntlayerProvider.mjs";
1
+ import { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./useLocaleStorage.mjs";
2
+ import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext } from "./IntlayerProvider.mjs";
8
3
  import { t } from "./t.mjs";
9
4
  import { useDictionary } from "./useDictionary.mjs";
10
5
  import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
6
+ import { useLoadDynamic } from "./useLoadDynamic.mjs";
11
7
  import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
12
8
  import { useI18n } from "./useI18n.mjs";
13
9
  import { useIntlayer } from "./useIntlayer.mjs";
14
- import { useLoadDynamic } from "./useLoadDynamic.mjs";
15
10
  import { useLocale } from "./useLocale.mjs";
16
11
  import { useLocaleBase } from "./useLocaleBase.mjs";
17
- import {
18
- localeCookie,
19
- setLocaleCookie,
20
- useLocaleCookie
21
- } from "./useLocaleCookie.mjs";
22
- export {
23
- IntlayerClientContext,
24
- IntlayerProvider,
25
- IntlayerProviderContent,
26
- getBrowserLocale,
27
- localeCookie,
28
- setLocaleCookie,
29
- t,
30
- useDictionary,
31
- useDictionaryAsync,
32
- useDictionaryDynamic,
33
- useI18n,
34
- useIntlayer,
35
- useIntlayerContext,
36
- useLoadDynamic,
37
- useLocale,
38
- useLocaleBase,
39
- useLocaleCookie
40
- };
41
- //# sourceMappingURL=index.mjs.map
12
+
13
+ export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage };
@@ -1,13 +1,21 @@
1
- "use client";
2
- import { getTranslation } from "@intlayer/core";
3
- import { useContext } from "react";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
+ import { useContext } from "react";
6
+ import { getTranslation } from "@intlayer/core";
7
+
8
+ //#region src/client/t.ts
9
+ /**
10
+ * On the client side, this function returns the translation of the provided multilang content.
11
+ *
12
+ * If the locale is not provided, it will use the locale from the client context
13
+ */
5
14
  const t = (multilangContent, locale) => {
6
- const { locale: currentLocale } = useContext(IntlayerClientContext);
7
- const localeTarget = locale ?? currentLocale;
8
- return getTranslation(multilangContent, localeTarget);
9
- };
10
- export {
11
- t
15
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
16
+ return getTranslation(multilangContent, locale ?? currentLocale);
12
17
  };
18
+
19
+ //#endregion
20
+ export { t };
13
21
  //# sourceMappingURL=t.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslation } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function 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 */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";AAGA,SAA+B,sBAAsB;AACrD,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAO/B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
1
+ {"version":3,"file":"t.mjs","names":[],"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 * On the client side, this function 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 */\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":";;;;;;;;;;;;;AAYA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;AAGnE,QAAO,eAAwB,kBAFV,UAAU,cAE+B"}
@@ -1,15 +1,27 @@
1
- "use client";
2
- import { useContext, useMemo } from "react";
3
- import { getDictionary } from "../getDictionary.mjs";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
+ import { getDictionary } from "../getDictionary.mjs";
6
+ import { useContext, useMemo } from "react";
7
+
8
+ //#region src/client/useDictionary.ts
9
+ /**
10
+ * On the server side, Hook that transform a dictionary and return the content
11
+ *
12
+ * If the locale is not provided, it will use the locale from the client context
13
+ */
5
14
  const useDictionary = (dictionary, locale) => {
6
- const { locale: currentLocale } = useContext(IntlayerClientContext);
7
- return useMemo(() => {
8
- const localeTarget = locale ?? currentLocale;
9
- return getDictionary(dictionary, localeTarget);
10
- }, [dictionary, currentLocale, locale]);
11
- };
12
- export {
13
- useDictionary
15
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
16
+ return useMemo(() => {
17
+ return getDictionary(dictionary, locale ?? currentLocale);
18
+ }, [
19
+ dictionary,
20
+ currentLocale,
21
+ locale
22
+ ]);
14
23
  };
24
+
25
+ //#endregion
26
+ export { useDictionary };
15
27
  //# sourceMappingURL=useDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { 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 = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n }, [dictionary, currentLocale, locale]);\n};\n"],"mappings":";AAIA,SAAS,YAAY,eAAe;AACpC,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAElE,SAAO,QAAQ,MAAM;AACnB,UAAM,eAAe,UAAU;AAE/B,WAAO,cAAgC,YAAY,YAAY;AAAA,EACjE,GAAG,CAAC,YAAY,eAAe,MAAM,CAAC;AACxC;","names":[]}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"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,kBAAkB,WAAW,sBAAsB;AAEnE,QAAO,cAAc;AAGnB,SAAO,cAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC;EAAY;EAAe;EAAO,CAAC"}
@@ -1,21 +1,23 @@
1
- "use client";
2
- import configuration from "@intlayer/config/built";
3
- import { useContext, useMemo } from "react";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  import { useDictionary } from "./useDictionary.mjs";
6
+ import { useContext, useMemo } from "react";
7
+ import configuration from "@intlayer/config/built";
8
+
9
+ //#region src/client/useDictionaryAsync.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
+ */
6
15
  const useDictionaryAsync = async (dictionaryPromise, locale) => {
7
- const { locale: currentLocale } = useContext(IntlayerClientContext);
8
- const localeTarget = useMemo(
9
- () => locale ?? currentLocale ?? configuration?.internationalization.defaultLocale,
10
- [currentLocale, locale]
11
- );
12
- const dictionary = await useMemo(
13
- async () => await dictionaryPromise[localeTarget](),
14
- [dictionaryPromise, localeTarget]
15
- );
16
- return useDictionary(dictionary, localeTarget);
17
- };
18
- export {
19
- useDictionaryAsync
16
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
17
+ const localeTarget = useMemo(() => locale ?? currentLocale ?? configuration?.internationalization.defaultLocale, [currentLocale, locale]);
18
+ return useDictionary(await useMemo(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
20
19
  };
20
+
21
+ //#endregion
22
+ export { useDictionaryAsync };
21
23
  //# sourceMappingURL=useDictionaryAsync.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary, LanguageContent } from '@intlayer/core';\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 <T extends Dictionary>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n locale?: LocalesValues\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>(dictionary, localeTarget) as any;\n};\n"],"mappings":";AAEA,OAAO,mBAAmB;AAG1B,SAAS,YAAY,eAAe;AACpC,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAOvB,MAAM,qBAAqB,OAChC,mBACA,WACe;AACf,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAElE,QAAM,eAAe;AAAA,IACnB,MACE,UACA,iBACA,eAAe,qBAAqB;AAAA,IACtC,CAAC,eAAe,MAAM;AAAA,EACxB;AAEA,QAAM,aAAa,MAAM;AAAA,IACvB,YACG,MAAM,kBACL,YACF,EAAG;AAAA,IACL,CAAC,mBAAmB,YAAY;AAAA,EAClC;AAEA,SAAO,cAAiB,YAAY,YAAY;AAClD;","names":[]}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"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,kBAAkB,WAAW,sBAAsB;CAEnE,MAAM,eAAe,cAEjB,UACA,iBACA,eAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAO,cARY,MAAM,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEsC,aAAkB"}
@@ -1,22 +1,24 @@
1
- "use client";
2
- import configuration from "@intlayer/config/built";
3
- import { useContext, useMemo } from "react";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  import { useDictionary } from "./useDictionary.mjs";
6
6
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
7
+ import { useContext, useMemo } from "react";
8
+ import configuration from "@intlayer/config/built";
9
+
10
+ //#region src/client/useDictionaryDynamic.ts
11
+ /**
12
+ * On the server side, Hook that transform a dictionary and return the content
13
+ *
14
+ * If the locale is not provided, it will use the locale from the client context
15
+ */
7
16
  const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
8
- const { locale: currentLocale } = useContext(IntlayerClientContext);
9
- const localeTarget = useMemo(
10
- () => locale ?? currentLocale ?? configuration?.internationalization.defaultLocale,
11
- [currentLocale, locale]
12
- );
13
- const dictionary = useLoadDynamic(
14
- `${String(key)}.${localeTarget}`,
15
- dictionaryPromise[localeTarget]()
16
- );
17
- return useDictionary(dictionary, localeTarget);
18
- };
19
- export {
20
- useDictionaryDynamic
17
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
18
+ const localeTarget = useMemo(() => locale ?? currentLocale ?? configuration?.internationalization.defaultLocale, [currentLocale, locale]);
19
+ return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
21
20
  };
21
+
22
+ //#endregion
23
+ export { useDictionaryDynamic };
22
24
  //# sourceMappingURL=useDictionaryDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n Dictionary,\n DictionaryKeys,\n LanguageContent,\n} from '@intlayer/core';\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: LanguageContent<() => 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[localeTarget]!()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";AAEA,OAAO,mBAAmB;AAO1B,SAAS,YAAY,eAAe;AACpC,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAOxB,MAAM,uBAAuB,CAIlC,mBACA,KACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe;AAAA,IACnB,MACE,UACA,iBACA,eAAe,qBAAqB;AAAA,IACtC,CAAC,eAAe,MAAM;AAAA,EACxB;AAEA,QAAM,aAAa;AAAA,IACjB,GAAG,OAAO,GAAG,CAAC,IAAI,YAAY;AAAA,IAC9B,kBAAkB,YAAY,EAAG;AAAA,EACnC;AAEA,SAAO,cAAc,YAAY,YAAY;AAC/C;","names":[]}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"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,kBAAkB,WAAW,sBAAsB;CACnE,MAAM,eAAe,cAEjB,UACA,iBACA,eAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
@@ -1,34 +1,45 @@
1
- "use client";
2
- import { getIntlayer } from "intlayer";
3
- import { useContext, useMemo } from "react";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
+ import { useContext, useMemo } from "react";
6
+ import { getIntlayer } from "@intlayer/core";
7
+
8
+ //#region src/client/useI18n.ts
9
+ /**
10
+ * Hook that provides a translation function `t()` for accessing nested content by key.
11
+ * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.
12
+ *
13
+ * @param namespace - The dictionary key to scope translations to
14
+ * @param locale - Optional locale override. If not provided, uses the current context locale
15
+ * @returns A translation function `t(key)` that returns the translated content for the given key
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const t = useI18n('IndexPage');
20
+ * const title = t('title'); // Returns translated string for 'IndexPage.title'
21
+ * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'
22
+ * // For attributes like `aria-label`, use `.value` to get the plain string
23
+ * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'
24
+ * ```
25
+ */
5
26
  const useI18n = (namespace, locale) => {
6
- const { locale: currentLocale } = useContext(IntlayerClientContext);
7
- const localeTarget = useMemo(
8
- () => locale ?? currentLocale,
9
- [currentLocale, locale]
10
- );
11
- let dictionaryContent = useMemo(
12
- () => getIntlayer(namespace, localeTarget),
13
- [namespace, localeTarget]
14
- );
15
- const t = (path) => {
16
- if (!path) {
17
- return dictionaryContent;
18
- }
19
- const pathArray = path.split(".");
20
- let current = dictionaryContent;
21
- for (const key of pathArray) {
22
- current = current?.[key];
23
- if (current === void 0) {
24
- return dictionaryContent;
25
- }
26
- }
27
- return current;
28
- };
29
- return t;
30
- };
31
- export {
32
- useI18n
27
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
28
+ const localeTarget = useMemo(() => locale ?? currentLocale, [currentLocale, locale]);
29
+ const dictionaryContent = useMemo(() => getIntlayer(namespace, localeTarget), [namespace, localeTarget]);
30
+ const t = (path) => {
31
+ if (!path) return dictionaryContent;
32
+ const pathArray = path.split(".");
33
+ let current = dictionaryContent;
34
+ for (const key of pathArray) {
35
+ current = current?.[key];
36
+ if (current === void 0) return dictionaryContent;
37
+ }
38
+ return current;
39
+ };
40
+ return t;
33
41
  };
42
+
43
+ //#endregion
44
+ export { useI18n };
34
45
  //# sourceMappingURL=useI18n.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n DictionaryKeys,\n GetSubPath,\n ValidDotPathsFor,\n} from '@intlayer/core';\nimport type { DeepTransformContent } from '../plugins';\n// @ts-ignore intlayer declared for module augmentation\nimport { getIntlayer, type IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <T extends DictionaryKeys>(\n namespace: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n let dictionaryContent: DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n > = useMemo(\n () => getIntlayer(namespace, localeTarget),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n ): GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']>,\n P\n > => {\n if (!path) {\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";AAUA,SAAS,mBAA0D;AACnE,SAAS,YAAY,eAAe;AACpC,SAAS,6BAA6B;AAmB/B,MAAM,UAAU,CACrB,WACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe;AAAA,IACnB,MAAM,UAAU;AAAA,IAChB,CAAC,eAAe,MAAM;AAAA,EACxB;AAGA,MAAI,oBAEA;AAAA,IACF,MAAM,YAAY,WAAW,YAAY;AAAA,IACzC,CAAC,WAAW,YAAY;AAAA,EAC1B;AAGA,QAAM,IAAI,CACR,SAIG;AACH,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAC3B,gBAAU,UAAU,GAAG;AACvB,UAAI,YAAY,QAAW;AAEzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"useI18n.mjs","names":["dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>>","current: any"],"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,kBAAkB,WAAW,sBAAsB;CACnE,MAAM,eAAe,cACb,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAID,MAAMA,oBACJ,cACQ,YAAkB,WAAW,aAAkB,EACrD,CAAC,WAAW,aAAa,CAC1B;CAIH,MAAM,KACJ,SAEsE;AACtE,MAAI,CAAC,KAEH,QAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAIC,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAC3B,aAAU,UAAU;AACpB,OAAI,YAAY,OAEd,QAAO;;AAIX,SAAO;;AAGT,QAAO"}
@@ -1,15 +1,29 @@
1
- "use client";
2
- import { useContext, useMemo } from "react";
3
- import { getIntlayer } from "../getIntlayer.mjs";
1
+ 'use client';
2
+
3
+
4
4
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
+ import { getIntlayer } from "../getIntlayer.mjs";
6
+ import { useContext, useMemo } from "react";
7
+
8
+ //#region src/client/useIntlayer.ts
9
+ /**
10
+ * On the client side, Hook that picking one dictionary by its key and return the content
11
+ *
12
+ * If the locale is not provided, it will use the locale from the client context
13
+ *
14
+ * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content
15
+ */
5
16
  const useIntlayer = (key, locale) => {
6
- const { locale: currentLocale } = useContext(IntlayerClientContext);
7
- return useMemo(() => {
8
- const localeTarget = locale ?? currentLocale;
9
- return getIntlayer(key, localeTarget);
10
- }, [key, currentLocale, locale]);
11
- };
12
- export {
13
- useIntlayer
17
+ const { locale: currentLocale } = useContext(IntlayerClientContext);
18
+ return useMemo(() => {
19
+ return getIntlayer(key, locale ?? currentLocale);
20
+ }, [
21
+ key,
22
+ currentLocale,
23
+ locale
24
+ ]);
14
25
  };
26
+
27
+ //#endregion
28
+ export { useIntlayer };
15
29
  //# sourceMappingURL=useIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n *\n * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getIntlayer(key, localeTarget) as any;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";AAMA,SAAS,YAAY,eAAe;AACpC,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AAS/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAElE,SAAO,QAAQ,MAAM;AACnB,UAAM,eAAe,UAAU;AAE/B,WAAO,YAAY,KAAK,YAAY;AAAA,EACtC,GAAG,CAAC,KAAK,eAAe,MAAM,CAAC;AACjC;","names":[]}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"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 * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n *\n * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content\n */\nexport const useIntlayer = <\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":";;;;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;AAEnE,QAAO,cAAc;AAGnB,SAAO,YAAkB,KAFJ,UAAW,cAEW;IAC1C;EAAC;EAAK;EAAe;EAAO,CAAC"}
@@ -1,32 +1,26 @@
1
+ //#region src/client/useLoadDynamic.ts
1
2
  const createSuspender = (promise) => {
2
- let status = "pending";
3
- let result;
4
- const suspender = promise.then(
5
- (r) => {
6
- status = "success";
7
- result = r;
8
- },
9
- (e) => {
10
- status = "error";
11
- result = e;
12
- }
13
- );
14
- return {
15
- read() {
16
- if (status === "pending") throw suspender;
17
- if (status === "error") throw result;
18
- return result;
19
- }
20
- };
3
+ let status = "pending";
4
+ let result;
5
+ const suspender = promise.then((r) => {
6
+ status = "success";
7
+ result = r;
8
+ }, (e) => {
9
+ status = "error";
10
+ result = e;
11
+ });
12
+ return { read() {
13
+ if (status === "pending") throw suspender;
14
+ if (status === "error") throw result;
15
+ return result;
16
+ } };
21
17
  };
22
18
  const cache = /* @__PURE__ */ new Map();
23
19
  const useLoadDynamic = (key, promise) => {
24
- if (!cache.has(key)) {
25
- cache.set(key, createSuspender(promise));
26
- }
27
- return cache.get(key).read();
28
- };
29
- export {
30
- useLoadDynamic
20
+ if (!cache.has(key)) cache.set(key, createSuspender(promise));
21
+ return cache.get(key).read();
31
22
  };
23
+
24
+ //#endregion
25
+ export { useLoadDynamic };
32
26
  //# sourceMappingURL=useLoadDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"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,kBAAkB,CAAI,YAAwB;AAClD,MAAI,SAAiB;AACrB,MAAI;AACJ,QAAM,YAAY,QAAQ;AAAA,IACxB,CAAC,MAAM;AACL,eAAS;AACT,eAAS;AAAA,IACX;AAAA,IACA,CAAC,MAAM;AACL,eAAS;AACT,eAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO;AACL,UAAI,WAAW,UAAW,OAAM;AAChC,UAAI,WAAW,QAAS,OAAM;AAC9B,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,MAAM,QAAQ,oBAAI,IAAgD;AAE3D,MAAM,iBAAiB,CAAI,KAAa,YAA2B;AACxE,MAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AACnB,UAAM,IAAI,KAAK,gBAAgB,OAAO,CAAC;AAAA,EACzC;AAEA,SAAQ,MAAM,IAAI,GAAG,EAA0C,KAAK;AACtE;","names":[]}
1
+ {"version":3,"file":"useLoadDynamic.mjs","names":["status: Status","result: T"],"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,IAAIA,SAAiB;CACrB,IAAIC;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,38 +1,38 @@
1
- "use client";
2
- import configuration from "@intlayer/config/built";
3
- import { useCallback, useContext } from "react";
1
+ 'use client';
2
+
3
+
4
+ import { setLocaleInStorage } from "./useLocaleStorage.mjs";
4
5
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
- import { useLocaleCookie } from "./useLocaleCookie.mjs";
6
- const useLocale = ({ onLocaleChange } = {}) => {
7
- const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
8
- const { locale, setLocale: setLocaleState } = useContext(
9
- IntlayerClientContext
10
- );
11
- const { setLocaleCookie } = useLocaleCookie();
12
- const setLocale = useCallback(
13
- (locale2) => {
14
- if (!availableLocales?.map(String).includes(locale2)) {
15
- console.error(`Locale ${locale2} is not available`);
16
- return;
17
- }
18
- setLocaleState(locale2);
19
- setLocaleCookie(locale2);
20
- onLocaleChange?.(locale2);
21
- },
22
- [availableLocales, onLocaleChange, setLocaleCookie, setLocaleState]
23
- );
24
- return {
25
- locale,
26
- // Current locale
27
- defaultLocale,
28
- // Principal locale defined in config
29
- availableLocales,
30
- // List of the available locales defined in config
31
- setLocale
32
- // Function to set the locale
33
- };
34
- };
35
- export {
36
- useLocale
6
+ import { useCallback, useContext } from "react";
7
+ import configuration from "@intlayer/config/built";
8
+
9
+ //#region src/client/useLocale.ts
10
+ /**
11
+ * On the client side, hook to get the current locale and all related fields
12
+ */
13
+ const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
14
+ const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
15
+ const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = useContext(IntlayerClientContext);
16
+ return {
17
+ locale,
18
+ defaultLocale,
19
+ availableLocales,
20
+ setLocale: useCallback((locale$1) => {
21
+ if (!availableLocales?.map(String).includes(locale$1)) {
22
+ console.error(`Locale ${locale$1} is not available`);
23
+ return;
24
+ }
25
+ setLocaleState(locale$1);
26
+ setLocaleInStorage(locale$1, isCookieEnabled ?? isCookieEnabledContext ?? true);
27
+ onLocaleChange?.(locale$1);
28
+ }, [
29
+ availableLocales,
30
+ onLocaleChange,
31
+ setLocaleState
32
+ ])
33
+ };
37
34
  };
35
+
36
+ //#endregion
37
+ export { useLocale };
38
38
  //# sourceMappingURL=useLocale.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const { locale, setLocale: setLocaleState } = useContext(\n IntlayerClientContext\n );\n const { setLocaleCookie } = useLocaleCookie();\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 setLocaleCookie(locale);\n onLocaleChange?.(locale);\n },\n [availableLocales, onLocaleChange, setLocaleCookie, setLocaleState]\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 };\n};\n"],"mappings":";AAEA,OAAO,mBAAmB;AAE1B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,eAAe,wBAAwB,CAAC;AAE1C,QAAM,EAAE,QAAQ,WAAW,eAAe,IAAI;AAAA,IAC5C;AAAA,EACF;AACA,QAAM,EAAE,gBAAgB,IAAI,gBAAgB;AAE5C,QAAM,YAAY;AAAA,IAChB,CAACA,YAA0B;AACzB,UAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAASA,OAAM,GAAG;AACnD,gBAAQ,MAAM,UAAUA,OAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,qBAAeA,OAAM;AACrB,sBAAgBA,OAAM;AACtB,uBAAiBA,OAAM;AAAA,IACzB;AAAA,IACA,CAAC,kBAAkB,gBAAgB,iBAAiB,cAAc;AAAA,EACpE;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["locale"]}
1
+ {"version":3,"file":"useLocale.mjs","names":["locale"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types';\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: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\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);\n },\n [availableLocales, onLocaleChange, setLocaleState]\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":";;;;;;;;;;;;AAuBA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,eAAe,wBAAwB,EAAE;CAE3C,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB;AAmBrC,QAAO;EACL;EACA;EACA;EACA,WArBgB,aACf,aAA0B;AACzB,OAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAASA,SAAO,EAAE;AACnD,YAAQ,MAAM,UAAUA,SAAO,mBAAmB;AAClD;;AAGF,kBAAeA,SAAO;AACtB,sBACEA,UACA,mBAAmB,0BAA0B,KAC9C;AACD,oBAAiBA,SAAO;KAE1B;GAAC;GAAkB;GAAgB;GAAe,CACnD;EAOA"}