react-intlayer 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/dist/cjs/IntlayerNode.cjs +1 -17
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +1 -96
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  6. package/dist/cjs/client/IntlayerProvider.cjs +1 -92
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +1 -20
  9. package/dist/cjs/client/format/useCompact.cjs +1 -29
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +1 -43
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +1 -45
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useIntl.cjs +1 -45
  16. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  17. package/dist/cjs/client/format/useList.cjs +1 -40
  18. package/dist/cjs/client/format/useList.cjs.map +1 -1
  19. package/dist/cjs/client/format/useNumber.cjs +1 -41
  20. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  21. package/dist/cjs/client/format/usePercentage.cjs +1 -37
  22. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  23. package/dist/cjs/client/format/useRelativeTime.cjs +1 -37
  24. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  25. package/dist/cjs/client/format/useUnit.cjs +1 -36
  26. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  27. package/dist/cjs/client/index.cjs +1 -34
  28. package/dist/cjs/client/t.cjs +1 -40
  29. package/dist/cjs/client/t.cjs.map +1 -1
  30. package/dist/cjs/client/useDictionary.cjs +1 -27
  31. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
  33. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  34. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
  35. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  36. package/dist/cjs/client/useI18n.cjs +1 -45
  37. package/dist/cjs/client/useI18n.cjs.map +1 -1
  38. package/dist/cjs/client/useIntlayer.cjs +1 -42
  39. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  40. package/dist/cjs/client/useLoadDynamic.cjs +1 -27
  41. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  42. package/dist/cjs/client/useLocale.cjs +1 -60
  43. package/dist/cjs/client/useLocale.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleBase.cjs +1 -26
  45. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  46. package/dist/cjs/client/useLocaleStorage.cjs +1 -61
  47. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  48. package/dist/cjs/client/useRewriteURL.cjs +1 -42
  49. package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
  50. package/dist/cjs/client/useTraduction.cjs +1 -35
  51. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  52. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -55
  53. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  54. package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -61
  55. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  56. package/dist/cjs/editor/index.cjs +1 -4
  57. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -40
  58. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  59. package/dist/cjs/getDictionary.cjs +1 -19
  60. package/dist/cjs/getDictionary.cjs.map +1 -1
  61. package/dist/cjs/getIntlayer.cjs +1 -19
  62. package/dist/cjs/getIntlayer.cjs.map +1 -1
  63. package/dist/cjs/html/HTMLProvider.cjs +1 -18
  64. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  65. package/dist/cjs/html/HTMLRenderer.cjs +1 -59
  66. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  67. package/dist/cjs/html/HTMLRendererPlugin.cjs +1 -36
  68. package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
  69. package/dist/cjs/html/index.cjs +1 -12
  70. package/dist/cjs/index.cjs +1 -52
  71. package/dist/cjs/markdown/MarkdownProvider.cjs +1 -77
  72. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  73. package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -199
  74. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  75. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -33
  76. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  77. package/dist/cjs/markdown/index.cjs +1 -25
  78. package/dist/cjs/markdown/processor.cjs +1 -66
  79. package/dist/cjs/markdown/processor.cjs.map +1 -1
  80. package/dist/cjs/markdown/runtime.cjs +1 -43
  81. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  82. package/dist/cjs/plugins.cjs +1 -179
  83. package/dist/cjs/plugins.cjs.map +1 -1
  84. package/dist/cjs/reactElement/renderReactElement.cjs +1 -52
  85. package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
  86. package/dist/cjs/server/IntlayerServerProvider.cjs +1 -34
  87. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  88. package/dist/cjs/server/format/index.cjs +1 -18
  89. package/dist/cjs/server/format/useCompact.cjs +1 -27
  90. package/dist/cjs/server/format/useCompact.cjs.map +1 -1
  91. package/dist/cjs/server/format/useCurrency.cjs +1 -38
  92. package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
  93. package/dist/cjs/server/format/useDate.cjs +1 -43
  94. package/dist/cjs/server/format/useDate.cjs.map +1 -1
  95. package/dist/cjs/server/format/useIntl.cjs +1 -44
  96. package/dist/cjs/server/format/useIntl.cjs.map +1 -1
  97. package/dist/cjs/server/format/useList.cjs +1 -35
  98. package/dist/cjs/server/format/useList.cjs.map +1 -1
  99. package/dist/cjs/server/format/useNumber.cjs +1 -39
  100. package/dist/cjs/server/format/useNumber.cjs.map +1 -1
  101. package/dist/cjs/server/format/usePercentage.cjs +1 -35
  102. package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
  103. package/dist/cjs/server/format/useRelativeTime.cjs +1 -35
  104. package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
  105. package/dist/cjs/server/format/useUnit.cjs +1 -34
  106. package/dist/cjs/server/format/useUnit.cjs.map +1 -1
  107. package/dist/cjs/server/index.cjs +1 -24
  108. package/dist/cjs/server/serverContext.cjs +1 -58
  109. package/dist/cjs/server/serverContext.cjs.map +1 -1
  110. package/dist/cjs/server/t.cjs +1 -35
  111. package/dist/cjs/server/t.cjs.map +1 -1
  112. package/dist/cjs/server/useDictionary.cjs +1 -17
  113. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  114. package/dist/cjs/server/useDictionaryAsync.cjs +1 -21
  115. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  116. package/dist/cjs/server/useDictionaryDynamic.cjs +1 -22
  117. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  118. package/dist/cjs/server/useI18n.cjs +1 -38
  119. package/dist/cjs/server/useI18n.cjs.map +1 -1
  120. package/dist/cjs/server/useIntlayer.cjs +1 -17
  121. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  122. package/dist/cjs/server/useLoadDynamic.cjs +1 -14
  123. package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
  124. package/dist/cjs/server/useLocale.cjs +1 -24
  125. package/dist/cjs/server/useLocale.cjs.map +1 -1
  126. package/dist/esm/IntlayerNode.mjs +1 -15
  127. package/dist/esm/IntlayerNode.mjs.map +1 -1
  128. package/dist/esm/UI/ContentSelector.mjs +1 -94
  129. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  130. package/dist/esm/client/IntlayerProvider.mjs +1 -86
  131. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  132. package/dist/esm/client/format/index.mjs +1 -11
  133. package/dist/esm/client/format/useCompact.mjs +1 -27
  134. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  135. package/dist/esm/client/format/useCurrency.mjs +1 -41
  136. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  137. package/dist/esm/client/format/useDate.mjs +1 -43
  138. package/dist/esm/client/format/useDate.mjs.map +1 -1
  139. package/dist/esm/client/format/useIntl.mjs +1 -43
  140. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  141. package/dist/esm/client/format/useList.mjs +1 -38
  142. package/dist/esm/client/format/useList.mjs.map +1 -1
  143. package/dist/esm/client/format/useNumber.mjs +1 -39
  144. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  145. package/dist/esm/client/format/usePercentage.mjs +1 -35
  146. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  147. package/dist/esm/client/format/useRelativeTime.mjs +1 -35
  148. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  149. package/dist/esm/client/format/useUnit.mjs +1 -34
  150. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  151. package/dist/esm/client/index.mjs +1 -14
  152. package/dist/esm/client/t.mjs +1 -38
  153. package/dist/esm/client/t.mjs.map +1 -1
  154. package/dist/esm/client/useDictionary.mjs +1 -25
  155. package/dist/esm/client/useDictionary.mjs.map +1 -1
  156. package/dist/esm/client/useDictionaryAsync.mjs +1 -21
  157. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  158. package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
  159. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  160. package/dist/esm/client/useI18n.mjs +1 -43
  161. package/dist/esm/client/useI18n.mjs.map +1 -1
  162. package/dist/esm/client/useIntlayer.mjs +1 -40
  163. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  164. package/dist/esm/client/useLoadDynamic.mjs +1 -25
  165. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  166. package/dist/esm/client/useLocale.mjs +1 -57
  167. package/dist/esm/client/useLocale.mjs.map +1 -1
  168. package/dist/esm/client/useLocaleBase.mjs +1 -23
  169. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  170. package/dist/esm/client/useLocaleStorage.mjs +1 -54
  171. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  172. package/dist/esm/client/useRewriteURL.mjs +1 -39
  173. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  174. package/dist/esm/client/useTraduction.mjs +1 -33
  175. package/dist/esm/client/useTraduction.mjs.map +1 -1
  176. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -53
  177. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  178. package/dist/esm/editor/IntlayerEditorProvider.mjs +1 -58
  179. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  180. package/dist/esm/editor/index.mjs +1 -3
  181. package/dist/esm/editor/useEditedContentRenderer.mjs +1 -37
  182. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  183. package/dist/esm/getDictionary.mjs +1 -17
  184. package/dist/esm/getDictionary.mjs.map +1 -1
  185. package/dist/esm/getIntlayer.mjs +1 -17
  186. package/dist/esm/getIntlayer.mjs.map +1 -1
  187. package/dist/esm/html/HTMLProvider.mjs +1 -15
  188. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  189. package/dist/esm/html/HTMLRenderer.mjs +1 -54
  190. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  191. package/dist/esm/html/HTMLRendererPlugin.mjs +1 -34
  192. package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
  193. package/dist/esm/html/index.mjs +1 -5
  194. package/dist/esm/index.mjs +1 -21
  195. package/dist/esm/markdown/MarkdownProvider.mjs +1 -74
  196. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  197. package/dist/esm/markdown/MarkdownRenderer.mjs +1 -195
  198. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  199. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -30
  200. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  201. package/dist/esm/markdown/index.mjs +1 -7
  202. package/dist/esm/markdown/processor.mjs +1 -58
  203. package/dist/esm/markdown/processor.mjs.map +1 -1
  204. package/dist/esm/markdown/runtime.mjs +1 -39
  205. package/dist/esm/markdown/runtime.mjs.map +1 -1
  206. package/dist/esm/plugins.mjs +1 -172
  207. package/dist/esm/plugins.mjs.map +1 -1
  208. package/dist/esm/reactElement/renderReactElement.mjs +1 -50
  209. package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
  210. package/dist/esm/server/IntlayerServerProvider.mjs +1 -28
  211. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  212. package/dist/esm/server/format/index.mjs +1 -10
  213. package/dist/esm/server/format/useCompact.mjs +1 -25
  214. package/dist/esm/server/format/useCompact.mjs.map +1 -1
  215. package/dist/esm/server/format/useCurrency.mjs +1 -36
  216. package/dist/esm/server/format/useCurrency.mjs.map +1 -1
  217. package/dist/esm/server/format/useDate.mjs +1 -41
  218. package/dist/esm/server/format/useDate.mjs.map +1 -1
  219. package/dist/esm/server/format/useIntl.mjs +1 -41
  220. package/dist/esm/server/format/useIntl.mjs.map +1 -1
  221. package/dist/esm/server/format/useList.mjs +1 -33
  222. package/dist/esm/server/format/useList.mjs.map +1 -1
  223. package/dist/esm/server/format/useNumber.mjs +1 -37
  224. package/dist/esm/server/format/useNumber.mjs.map +1 -1
  225. package/dist/esm/server/format/usePercentage.mjs +1 -33
  226. package/dist/esm/server/format/usePercentage.mjs.map +1 -1
  227. package/dist/esm/server/format/useRelativeTime.mjs +1 -33
  228. package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
  229. package/dist/esm/server/format/useUnit.mjs +1 -32
  230. package/dist/esm/server/format/useUnit.mjs.map +1 -1
  231. package/dist/esm/server/index.mjs +1 -12
  232. package/dist/esm/server/serverContext.mjs +1 -54
  233. package/dist/esm/server/serverContext.mjs.map +1 -1
  234. package/dist/esm/server/t.mjs +1 -33
  235. package/dist/esm/server/t.mjs.map +1 -1
  236. package/dist/esm/server/useDictionary.mjs +1 -16
  237. package/dist/esm/server/useDictionary.mjs.map +1 -1
  238. package/dist/esm/server/useDictionaryAsync.mjs +1 -18
  239. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  240. package/dist/esm/server/useDictionaryDynamic.mjs +1 -19
  241. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  242. package/dist/esm/server/useI18n.mjs +1 -37
  243. package/dist/esm/server/useI18n.mjs.map +1 -1
  244. package/dist/esm/server/useIntlayer.mjs +1 -16
  245. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  246. package/dist/esm/server/useLoadDynamic.mjs +1 -11
  247. package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
  248. package/dist/esm/server/useLocale.mjs +1 -21
  249. package/dist/esm/server/useLocale.mjs.map +1 -1
  250. package/dist/types/IntlayerNode.d.ts +1 -1
  251. package/dist/types/client/format/useDate.d.ts +1 -1
  252. package/dist/types/client/useDictionary.d.ts +2 -2
  253. package/dist/types/client/useDictionary.d.ts.map +1 -1
  254. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  255. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  256. package/dist/types/client/useI18n.d.ts +3 -3
  257. package/dist/types/client/useI18n.d.ts.map +1 -1
  258. package/dist/types/client/useIntlayer.d.ts +2 -2
  259. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  260. package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
  261. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  262. package/dist/types/getDictionary.d.ts +1 -1
  263. package/dist/types/getIntlayer.d.ts +1 -1
  264. package/dist/types/getIntlayer.d.ts.map +1 -1
  265. package/dist/types/html/HTMLComponentTypes.d.ts +1 -1
  266. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  267. package/dist/types/index.d.ts +1 -1
  268. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  269. package/dist/types/markdown/processor.d.ts +1 -1
  270. package/dist/types/markdown/runtime.d.ts +1 -1
  271. package/dist/types/plugins.d.ts +1 -1
  272. package/dist/types/plugins.d.ts.map +1 -1
  273. package/dist/types/server/format/useCompact.d.ts +1 -1
  274. package/dist/types/server/format/useCurrency.d.ts +1 -1
  275. package/dist/types/server/format/useDate.d.ts +1 -1
  276. package/dist/types/server/format/useList.d.ts +1 -1
  277. package/dist/types/server/format/useNumber.d.ts +1 -1
  278. package/dist/types/server/format/usePercentage.d.ts +1 -1
  279. package/dist/types/server/format/useRelativeTime.d.ts +1 -1
  280. package/dist/types/server/format/useUnit.d.ts +1 -1
  281. package/dist/types/server/useDictionary.d.ts +2 -2
  282. package/dist/types/server/useDictionary.d.ts.map +1 -1
  283. package/dist/types/server/useDictionaryAsync.d.ts +2 -2
  284. package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
  285. package/dist/types/server/useDictionaryDynamic.d.ts +2 -2
  286. package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
  287. package/dist/types/server/useI18n.d.ts +3 -3
  288. package/dist/types/server/useI18n.d.ts.map +1 -1
  289. package/dist/types/server/useIntlayer.d.ts +2 -2
  290. package/dist/types/server/useIntlayer.d.ts.map +1 -1
  291. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLContent,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type InsertionContent,\n type MarkdownContent,\n type Plugins,\n splitInsertionTemplate,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelectorRenderer } from './editor';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <EditedContentRenderer {...rest}>{rest.children}</EditedContentRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node?.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n {renderReactElement(node)}\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeType.Enumeration, NodeType.Condition].includes(\n children.nodeType as NodeType\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components: HTMLComponents<'permissive', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRendererPlugin {...rest} {...(components ?? {})}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n createElement(HTMLRendererPlugin, { ...rest, html, userComponents });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":"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"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type Plugins,\n splitInsertionTemplate,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelectorRenderer } from './editor';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <EditedContentRenderer {...rest}>{rest.children}</EditedContentRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node?.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n {renderReactElement(node)}\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n values: V\n ) => V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<ReactNode>\n : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | ReactNode>\n): ReactNode => {\n const result = splitInsertionTemplate(template, values);\n\n if (result.isSimple) {\n // Simple string replacement\n return result.parts as string;\n }\n\n // Return as Fragment with proper keys\n return createElement(\n Fragment,\n null,\n ...(result.parts as any[]).map((part, index) =>\n createElement(Fragment, { key: index }, part)\n )\n );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | ReactNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeType.Enumeration, NodeType.Condition].includes(\n children.nodeType as NodeType\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components: HTMLComponents<'permissive', {}>) => ReactNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: HTMLComponents) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRendererPlugin {...rest} {...(components ?? {})}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: HTMLComponents) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): ReactNode =>\n createElement(HTMLRendererPlugin, { ...rest, html, userComponents });\n\n const element = render() as ReactElement;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n reactNode: ReactNodeCond<T>;\n reactIntlayerNode: IntlayerNodeCond<T>;\n reactInsertion: InsertionCond<T>;\n reactMarkdown: MarkdownCond<T>;\n reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n reactNode: true;\n reactIntlayerNode: true;\n reactMarkdown: true;\n reactHtml: true;\n reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":"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"}
@@ -1,51 +1,2 @@
1
- import { createElement } from "react";
2
-
3
- //#region src/reactElement/renderReactElement.ts
4
- const renderReactElement = (element) => {
5
- if (element === null || typeof element !== "object") return element;
6
- const convertChildrenAsArray = (element) => {
7
- const children = element.props?.children;
8
- if (Array.isArray(children)) {
9
- const childrenResult = children.map((child, index) => {
10
- const renderedChild = renderReactElement(child);
11
- if (typeof renderedChild === "object" && renderedChild !== null && "type" in renderedChild) {
12
- const childElement = renderedChild;
13
- return createElement(childElement.type, {
14
- ...childElement.props,
15
- key: index
16
- }, ...Array.isArray(childElement.props?.children) ? childElement.props.children : typeof childElement.props?.children !== "undefined" ? [childElement.props.children] : []);
17
- }
18
- return renderedChild;
19
- });
20
- return {
21
- ...element,
22
- props: {
23
- ...element.props,
24
- children: childrenResult
25
- }
26
- };
27
- } else if (typeof children !== "undefined" && children !== null) {
28
- const renderedChild = renderReactElement(children);
29
- return {
30
- ...element,
31
- props: {
32
- ...element.props,
33
- children: [renderedChild]
34
- }
35
- };
36
- }
37
- return {
38
- ...element,
39
- props: {
40
- ...element.props,
41
- children: []
42
- }
43
- };
44
- };
45
- const { type, props } = convertChildrenAsArray(element);
46
- return createElement(type ?? "span", props, ...props.children);
47
- };
48
-
49
- //#endregion
50
- export { renderReactElement };
1
+ import{createElement as e}from"react";const t=n=>{if(typeof n!=`object`||!n)return n;let{type:r,props:i}=(n=>{let r=n.props?.children;if(Array.isArray(r)){let i=r.map((n,r)=>{let i=t(n);if(typeof i==`object`&&i&&`type`in i){let t=i;return e(t.type,{...t.props,key:r},...Array.isArray(t.props?.children)?t.props.children:t.props?.children===void 0?[]:[t.props.children])}return i});return{...n,props:{...n.props,children:i}}}else if(r!=null){let e=t(r);return{...n,props:{...n.props,children:[e]}}}return{...n,props:{...n.props,children:[]}}})(n);return e(r??`span`,i,...i.children)};export{t as renderReactElement};
51
2
  //# sourceMappingURL=renderReactElement.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderReactElement.mjs","names":[],"sources":["../../../src/reactElement/renderReactElement.ts"],"sourcesContent":["import { createElement, type ReactElement, type ReactNode } from 'react';\n\n// This function recursively creates React elements from a given JSON-like structure\nexport const renderReactElement = (element: ReactElement<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ReactNode[] = children.map((child, index) => {\n const renderedChild = renderReactElement(child as ReactElement<any>);\n\n if (\n typeof renderedChild === 'object' &&\n renderedChild !== null &&\n 'type' in renderedChild\n ) {\n const childElement = renderedChild as ReactElement<any>;\n return createElement(\n childElement.type,\n { ...childElement.props, key: index },\n ...(Array.isArray(childElement.props?.children)\n ? childElement.props.children\n : typeof childElement.props?.children !== 'undefined'\n ? [childElement.props.children]\n : [])\n );\n }\n return renderedChild;\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderReactElement(children as ReactElement<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as ReactElement<{ children?: ReactNode }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(\n type ?? 'span',\n props,\n ...(props.children as ReactNode[])\n );\n};\n"],"mappings":";;;AAGA,MAAa,sBAAsB,YAAoC;AACrE,KAAI,YAAY,QAAQ,OAAO,YAAY,SACzC,QAAO;CAGT,MAAM,0BACJ,YAC2C;EAC3C,MAAM,WAAW,QAAQ,OAAO;AAEhC,MAAI,MAAM,QAAQ,SAAS,EAAE;GAC3B,MAAM,iBAA8B,SAAS,KAAK,OAAO,UAAU;IACjE,MAAM,gBAAgB,mBAAmB,MAA2B;AAEpE,QACE,OAAO,kBAAkB,YACzB,kBAAkB,QAClB,UAAU,eACV;KACA,MAAM,eAAe;AACrB,YAAO,cACL,aAAa,MACb;MAAE,GAAG,aAAa;MAAO,KAAK;MAAO,EACrC,GAAI,MAAM,QAAQ,aAAa,OAAO,SAAS,GAC3C,aAAa,MAAM,WACnB,OAAO,aAAa,OAAO,aAAa,cACtC,CAAC,aAAa,MAAM,SAAS,GAC7B,EAAE,CACT;;AAEH,WAAO;KACP;AAEF,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;KAAgB;IACtD;aACQ,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,mBAAmB,SAA8B;AACvE,UAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,cAAc;KAAE;IACvD;;AAGH,SAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,EAAE;IAAE;GAC1C;;CAOH,MAAM,EAAE,MAAM,UAJO,uBACnB,QACD;AAKD,QAAO,cACL,QAAQ,QACR,OACA,GAAI,MAAM,SACX"}
1
+ {"version":3,"file":"renderReactElement.mjs","names":[],"sources":["../../../src/reactElement/renderReactElement.ts"],"sourcesContent":["import { createElement, type ReactElement, type ReactNode } from 'react';\n\n// This function recursively creates React elements from a given JSON-like structure\nexport const renderReactElement = (element: ReactElement<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ReactNode[] = children.map((child, index) => {\n const renderedChild = renderReactElement(child as ReactElement<any>);\n\n if (\n typeof renderedChild === 'object' &&\n renderedChild !== null &&\n 'type' in renderedChild\n ) {\n const childElement = renderedChild as ReactElement<any>;\n return createElement(\n childElement.type,\n { ...childElement.props, key: index },\n ...(Array.isArray(childElement.props?.children)\n ? childElement.props.children\n : typeof childElement.props?.children !== 'undefined'\n ? [childElement.props.children]\n : [])\n );\n }\n return renderedChild;\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderReactElement(children as ReactElement<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as ReactElement<{ children?: ReactNode }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(\n type ?? 'span',\n props,\n ...(props.children as ReactNode[])\n );\n};\n"],"mappings":"sCAGA,MAAa,EAAsB,GAAoC,CACrE,GAAwB,OAAO,GAAY,WAAvC,EACF,OAAO,EAqDT,GAAM,CAAE,OAAM,UAjDZ,GAC2C,CAC3C,IAAM,EAAW,EAAQ,OAAO,SAEhC,GAAI,MAAM,QAAQ,EAAS,CAAE,CAC3B,IAAM,EAA8B,EAAS,KAAK,EAAO,IAAU,CACjE,IAAM,EAAgB,EAAmB,EAA2B,CAEpE,GACE,OAAO,GAAkB,UACzB,GACA,SAAU,EACV,CACA,IAAM,EAAe,EACrB,OAAO,EACL,EAAa,KACb,CAAE,GAAG,EAAa,MAAO,IAAK,EAAO,CACrC,GAAI,MAAM,QAAQ,EAAa,OAAO,SAAS,CAC3C,EAAa,MAAM,SACZ,EAAa,OAAO,WAAa,OAEtC,EAAE,CADF,CAAC,EAAa,MAAM,SAAS,CAEpC,CAEH,OAAO,GACP,CAEF,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,EAAgB,CACtD,SACe,GAAyC,KAAM,CAC/D,IAAM,EAAgB,EAAmB,EAA8B,CACvE,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,CAAC,EAAc,CAAE,CACvD,CAGH,MAAO,CACL,GAAG,EACH,MAAO,CAAE,GAAG,EAAQ,MAAO,SAAU,EAAE,CAAE,CAC1C,GAID,EACD,CAKD,OAAO,EACL,GAAQ,OACR,EACA,GAAI,EAAM,SACX"}
@@ -1,29 +1,2 @@
1
- import { createServerContext, getServerContext } from "./serverContext.mjs";
2
- import { jsx } from "react/jsx-runtime";
3
- import configuration from "@intlayer/config/built";
4
-
5
- //#region src/server/IntlayerServerProvider.tsx
6
- const { defaultLocale } = configuration?.internationalization ?? {};
7
- /**
8
- * Context that store the current locale on the server side
9
- */
10
- const IntlayerServerContext = createServerContext(defaultLocale);
11
- /**
12
- * Hook that provides the current locale
13
- */
14
- const useIntlayer = () => getServerContext(IntlayerServerContext);
15
- /**
16
- * Get the current locale
17
- */
18
- const locale = getServerContext(IntlayerServerContext);
19
- /**
20
- * Provider that store the current locale on the server side
21
- */
22
- const IntlayerServerProvider = ({ children, locale = defaultLocale }) => /* @__PURE__ */ jsx(IntlayerServerContext.Provider, {
23
- value: locale,
24
- children
25
- });
26
-
27
- //#endregion
28
- export { IntlayerServerContext, IntlayerServerProvider, locale, useIntlayer };
1
+ import{createServerContext as e,getServerContext as t}from"./serverContext.mjs";import{jsx as n}from"react/jsx-runtime";import r from"@intlayer/config/built";const{defaultLocale:i}=r?.internationalization??{},a=e(i),o=()=>t(a),s=t(a),c=({children:e,locale:t=i})=>n(a.Provider,{value:t,children:e});export{a as IntlayerServerContext,c as IntlayerServerProvider,s as locale,o as useIntlayer};
29
2
  //# sourceMappingURL=IntlayerServerProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = configuration?.internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;AAMA,MAAM,EAAE,kBAAkB,eAAe,wBAAwB,EAAE;;;;AAKnE,MAAa,wBACX,oBAAmC,cAAc;;;;AAKnD,MAAa,oBAAoB,iBAAiB,sBAAsB;;;;AAKxE,MAAa,SAAS,iBAAiB,sBAAsB;;;;AAS7D,MAAa,0BAA2D,EACtE,UACA,SAAS,oBAET,oBAAC,sBAAsB;CAAS,OAAO;CACpC;EAC8B"}
1
+ {"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = configuration?.internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":"8JAMA,KAAM,CAAE,iBAAkB,GAAe,sBAAwB,EAAE,CAKtD,EACX,EAAmC,EAAc,CAKtC,MAAoB,EAAiB,EAAsB,CAK3D,EAAS,EAAiB,EAAsB,CAShD,GAA2D,CACtE,WACA,SAAS,KAET,EAAC,EAAsB,SAAA,CAAS,MAAO,EACpC,YAC8B"}
@@ -1,10 +1 @@
1
- import { useCompact } from "./useCompact.mjs";
2
- import { useCurrency } from "./useCurrency.mjs";
3
- import { useDate } from "./useDate.mjs";
4
- import { useList } from "./useList.mjs";
5
- import { useNumber } from "./useNumber.mjs";
6
- import { usePercentage } from "./usePercentage.mjs";
7
- import { useRelativeTime } from "./useRelativeTime.mjs";
8
- import { useUnit } from "./useUnit.mjs";
9
-
10
- export { useCompact, useCurrency, useDate, useList, useNumber, usePercentage, useRelativeTime, useUnit };
1
+ import{useCompact as e}from"./useCompact.mjs";import{useCurrency as t}from"./useCurrency.mjs";import{useDate as n}from"./useDate.mjs";import{useList as r}from"./useList.mjs";import{useNumber as i}from"./useNumber.mjs";import{usePercentage as a}from"./usePercentage.mjs";import{useRelativeTime as o}from"./useRelativeTime.mjs";import{useUnit as s}from"./useUnit.mjs";export{e as useCompact,t as useCurrency,n as useDate,r as useList,i as useNumber,a as usePercentage,o as useRelativeTime,s as useUnit};
@@ -1,26 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { compact } from "@intlayer/core";
4
-
5
- //#region src/server/format/useCompact.ts
6
- /**
7
- * React client hook that provides a compact number formatter
8
- * bound to the current application locale.
9
- *
10
- * @example
11
- * ```tsx
12
- * const formatCompact = useCompact();
13
- * formatCompact(1500); // "1.5K"
14
- * ```
15
- */
16
- const useCompact = () => {
17
- const locale = getServerContext(IntlayerServerContext);
18
- return (...args) => compact(args[0], {
19
- ...args[1],
20
- locale: args[1]?.locale ?? locale
21
- });
22
- };
23
-
24
- //#endregion
25
- export { useCompact };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{compact as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useCompact};
26
2
  //# sourceMappingURL=useCompact.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,mBAAmB;CAC9B,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"kLAeA,MAAa,MAAmB,CAC9B,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAQ,EAAK,GAAI,CACf,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,37 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { currency } from "@intlayer/core";
4
-
5
- //#region src/server/format/useCurrency.ts
6
- /**
7
- * React client hook that provides a currency formatter
8
- * bound to the current application locale.
9
- *
10
- * @example
11
- * ```tsx
12
- * const formatCurrency = useCurrency();
13
- *
14
- * formatCurrency(1500, { currency: "USD" });
15
- * // "$1,500.00"
16
- *
17
- * formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
18
- * // "1.500,00 €"
19
- *
20
- * formatCurrency(9876543.21, {
21
- * currency: "JPY",
22
- * fractionDigits: 0,
23
- * });
24
- * // "¥9,876,543"
25
- * ```
26
- */
27
- const useCurrency = () => {
28
- const locale = getServerContext(IntlayerServerContext);
29
- return (...args) => currency(args[0], {
30
- ...args[1],
31
- locale: args[1]?.locale ?? locale
32
- });
33
- };
34
-
35
- //#endregion
36
- export { useCurrency };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{currency as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useCurrency};
37
2
  //# sourceMappingURL=useCurrency.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"mLA0BA,MAAa,MAAoB,CAC/B,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAS,EAAK,GAAI,CAChB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,42 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { date } from "@intlayer/core";
4
-
5
- //#region src/server/format/useDate.ts
6
- /**
7
- * React client hook that provides a localized date/time formatter
8
- * bound to the current application locale.
9
- *
10
- * @returns {(date: Date | string | number, options?: DateProps) => string}
11
- * A function to format dates or timestamps into localized date/time strings.
12
- *
13
- * @example
14
- * ```tsx
15
- * const formatDate = useDate();
16
- *
17
- * formatDate(new Date("2025-01-01"));
18
- * // "Jan 1, 2025"
19
- *
20
- * formatDate("2025-01-01T15:30:00Z", {
21
- * dateStyle: "full",
22
- * timeStyle: "short",
23
- * });
24
- * // "Wednesday, January 1, 2025 at 3:30 PM"
25
- *
26
- * formatDate(1735689600000, { locale: "fr-FR", dateStyle: "long" });
27
- * // "1 janvier 2025"
28
- * ```
29
- *
30
- * @see createDate
31
- */
32
- const useDate = () => {
33
- const locale = getServerContext(IntlayerServerContext);
34
- return (...args) => date(args[0], {
35
- ...args[1],
36
- locale: args[1]?.locale ?? locale
37
- });
38
- };
39
-
40
- //#endregion
41
- export { useDate };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{date as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useDate};
42
2
  //# sourceMappingURL=useDate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"+KA+BA,MAAa,MAAgB,CAC3B,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAK,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,42 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { bindIntl } from "@intlayer/core";
4
- import configuration from "@intlayer/config/built";
5
-
6
- //#region src/server/format/useIntl.ts
7
- /**
8
- * React client hook that provides a locale-bound `Intl` object.
9
- *
10
- * It acts exactly like the native `Intl` object, but acts as a proxy to:
11
- * 1. Inject the current locale automatically if none is provided.
12
- * 2. Use the performance-optimized `CachedIntl` under the hood.
13
- *
14
- * @example
15
- * ```tsx
16
- * const intl = useIntl(); // uses context locale
17
- *
18
- * // Standard API, but no need to pass 'en-US' as the first argument
19
- * const formatted = new intl.NumberFormat({
20
- * style: 'currency',
21
- * currency: 'USD'
22
- * }).format(123.45);
23
- * ```
24
- *
25
- * @example
26
- * ```tsx
27
- * const intl = useIntl();
28
- *
29
- * // You can still override the locale if needed
30
- * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());
31
- * // or
32
- * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());
33
- * ```
34
- */
35
- const useIntl = (locale) => {
36
- const currentLocale = getServerContext(IntlayerServerContext);
37
- return bindIntl(locale ?? currentLocale ?? configuration?.internationalization?.defaultLocale);
38
- };
39
-
40
- //#endregion
41
- export { useIntl };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import n from"@intlayer/config/built";import{bindIntl as r}from"@intlayer/core/formatters";const i=i=>{let a=e(t);return r(i??a??n?.internationalization?.defaultLocale)};export{i as useIntl};
42
2
  //# sourceMappingURL=useIntl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,WAAW,WAA2B;CACjD,MAAM,gBAAgB,iBAAgC,sBAAsB;AAE5E,QAAO,SACL,UACE,iBACA,eAAe,sBAAsB,cACxC"}
1
+ {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"yNAkCA,MAAa,EAAW,GAA2B,CACjD,IAAM,EAAgB,EAAgC,EAAsB,CAE5E,OAAO,EACL,GACE,GACA,GAAe,sBAAsB,cACxC"}
@@ -1,34 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { list } from "@intlayer/core";
4
-
5
- //#region src/server/format/useList.ts
6
- /**
7
- * React server hook that provides a list formatter
8
- * bound to the current application locale.
9
- *
10
- * @example
11
- * ```tsx
12
- * const formatList = useList();
13
- *
14
- * formatList(['apple', 'banana', 'orange']);
15
- * // "apple, banana, and orange"
16
- *
17
- * formatList(['red', 'green', 'blue'], { type: 'disjunction' });
18
- * // "red, green, or blue"
19
- *
20
- * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });
21
- * // "1, 2 und 3"
22
- * ```
23
- */
24
- const useList = () => {
25
- const locale = getServerContext(IntlayerServerContext);
26
- return (...args) => list(args[0], {
27
- ...args[1],
28
- locale: args[1]?.locale ?? locale
29
- });
30
- };
31
-
32
- //#endregion
33
- export { useList };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{list as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useList};
34
2
  //# sourceMappingURL=useList.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"+KAuBA,MAAa,MAAgB,CAC3B,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAK,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,38 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { number } from "@intlayer/core";
4
-
5
- //#region src/server/format/useNumber.ts
6
- /**
7
- * React client hook that provides a localized number formatter.
8
- *
9
- * Uses the current locale from {@link useLocaleBase} and returns
10
- * a function that can be used to format numbers consistently
11
- * according to the user's locale.
12
- *
13
- * @example
14
- * ```tsx
15
- * const formatNumber = useNumber();
16
- *
17
- * formatNumber(12345);
18
- * // e.g. "12,345" (en-US)
19
- * // e.g. "12 345" (fr-FR)
20
- *
21
- * formatNumber(0.75, { style: "percent" });
22
- * // e.g. "75%"
23
- * ```
24
- *
25
- * @returns {(value: string | number, options?: import("../createNumber").NumberProps) => string}
26
- * A number formatting function bound to the active locale.
27
- */
28
- const useNumber = () => {
29
- const locale = getServerContext(IntlayerServerContext);
30
- return (...args) => number(args[0], {
31
- ...args[1],
32
- locale: args[1]?.locale ?? locale
33
- });
34
- };
35
-
36
- //#endregion
37
- export { useNumber };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{number as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as useNumber};
38
2
  //# sourceMappingURL=useNumber.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,kBAAkB;CAC7B,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iLA2BA,MAAa,MAAkB,CAC7B,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAO,EAAK,GAAI,CACd,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,34 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { percentage } from "@intlayer/core";
4
-
5
- //#region src/server/format/usePercentage.ts
6
- /**
7
- * React hook to provide a percentage formatter function
8
- * based on the current application locale.
9
- *
10
- * This hook retrieves the active locale using {@link useLocaleBase}
11
- * and memoizes a `createPercentage` instance for that locale.
12
- *
13
- * @example
14
- * ```tsx
15
- * const formatPercentage = usePercentage();
16
- *
17
- * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });
18
- * // "87.5%" (depending on locale)
19
- * ```
20
- *
21
- * @returns {(value: string | number, options?: Omit<PercentageOptions, "value">) => string}
22
- * A function that formats numbers or numeric strings into localized percentages.
23
- */
24
- const usePercentage = () => {
25
- const locale = getServerContext(IntlayerServerContext);
26
- return (...args) => percentage(args[0], {
27
- ...args[1],
28
- locale: args[1]?.locale ?? locale
29
- });
30
- };
31
-
32
- //#endregion
33
- export { usePercentage };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{percentage as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],{...e[1],locale:e[1]?.locale??r})};export{r as usePercentage};
34
2
  //# sourceMappingURL=usePercentage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,sBAAsB;CACjC,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"qLAuBA,MAAa,MAAsB,CACjC,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAW,EAAK,GAAI,CAClB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
@@ -1,34 +1,2 @@
1
- import { getServerContext } from "../serverContext.mjs";
2
- import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
3
- import { relativeTime } from "@intlayer/core";
4
-
5
- //#region src/server/format/useRelativeTime.ts
6
- /**
7
- * Client-side React hook for accessing a localized relative time formatter.
8
- *
9
- * This hook:
10
- * - Reads the current locale from {@link useLocaleBase}.
11
- * - Creates a new relative time formatter with {@link createRelativeTime}.
12
- * - Returns a function that can format time differences into localized strings.
13
- *
14
- * Example:
15
- * ```tsx
16
- * const relativeTime = useRelativeTime();
17
- * const formatted = relativeTime(new Date("2024-08-01"), new Date());
18
- * // e.g., "2 weeks ago"
19
- * ```
20
- *
21
- * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
22
- * bound to the current client locale.
23
- */
24
- const useRelativeTime = () => {
25
- const locale = getServerContext(IntlayerServerContext);
26
- return (...args) => relativeTime(args[0], args[1] ?? /* @__PURE__ */ new Date(), {
27
- ...args[2],
28
- locale: args[2]?.locale ?? locale
29
- });
30
- };
31
-
32
- //#endregion
33
- export { useRelativeTime };
1
+ import{getServerContext as e}from"../serverContext.mjs";import{IntlayerServerContext as t}from"../IntlayerServerProvider.mjs";import{relativeTime as n}from"@intlayer/core/formatters";const r=()=>{let r=e(t);return(...e)=>n(e[0],e[1]??new Date,{...e[2],locale:e[2]?.locale??r})};export{r as useRelativeTime};
34
2
  //# sourceMappingURL=useRelativeTime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,wBAAwB;CACnC,MAAM,SAAS,iBAAgC,sBAAsB;AAErE,SAAQ,GAAG,SACT,aAAa,KAAK,IAAI,KAAK,sBAAM,IAAI,MAAM,EAAE;EAC3C,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":"uLAuBA,MAAa,MAAwB,CACnC,IAAM,EAAS,EAAgC,EAAsB,CAErE,OAAQ,GAAG,IACT,EAAa,EAAK,GAAI,EAAK,IAAM,IAAI,KAAQ,CAC3C,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}