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,62 +1,58 @@
1
- "use client";
1
+ 'use client';
2
+
3
+
4
+ import { IntlayerEditorProvider } from "../editor/IntlayerEditorProvider.mjs";
5
+ import { localeCookie, setLocaleInStorage as setLocaleInStorage$1 } from "./useLocaleStorage.mjs";
6
+ import { createContext, useContext } from "react";
2
7
  import { jsx } from "react/jsx-runtime";
3
- import configuration from "@intlayer/config/built";
4
8
  import { localeResolver } from "@intlayer/core";
5
9
  import { MessageKey, useCrossFrameState } from "@intlayer/editor-react";
6
- import {
7
- createContext,
8
- useContext
9
- } from "react";
10
- import { IntlayerEditorProvider } from "../editor/IntlayerEditorProvider.mjs";
11
- import { localeCookie, setLocaleCookie } from "./useLocaleCookie.mjs";
10
+ import configuration from "@intlayer/config/built";
11
+
12
+ //#region src/client/IntlayerProvider.tsx
13
+ /**
14
+ * Context that store the current locale on the client side
15
+ */
12
16
  const IntlayerClientContext = createContext({
13
- locale: localeCookie ?? configuration?.internationalization?.defaultLocale,
14
- setLocale: () => null,
15
- disableEditor: false
17
+ locale: localeCookie ?? configuration?.internationalization?.defaultLocale,
18
+ setLocale: () => null,
19
+ isCookieEnabled: true,
20
+ disableEditor: false
16
21
  });
22
+ /**
23
+ * Hook that provides the current locale
24
+ */
17
25
  const useIntlayerContext = () => useContext(IntlayerClientContext);
18
- const IntlayerProviderContent = ({
19
- locale: localeProp,
20
- defaultLocale: defaultLocaleProp,
21
- children,
22
- setLocale: setLocaleProp,
23
- disableEditor
24
- }) => {
25
- const { internationalization } = configuration ?? {};
26
- const { defaultLocale: defaultLocaleConfig, locales: availableLocales } = internationalization ?? {};
27
- const defaultLocale = localeProp ?? localeCookie ?? defaultLocaleProp ?? defaultLocaleConfig;
28
- const [currentLocale, setCurrentLocale] = useCrossFrameState(
29
- MessageKey.INTLAYER_CURRENT_LOCALE,
30
- defaultLocale
31
- );
32
- const setLocaleBase = (newLocale) => {
33
- if (currentLocale.toString() === newLocale.toString()) return;
34
- if (!availableLocales?.map(String).includes(newLocale)) {
35
- console.error(`Locale ${newLocale} is not available`);
36
- return;
37
- }
38
- setCurrentLocale(newLocale);
39
- setLocaleCookie(newLocale);
40
- };
41
- const setLocale = setLocaleProp ?? setLocaleBase;
42
- const resolvedLocale = localeResolver(localeProp ?? currentLocale);
43
- return /* @__PURE__ */ jsx(
44
- IntlayerClientContext.Provider,
45
- {
46
- value: {
47
- locale: resolvedLocale,
48
- setLocale,
49
- disableEditor
50
- },
51
- children
52
- }
53
- );
26
+ /**
27
+ * Provider that store the current locale on the client side
28
+ */
29
+ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
30
+ const { internationalization } = configuration ?? {};
31
+ const { defaultLocale: defaultLocaleConfig, locales: availableLocales } = internationalization ?? {};
32
+ const defaultLocale = localeProp ?? localeCookie ?? defaultLocaleProp ?? defaultLocaleConfig;
33
+ const [currentLocale, setCurrentLocale] = useCrossFrameState(MessageKey.INTLAYER_CURRENT_LOCALE, defaultLocale);
34
+ const setLocaleBase = (newLocale) => {
35
+ if (currentLocale.toString() === newLocale.toString()) return;
36
+ if (!availableLocales?.map(String).includes(newLocale)) {
37
+ console.error(`Locale ${newLocale} is not available`);
38
+ return;
39
+ }
40
+ setCurrentLocale(newLocale);
41
+ setLocaleInStorage$1(newLocale, isCookieEnabled);
42
+ };
43
+ const setLocale = setLocaleProp ?? setLocaleBase;
44
+ const resolvedLocale = localeResolver(localeProp ?? currentLocale);
45
+ return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, {
46
+ value: {
47
+ locale: resolvedLocale,
48
+ setLocale,
49
+ disableEditor
50
+ },
51
+ children
52
+ });
54
53
  };
55
54
  const IntlayerProvider = (props) => /* @__PURE__ */ jsx(IntlayerEditorProvider, { children: /* @__PURE__ */ jsx(IntlayerProviderContent, { ...props }) });
56
- export {
57
- IntlayerClientContext,
58
- IntlayerProvider,
59
- IntlayerProviderContent,
60
- useIntlayerContext
61
- };
55
+
56
+ //#endregion
57
+ export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext };
62
58
  //# sourceMappingURL=IntlayerProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\n\nimport { localeResolver } from '@intlayer/core';\nimport { MessageKey, useCrossFrameState } from '@intlayer/editor-react';\nimport {\n type FC,\n type PropsWithChildren,\n createContext,\n useContext,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren<{\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n}>;\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeCookie ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\n );\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";AAkFI;AAhFJ,OAAO,mBAAmB;AAG1B,SAAS,sBAAsB;AAC/B,SAAS,YAAY,0BAA0B;AAC/C;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,cAAc,uBAAuB;AAWvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,eAAe,sBAAsB;AAAA,EAC7D,WAAW,MAAM;AAAA,EACjB,eAAe;AACjB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAYjE,MAAM,0BAAqD,CAAC;AAAA,EACjE,QAAQ;AAAA,EACR,eAAe;AAAA,EACf;AAAA,EACA,WAAW;AAAA,EACX;AACF,MAAM;AACJ,QAAM,EAAE,qBAAqB,IAAI,iBAAiB,CAAC;AACnD,QAAM,EAAE,eAAe,qBAAqB,SAAS,iBAAiB,IACpE,wBAAwB,CAAC;AAE3B,QAAM,gBACJ,cAAc,gBAAgB,qBAAqB;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,WAAW;AAAA,IACX;AAAA,EACF;AAEA,QAAM,gBAAgB,CAAC,cAA6B;AAClD,QAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,QAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;AACtD,cAAQ,MAAM,UAAU,SAAS,mBAAmB;AACpD;AAAA,IACF;AAEA,qBAAiB,SAAS;AAC1B,oBAAgB,SAAS;AAAA,EAC3B;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,iBAAiB,eAAe,cAAc,aAAa;AAEjE,SACE;AAAA,IAAC,sBAAsB;AAAA,IAAtB;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEO,MAAM,mBAA8C,CAAC,UAC1D,oBAAC,0BACC,8BAAC,2BAAyB,GAAG,OAAO,GACtC;","names":[]}
1
+ {"version":3,"file":"IntlayerProvider.mjs","names":["IntlayerProviderContent: FC<IntlayerProviderProps>","IntlayerProvider: FC<IntlayerProviderProps>"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core';\nimport { MessageKey, useCrossFrameState } from '@intlayer/editor-react';\nimport type { LocalesValues } from '@intlayer/types';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { localeCookie, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren<{\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeCookie ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\n );\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;AAyBA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,gBAAgB,eAAe,sBAAsB;CAC7D,iBAAiB;CACjB,iBAAiB;CACjB,eAAe;CAChB,CAAC;;;;AAKF,MAAa,2BAA2B,WAAW,sBAAsB;;;;AAazE,MAAaA,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyB,iBAAiB,EAAE;CACpD,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnD,wBAAwB,EAAE;CAE5B,MAAM,gBACJ,cAAc,gBAAgB,qBAAqB;CAErD,MAAM,CAAC,eAAe,oBAAoB,mBACxC,WAAW,yBACX,cACD;CAED,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,uBAAmB,WAAW,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iBAAiB,eAAe,cAAc,cAAc;AAElE,QACE,oBAAC,sBAAsB;EACrB,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;GAC8B;;AAIrC,MAAaC,oBAA+C,UAC1D,oBAAC,oCACC,oBAAC,2BAAwB,GAAI,QAAS,GACf"}
@@ -6,14 +6,5 @@ import { useNumber } from "./useNumber.mjs";
6
6
  import { usePercentage } from "./usePercentage.mjs";
7
7
  import { useRelativeTime } from "./useRelativeTime.mjs";
8
8
  import { useUnit } from "./useUnit.mjs";
9
- export {
10
- useCompact,
11
- useCurrency,
12
- useDate,
13
- useList,
14
- useNumber,
15
- usePercentage,
16
- useRelativeTime,
17
- useUnit
18
- };
19
- //# sourceMappingURL=index.mjs.map
9
+
10
+ export { useCompact, useCurrency, useDate, useList, useNumber, usePercentage, useRelativeTime, useUnit };
@@ -1,18 +1,29 @@
1
- "use client";
2
- import { compact } 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 { compact } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useCompact.ts
9
+ /**
10
+ * React client hook that provides a compact number formatter
11
+ * bound to the current application locale.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const formatCompact = useCompact();
16
+ * formatCompact(1500); // "1.5K"
17
+ * ```
18
+ */
5
19
  const useCompact = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => compact(args[0], {
9
- ...args[1],
10
- locale: args[1]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- useCompact
20
+ const { locale } = useContext(IntlayerClientContext);
21
+ return useCallback((...args) => compact(args[0], {
22
+ ...args[1],
23
+ locale: args[1]?.locale ?? locale
24
+ }), [locale]);
17
25
  };
26
+
27
+ //#endregion
28
+ export { useCompact };
18
29
  //# sourceMappingURL=useCompact.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,eAAe;AACxB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAY/B,MAAM,aAAa,MAAM;AAC9B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,QAAQ,KAAK,CAAC,GAAG;AAAA,MACf,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":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,18 +1,43 @@
1
- "use client";
2
- import { currency } 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 { currency } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useCurrency.ts
9
+ /**
10
+ * React client hook that provides a currency formatter
11
+ * bound to the current application locale.
12
+ *
13
+ * @returns {(value: string | number, options?: CurrencyProps) => string}
14
+ * A function to format numbers into localized currency strings.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const formatCurrency = useCurrency();
19
+ *
20
+ * formatCurrency(1500, { currency: "USD" });
21
+ * // "$1,500.00"
22
+ *
23
+ * formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
24
+ * // "1.500,00 €"
25
+ *
26
+ * formatCurrency(9876543.21, {
27
+ * currency: "JPY",
28
+ * fractionDigits: 0,
29
+ * });
30
+ * // "¥9,876,543"
31
+ * ```
32
+ */
5
33
  const useCurrency = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => currency(args[0], {
9
- ...args[1],
10
- locale: args[1]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- useCurrency
34
+ const { locale } = useContext(IntlayerClientContext);
35
+ return useCallback((...args) => currency(args[0], {
36
+ ...args[1],
37
+ locale: args[1]?.locale ?? locale
38
+ }), [locale]);
17
39
  };
40
+
41
+ //#endregion
42
+ export { useCurrency };
18
43
  //# sourceMappingURL=useCurrency.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AA0B/B,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,SAAS,KAAK,CAAC,GAAG;AAAA,MAChB,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":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,15 +1,45 @@
1
- "use client";
2
- import { date } 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 { date } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useDate.ts
9
+ /**
10
+ * React client hook that provides a localized date/time formatter
11
+ * bound to the current application locale.
12
+ *
13
+ * @returns {(date: Date | string | number, options?: DateProps) => string}
14
+ * A function to format dates or timestamps into localized date/time strings.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const formatDate = useDate();
19
+ *
20
+ * formatDate(new Date("2025-01-01"));
21
+ * // "Jan 1, 2025"
22
+ *
23
+ * formatDate("2025-01-01T15:30:00Z", {
24
+ * dateStyle: "full",
25
+ * timeStyle: "short",
26
+ * });
27
+ * // "Wednesday, January 1, 2025 at 3:30 PM"
28
+ *
29
+ * formatDate(1735689600000, { locale: "fr-FR", dateStyle: "long" });
30
+ * // "1 janvier 2025"
31
+ * ```
32
+ *
33
+ * @see createDate
34
+ */
5
35
  const useDate = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return (...args) => date(args[0], {
8
- ...args[1],
9
- locale: args[1]?.locale ?? locale
10
- });
11
- };
12
- export {
13
- useDate
36
+ const { locale } = useContext(IntlayerClientContext);
37
+ return (...args) => date(args[0], {
38
+ ...args[1],
39
+ locale: args[1]?.locale ?? locale
40
+ });
14
41
  };
42
+
43
+ //#endregion
44
+ export { useDate };
15
45
  //# sourceMappingURL=useDate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";AAEA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AA4B/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO,IAAI,SACT,KAAK,KAAK,CAAC,GAAG;AAAA,IACZ,GAAG,KAAK,CAAC;AAAA,IACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,EAC7B,CAAC;AACL;","names":[]}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,SAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
@@ -1,18 +1,40 @@
1
- "use client";
2
- import { list } 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 { list } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useList.ts
9
+ /**
10
+ * React client hook that provides a list formatter
11
+ * bound to the current application locale.
12
+ *
13
+ * @returns {(values: (string | number)[], options?: ListProps) => string}
14
+ * A function to format arrays into localized list strings.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const formatList = useList();
19
+ *
20
+ * formatList(['apple', 'banana', 'orange']);
21
+ * // "apple, banana, and orange"
22
+ *
23
+ * formatList(['red', 'green', 'blue'], { type: 'disjunction' });
24
+ * // "red, green, or blue"
25
+ *
26
+ * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });
27
+ * // "1, 2 und 3"
28
+ * ```
29
+ */
5
30
  const useList = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => list(args[0], {
9
- ...args[1],
10
- locale: args[1]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- useList
31
+ const { locale } = useContext(IntlayerClientContext);
32
+ return useCallback((...args) => list(args[0], {
33
+ ...args[1],
34
+ locale: args[1]?.locale ?? locale
35
+ }), [locale]);
17
36
  };
37
+
38
+ //#endregion
39
+ export { useList };
18
40
  //# sourceMappingURL=useList.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";AAEA,SAAS,YAAY;AACrB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAuB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,KAAK,KAAK,CAAC,GAAG;AAAA,MACZ,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":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,18 +1,41 @@
1
- "use client";
2
- import { number } 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 { number } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useNumber.ts
9
+ /**
10
+ * React client hook that provides a localized number formatter.
11
+ *
12
+ * Uses the current locale from {@link useLocaleBase} and returns
13
+ * a function that can be used to format numbers consistently
14
+ * according to the user's locale.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const formatNumber = useNumber();
19
+ *
20
+ * formatNumber(12345);
21
+ * // e.g. "12,345" (en-US)
22
+ * // e.g. "12 345" (fr-FR)
23
+ *
24
+ * formatNumber(0.75, { style: "percent" });
25
+ * // e.g. "75%"
26
+ * ```
27
+ *
28
+ * @returns {(value: string | number, options?: import("../createNumber").NumberProps) => string}
29
+ * A number formatting function bound to the active locale.
30
+ */
5
31
  const useNumber = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => number(args[0], {
9
- ...args[1],
10
- locale: args[1]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- useNumber
32
+ const { locale } = useContext(IntlayerClientContext);
33
+ return useCallback((...args) => number(args[0], {
34
+ ...args[1],
35
+ locale: args[1]?.locale ?? locale
36
+ }), [locale]);
17
37
  };
38
+
39
+ //#endregion
40
+ export { useNumber };
18
41
  //# sourceMappingURL=useNumber.mjs.map
@@ -1 +1 @@
1
- {"version":3,"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":";AAEA,SAAS,cAAc;AACvB,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAwB/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,OAAO,KAAK,CAAC,GAAG;AAAA,MACd,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":"useNumber.mjs","names":[],"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,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,18 +1,37 @@
1
- "use client";
2
- import { percentage } 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 { percentage } from "@intlayer/core";
7
+
8
+ //#region src/client/format/usePercentage.ts
9
+ /**
10
+ * React hook to provide a percentage formatter function
11
+ * based on the current application locale.
12
+ *
13
+ * This hook retrieves the active locale using {@link useLocaleBase}
14
+ * and memoizes a `createPercentage` instance for that locale.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const formatPercentage = usePercentage();
19
+ *
20
+ * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });
21
+ * // "87.5%" (depending on locale)
22
+ * ```
23
+ *
24
+ * @returns {(value: string | number, options?: Omit<PercentageOptions, "value">) => string}
25
+ * A function that formats numbers or numeric strings into localized percentages.
26
+ */
5
27
  const usePercentage = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => percentage(args[0], {
9
- ...args[1],
10
- locale: args[1]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- usePercentage
28
+ const { locale } = useContext(IntlayerClientContext);
29
+ return useCallback((...args) => percentage(args[0], {
30
+ ...args[1],
31
+ locale: args[1]?.locale ?? locale
32
+ }), [locale]);
17
33
  };
34
+
35
+ //#endregion
36
+ export { usePercentage };
18
37
  //# sourceMappingURL=usePercentage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"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":";AAEA,SAAS,kBAAkB;AAC3B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAoB/B,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,WAAW,KAAK,CAAC,GAAG;AAAA,MAClB,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":"usePercentage.mjs","names":[],"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,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,18 +1,37 @@
1
- "use client";
2
- import { relativeTime } 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 { relativeTime } from "@intlayer/core";
7
+
8
+ //#region src/client/format/useRelativeTime.ts
9
+ /**
10
+ * Client-side React hook for accessing a localized relative time formatter.
11
+ *
12
+ * This hook:
13
+ * - Reads the current locale from {@link useLocaleBase}.
14
+ * - Creates a new relative time formatter with {@link createRelativeTime}.
15
+ * - Returns a function that can format time differences into localized strings.
16
+ *
17
+ * Example:
18
+ * ```tsx
19
+ * const relativeTime = useRelativeTime();
20
+ * const formatted = relativeTime(new Date("2024-08-01"), new Date());
21
+ * // e.g., "2 weeks ago"
22
+ * ```
23
+ *
24
+ * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
25
+ * bound to the current client locale.
26
+ */
5
27
  const useRelativeTime = () => {
6
- const { locale } = useContext(IntlayerClientContext);
7
- return useCallback(
8
- (...args) => relativeTime(args[0], args[1], {
9
- ...args[2],
10
- locale: args[2]?.locale ?? locale
11
- }),
12
- [locale]
13
- );
14
- };
15
- export {
16
- useRelativeTime
28
+ const { locale } = useContext(IntlayerClientContext);
29
+ return useCallback((...args) => relativeTime(args[0], args[1], {
30
+ ...args[2],
31
+ locale: args[2]?.locale ?? locale
32
+ }), [locale]);
17
33
  };
34
+
35
+ //#endregion
36
+ export { useRelativeTime };
18
37
  //# sourceMappingURL=useRelativeTime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"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":";AAEA,SAAS,oBAAoB;AAC7B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AAoB/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL,IAAI,SACF,aAAa,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG;AAAA,MAC7B,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":"useRelativeTime.mjs","names":[],"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,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,aAAa,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}