react-intlayer 8.4.4 → 8.4.5

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 (251) hide show
  1. package/dist/cjs/IntlayerNode.cjs +17 -1
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +96 -1
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -1
  6. package/dist/cjs/client/IntlayerProvider.cjs +92 -1
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +20 -1
  9. package/dist/cjs/client/format/useCompact.cjs +29 -1
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +43 -1
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +45 -1
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useIntl.cjs +45 -1
  16. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  17. package/dist/cjs/client/format/useList.cjs +40 -1
  18. package/dist/cjs/client/format/useList.cjs.map +1 -1
  19. package/dist/cjs/client/format/useNumber.cjs +41 -1
  20. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  21. package/dist/cjs/client/format/usePercentage.cjs +37 -1
  22. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  23. package/dist/cjs/client/format/useRelativeTime.cjs +37 -1
  24. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  25. package/dist/cjs/client/format/useUnit.cjs +36 -1
  26. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  27. package/dist/cjs/client/index.cjs +34 -1
  28. package/dist/cjs/client/t.cjs +40 -1
  29. package/dist/cjs/client/t.cjs.map +1 -1
  30. package/dist/cjs/client/useDictionary.cjs +27 -1
  31. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionaryAsync.cjs +24 -1
  33. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  34. package/dist/cjs/client/useDictionaryDynamic.cjs +25 -1
  35. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  36. package/dist/cjs/client/useI18n.cjs +45 -1
  37. package/dist/cjs/client/useI18n.cjs.map +1 -1
  38. package/dist/cjs/client/useIntlayer.cjs +42 -1
  39. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  40. package/dist/cjs/client/useLoadDynamic.cjs +27 -1
  41. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  42. package/dist/cjs/client/useLocale.cjs +60 -1
  43. package/dist/cjs/client/useLocale.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleBase.cjs +26 -1
  45. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  46. package/dist/cjs/client/useLocaleStorage.cjs +62 -1
  47. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  48. package/dist/cjs/client/useRewriteURL.cjs +42 -1
  49. package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
  50. package/dist/cjs/client/useTraduction.cjs +35 -1
  51. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  52. package/dist/cjs/editor/ContentSelector.cjs +18 -1
  53. package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
  54. package/dist/cjs/editor/EditorProvider.cjs +11 -1
  55. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  56. package/dist/cjs/editor/useEditor.cjs +39 -1
  57. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  58. package/dist/cjs/getDictionary.cjs +10 -1
  59. package/dist/cjs/getDictionary.cjs.map +1 -1
  60. package/dist/cjs/getIntlayer.cjs +10 -1
  61. package/dist/cjs/getIntlayer.cjs.map +1 -1
  62. package/dist/cjs/html/HTMLProvider.cjs +18 -1
  63. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  64. package/dist/cjs/html/HTMLRenderer.cjs +60 -1
  65. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  66. package/dist/cjs/html/HTMLRendererPlugin.cjs +23 -1
  67. package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
  68. package/dist/cjs/html/index.cjs +12 -1
  69. package/dist/cjs/index.cjs +52 -1
  70. package/dist/cjs/markdown/MarkdownProvider.cjs +80 -1
  71. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  72. package/dist/cjs/markdown/MarkdownRenderer.cjs +201 -1
  73. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  74. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +17 -1
  75. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  76. package/dist/cjs/markdown/index.cjs +24 -1
  77. package/dist/cjs/markdown/processor.cjs +66 -1
  78. package/dist/cjs/markdown/processor.cjs.map +1 -1
  79. package/dist/cjs/markdown/runtime.cjs +43 -1
  80. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  81. package/dist/cjs/plugins.cjs +200 -1
  82. package/dist/cjs/plugins.cjs.map +1 -1
  83. package/dist/cjs/reactElement/renderReactElement.cjs +52 -1
  84. package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
  85. package/dist/cjs/server/IntlayerServerProvider.cjs +34 -1
  86. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  87. package/dist/cjs/server/format/index.cjs +18 -1
  88. package/dist/cjs/server/format/useCompact.cjs +27 -1
  89. package/dist/cjs/server/format/useCompact.cjs.map +1 -1
  90. package/dist/cjs/server/format/useCurrency.cjs +38 -1
  91. package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
  92. package/dist/cjs/server/format/useDate.cjs +43 -1
  93. package/dist/cjs/server/format/useDate.cjs.map +1 -1
  94. package/dist/cjs/server/format/useIntl.cjs +44 -1
  95. package/dist/cjs/server/format/useIntl.cjs.map +1 -1
  96. package/dist/cjs/server/format/useList.cjs +35 -1
  97. package/dist/cjs/server/format/useList.cjs.map +1 -1
  98. package/dist/cjs/server/format/useNumber.cjs +39 -1
  99. package/dist/cjs/server/format/useNumber.cjs.map +1 -1
  100. package/dist/cjs/server/format/usePercentage.cjs +35 -1
  101. package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
  102. package/dist/cjs/server/format/useRelativeTime.cjs +35 -1
  103. package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
  104. package/dist/cjs/server/format/useUnit.cjs +34 -1
  105. package/dist/cjs/server/format/useUnit.cjs.map +1 -1
  106. package/dist/cjs/server/index.cjs +24 -1
  107. package/dist/cjs/server/serverContext.cjs +58 -1
  108. package/dist/cjs/server/serverContext.cjs.map +1 -1
  109. package/dist/cjs/server/t.cjs +35 -1
  110. package/dist/cjs/server/t.cjs.map +1 -1
  111. package/dist/cjs/server/useDictionary.cjs +17 -1
  112. package/dist/cjs/server/useDictionary.cjs.map +1 -1
  113. package/dist/cjs/server/useDictionaryAsync.cjs +21 -1
  114. package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
  115. package/dist/cjs/server/useDictionaryDynamic.cjs +22 -1
  116. package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
  117. package/dist/cjs/server/useI18n.cjs +38 -1
  118. package/dist/cjs/server/useI18n.cjs.map +1 -1
  119. package/dist/cjs/server/useIntlayer.cjs +17 -1
  120. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  121. package/dist/cjs/server/useLoadDynamic.cjs +14 -1
  122. package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
  123. package/dist/cjs/server/useLocale.cjs +24 -1
  124. package/dist/cjs/server/useLocale.cjs.map +1 -1
  125. package/dist/esm/IntlayerNode.mjs +15 -1
  126. package/dist/esm/IntlayerNode.mjs.map +1 -1
  127. package/dist/esm/UI/ContentSelector.mjs +94 -1
  128. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  129. package/dist/esm/client/IntlayerProvider.mjs +86 -1
  130. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  131. package/dist/esm/client/format/index.mjs +11 -1
  132. package/dist/esm/client/format/useCompact.mjs +27 -1
  133. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  134. package/dist/esm/client/format/useCurrency.mjs +41 -1
  135. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  136. package/dist/esm/client/format/useDate.mjs +43 -1
  137. package/dist/esm/client/format/useDate.mjs.map +1 -1
  138. package/dist/esm/client/format/useIntl.mjs +43 -1
  139. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  140. package/dist/esm/client/format/useList.mjs +38 -1
  141. package/dist/esm/client/format/useList.mjs.map +1 -1
  142. package/dist/esm/client/format/useNumber.mjs +39 -1
  143. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  144. package/dist/esm/client/format/usePercentage.mjs +35 -1
  145. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  146. package/dist/esm/client/format/useRelativeTime.mjs +35 -1
  147. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  148. package/dist/esm/client/format/useUnit.mjs +34 -1
  149. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  150. package/dist/esm/client/index.mjs +14 -1
  151. package/dist/esm/client/t.mjs +38 -1
  152. package/dist/esm/client/t.mjs.map +1 -1
  153. package/dist/esm/client/useDictionary.mjs +25 -1
  154. package/dist/esm/client/useDictionary.mjs.map +1 -1
  155. package/dist/esm/client/useDictionaryAsync.mjs +21 -1
  156. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  157. package/dist/esm/client/useDictionaryDynamic.mjs +22 -1
  158. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  159. package/dist/esm/client/useI18n.mjs +43 -1
  160. package/dist/esm/client/useI18n.mjs.map +1 -1
  161. package/dist/esm/client/useIntlayer.mjs +40 -1
  162. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  163. package/dist/esm/client/useLoadDynamic.mjs +25 -1
  164. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  165. package/dist/esm/client/useLocale.mjs +57 -1
  166. package/dist/esm/client/useLocale.mjs.map +1 -1
  167. package/dist/esm/client/useLocaleBase.mjs +23 -1
  168. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  169. package/dist/esm/client/useLocaleStorage.mjs +55 -1
  170. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  171. package/dist/esm/client/useRewriteURL.mjs +39 -1
  172. package/dist/esm/client/useRewriteURL.mjs.map +1 -1
  173. package/dist/esm/client/useTraduction.mjs +33 -1
  174. package/dist/esm/client/useTraduction.mjs.map +1 -1
  175. package/dist/esm/editor/ContentSelector.mjs +16 -1
  176. package/dist/esm/editor/ContentSelector.mjs.map +1 -1
  177. package/dist/esm/editor/EditorProvider.mjs +10 -1
  178. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  179. package/dist/esm/editor/useEditor.mjs +37 -1
  180. package/dist/esm/editor/useEditor.mjs.map +1 -1
  181. package/dist/esm/getDictionary.mjs +8 -1
  182. package/dist/esm/getDictionary.mjs.map +1 -1
  183. package/dist/esm/getIntlayer.mjs +8 -1
  184. package/dist/esm/getIntlayer.mjs.map +1 -1
  185. package/dist/esm/html/HTMLProvider.mjs +15 -1
  186. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  187. package/dist/esm/html/HTMLRenderer.mjs +55 -1
  188. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  189. package/dist/esm/html/HTMLRendererPlugin.mjs +21 -1
  190. package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
  191. package/dist/esm/html/index.mjs +5 -1
  192. package/dist/esm/index.mjs +21 -1
  193. package/dist/esm/markdown/MarkdownProvider.mjs +77 -1
  194. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  195. package/dist/esm/markdown/MarkdownRenderer.mjs +197 -1
  196. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  197. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +16 -1
  198. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  199. package/dist/esm/markdown/index.mjs +7 -1
  200. package/dist/esm/markdown/processor.mjs +58 -1
  201. package/dist/esm/markdown/processor.mjs.map +1 -1
  202. package/dist/esm/markdown/runtime.mjs +39 -1
  203. package/dist/esm/markdown/runtime.mjs.map +1 -1
  204. package/dist/esm/plugins.mjs +190 -1
  205. package/dist/esm/plugins.mjs.map +1 -1
  206. package/dist/esm/reactElement/renderReactElement.mjs +50 -1
  207. package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
  208. package/dist/esm/server/IntlayerServerProvider.mjs +28 -1
  209. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  210. package/dist/esm/server/format/index.mjs +10 -1
  211. package/dist/esm/server/format/useCompact.mjs +25 -1
  212. package/dist/esm/server/format/useCompact.mjs.map +1 -1
  213. package/dist/esm/server/format/useCurrency.mjs +36 -1
  214. package/dist/esm/server/format/useCurrency.mjs.map +1 -1
  215. package/dist/esm/server/format/useDate.mjs +41 -1
  216. package/dist/esm/server/format/useDate.mjs.map +1 -1
  217. package/dist/esm/server/format/useIntl.mjs +41 -1
  218. package/dist/esm/server/format/useIntl.mjs.map +1 -1
  219. package/dist/esm/server/format/useList.mjs +33 -1
  220. package/dist/esm/server/format/useList.mjs.map +1 -1
  221. package/dist/esm/server/format/useNumber.mjs +37 -1
  222. package/dist/esm/server/format/useNumber.mjs.map +1 -1
  223. package/dist/esm/server/format/usePercentage.mjs +33 -1
  224. package/dist/esm/server/format/usePercentage.mjs.map +1 -1
  225. package/dist/esm/server/format/useRelativeTime.mjs +33 -1
  226. package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
  227. package/dist/esm/server/format/useUnit.mjs +32 -1
  228. package/dist/esm/server/format/useUnit.mjs.map +1 -1
  229. package/dist/esm/server/index.mjs +12 -1
  230. package/dist/esm/server/serverContext.mjs +54 -1
  231. package/dist/esm/server/serverContext.mjs.map +1 -1
  232. package/dist/esm/server/t.mjs +33 -1
  233. package/dist/esm/server/t.mjs.map +1 -1
  234. package/dist/esm/server/useDictionary.mjs +16 -1
  235. package/dist/esm/server/useDictionary.mjs.map +1 -1
  236. package/dist/esm/server/useDictionaryAsync.mjs +18 -1
  237. package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
  238. package/dist/esm/server/useDictionaryDynamic.mjs +19 -1
  239. package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
  240. package/dist/esm/server/useI18n.mjs +37 -1
  241. package/dist/esm/server/useI18n.mjs.map +1 -1
  242. package/dist/esm/server/useIntlayer.mjs +16 -1
  243. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  244. package/dist/esm/server/useLoadDynamic.mjs +11 -1
  245. package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
  246. package/dist/esm/server/useLocale.mjs +21 -1
  247. package/dist/esm/server/useLocale.mjs.map +1 -1
  248. package/dist/types/html/HTMLRenderer.d.ts +1 -1
  249. package/dist/types/plugins.d.ts +4 -3
  250. package/dist/types/plugins.d.ts.map +1 -1
  251. package/package.json +9 -9
@@ -1,2 +1,44 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);const t={createElement:(t,n,...r)=>r.length===0?(0,e.createElement)(t,n):r.length===1?(0,e.createElement)(t,n,r[0]):(0,e.createElement)(t,n,...r),cloneElement:(t,n,...r)=>r.length===0?(0,e.cloneElement)(t,n):(0,e.cloneElement)(t,n,...r),Fragment:e.Fragment,normalizeProps:(e,t)=>t},n=(e={})=>{let{onCreateElement:n}=e;return n?{...t,createElement:(e,t,...r)=>n(e,t,r)}:t};exports.createReactRuntime=n,exports.default=t,exports.reactRuntime=t;
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+
5
+ //#region src/markdown/runtime.ts
6
+ /**
7
+ * React-specific runtime for the markdown processor.
8
+ * Implements the MarkdownRuntime interface using React's primitives.
9
+ */
10
+ const reactRuntime = {
11
+ createElement: (type, props, ...children) => {
12
+ if (children.length === 0) return (0, react.createElement)(type, props);
13
+ if (children.length === 1) return (0, react.createElement)(type, props, children[0]);
14
+ return (0, react.createElement)(type, props, ...children);
15
+ },
16
+ cloneElement: (element, props, ...children) => {
17
+ if (children.length === 0) return (0, react.cloneElement)(element, props);
18
+ return (0, react.cloneElement)(element, props, ...children);
19
+ },
20
+ Fragment: react.Fragment,
21
+ normalizeProps: (_tag, props) => {
22
+ return props;
23
+ }
24
+ };
25
+ /**
26
+ * Creates a React runtime with custom createElement for advanced use cases.
27
+ * Useful for wrapping elements or adding middleware.
28
+ */
29
+ const createReactRuntime = (options = {}) => {
30
+ const { onCreateElement } = options;
31
+ if (onCreateElement) return {
32
+ ...reactRuntime,
33
+ createElement: (type, props, ...children) => {
34
+ return onCreateElement(type, props, children);
35
+ }
36
+ };
37
+ return reactRuntime;
38
+ };
39
+
40
+ //#endregion
41
+ exports.createReactRuntime = createReactRuntime;
42
+ exports.default = reactRuntime;
43
+ exports.reactRuntime = reactRuntime;
2
44
  //# sourceMappingURL=runtime.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["import type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n cloneElement,\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nexport const reactRuntime: MarkdownRuntime = {\n /**\n * Creates a React element.\n * Handles the conversion of props and children to React format.\n */\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n // React accepts children as rest args or as a single array\n // If there's only one child, pass it directly to avoid unnecessary array\n if (children.length === 0) {\n return createElement(type, props);\n }\n if (children.length === 1) {\n return createElement(type, props, children[0]);\n }\n return createElement(type, props, ...children);\n },\n\n /**\n * Clones a React element with new props.\n */\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): ReactNode => {\n if (children.length === 0) {\n return cloneElement(element as ReactElement, props);\n }\n return cloneElement(element as ReactElement, props, ...children);\n },\n\n /**\n * React Fragment component.\n */\n Fragment,\n\n /**\n * React-specific prop normalization.\n * React uses className instead of class, htmlFor instead of for, etc.\n * The core processor already handles ATTRIBUTE_TO_NODE_PROP_MAP,\n * so this is mostly a no-op but can be used for additional React-specific transforms.\n */\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => {\n // The core already handles class -> className and for -> htmlFor\n // via ATTRIBUTE_TO_NODE_PROP_MAP in the attrStringToMap function.\n // This hook is available for any additional React-specific transforms.\n return props;\n },\n};\n\n/**\n * Creates a React runtime with custom createElement for advanced use cases.\n * Useful for wrapping elements or adding middleware.\n */\nexport const createReactRuntime = (\n options: {\n onCreateElement?: (\n type: string | any,\n props: Record<string, any> | null,\n children: any[]\n ) => ReactNode;\n } = {}\n): MarkdownRuntime => {\n const { onCreateElement } = options;\n\n if (onCreateElement) {\n return {\n ...reactRuntime,\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n return onCreateElement(type, props, children);\n },\n };\n }\n\n return reactRuntime;\n};\n\nexport default reactRuntime;\n"],"mappings":"mKAaA,MAAa,EAAgC,CAK3C,eACE,EACA,EACA,GAAG,IAIC,EAAS,SAAW,GACtB,EAAA,EAAA,eAAqB,EAAM,EAAM,CAE/B,EAAS,SAAW,GACtB,EAAA,EAAA,eAAqB,EAAM,EAAO,EAAS,GAAG,EAEhD,EAAA,EAAA,eAAqB,EAAM,EAAO,GAAG,EAAS,CAMhD,cACE,EACA,EACA,GAAG,IAEC,EAAS,SAAW,GACtB,EAAA,EAAA,cAAoB,EAAyB,EAAM,EAErD,EAAA,EAAA,cAAoB,EAAyB,EAAO,GAAG,EAAS,CAMlE,SAAA,EAAA,SAQA,gBACE,EACA,IAKO,EAEV,CAMY,GACX,EAMI,EAAE,GACc,CACpB,GAAM,CAAE,mBAAoB,EAe5B,OAbI,EACK,CACL,GAAG,EACH,eACE,EACA,EACA,GAAG,IAEI,EAAgB,EAAM,EAAO,EAAS,CAEhD,CAGI"}
1
+ {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["import type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n cloneElement,\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nexport const reactRuntime: MarkdownRuntime = {\n /**\n * Creates a React element.\n * Handles the conversion of props and children to React format.\n */\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n // React accepts children as rest args or as a single array\n // If there's only one child, pass it directly to avoid unnecessary array\n if (children.length === 0) {\n return createElement(type, props);\n }\n if (children.length === 1) {\n return createElement(type, props, children[0]);\n }\n return createElement(type, props, ...children);\n },\n\n /**\n * Clones a React element with new props.\n */\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): ReactNode => {\n if (children.length === 0) {\n return cloneElement(element as ReactElement, props);\n }\n return cloneElement(element as ReactElement, props, ...children);\n },\n\n /**\n * React Fragment component.\n */\n Fragment,\n\n /**\n * React-specific prop normalization.\n * React uses className instead of class, htmlFor instead of for, etc.\n * The core processor already handles ATTRIBUTE_TO_NODE_PROP_MAP,\n * so this is mostly a no-op but can be used for additional React-specific transforms.\n */\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => {\n // The core already handles class -> className and for -> htmlFor\n // via ATTRIBUTE_TO_NODE_PROP_MAP in the attrStringToMap function.\n // This hook is available for any additional React-specific transforms.\n return props;\n },\n};\n\n/**\n * Creates a React runtime with custom createElement for advanced use cases.\n * Useful for wrapping elements or adding middleware.\n */\nexport const createReactRuntime = (\n options: {\n onCreateElement?: (\n type: string | any,\n props: Record<string, any> | null,\n children: any[]\n ) => ReactNode;\n } = {}\n): MarkdownRuntime => {\n const { onCreateElement } = options;\n\n if (onCreateElement) {\n return {\n ...reactRuntime,\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n return onCreateElement(type, props, children);\n },\n };\n }\n\n return reactRuntime;\n};\n\nexport default reactRuntime;\n"],"mappings":";;;;;;;;;AAaA,MAAa,eAAgC;CAK3C,gBACE,MACA,OACA,GAAG,aACW;AAGd,MAAI,SAAS,WAAW,EACtB,iCAAqB,MAAM,MAAM;AAEnC,MAAI,SAAS,WAAW,EACtB,iCAAqB,MAAM,OAAO,SAAS,GAAG;AAEhD,kCAAqB,MAAM,OAAO,GAAG,SAAS;;CAMhD,eACE,SACA,OACA,GAAG,aACW;AACd,MAAI,SAAS,WAAW,EACtB,gCAAoB,SAAyB,MAAM;AAErD,iCAAoB,SAAyB,OAAO,GAAG,SAAS;;CAMlE;CAQA,iBACE,MACA,UACwB;AAIxB,SAAO;;CAEV;;;;;AAMD,MAAa,sBACX,UAMI,EAAE,KACc;CACpB,MAAM,EAAE,oBAAoB;AAE5B,KAAI,gBACF,QAAO;EACL,GAAG;EACH,gBACE,MACA,OACA,GAAG,aACW;AACd,UAAO,gBAAgB,MAAM,OAAO,SAAS;;EAEhD;AAGH,QAAO"}
@@ -1,2 +1,201 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./editor/ContentSelector.cjs`),n=require(`./html/HTMLRendererPlugin.cjs`),r=require(`./IntlayerNode.cjs`),i=require(`./markdown/MarkdownRendererPlugin.cjs`),a=require(`./reactElement/renderReactElement.cjs`);let o=require(`@intlayer/config/built`);o=e.__toESM(o);let s=require(`@intlayer/core/interpreter`),c=require(`@intlayer/core/markdown`),l=require(`@intlayer/types/nodeType`),u=require(`react`),d=require(`react/jsx-runtime`);const f={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:i.children,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...i,children:i.children}):i.children})},p={id:`react-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0&&e.key!==void 0,transform:(e,{plugins:n,...i})=>r.renderIntlayerNode({...i,value:`[[react-element]]`,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...i,children:a.renderReactElement(e)}):a.renderReactElement(e)})},m=(e,t)=>{let n=(0,s.splitInsertionTemplate)(e,t);return n.isSimple?n.parts:(0,u.createElement)(u.Fragment,null,...n.parts.map((e,t)=>(0,u.createElement)(u.Fragment,{key:t},e)))},h={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:l.NodeType.Insertion}],i=e[l.NodeType.Insertion],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let i=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let a=m(i,e);return r(a,{...n,plugins:t.plugins,children:a})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return typeof i==`object`&&i&&`nodeType`in i&&[l.NodeType.Enumeration,l.NodeType.Condition].includes(i.nodeType)?e=>t=>{let n=o(t);return typeof n==`function`?n(e):n}:o}},g={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,a)=>{let{plugins:s,...l}=n,u=a((0,c.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,i)=>r.renderIntlayerNode({...i,value:n,children:o.default?.editor.enabled?(0,d.jsx)(t.ContentSelector,{...l,children:e}):e})}],dictionaryKey:l.dictionaryKey,keyPath:[]}),f=a=>r.renderIntlayerNode({...n,value:e,children:o.default.editor.enabled?(0,d.jsx)(t.ContentSelector,{...l,children:(0,d.jsx)(i.MarkdownRendererPlugin,{...l,components:a,children:e})}):(0,d.jsx)(i.MarkdownRendererPlugin,{...l,components:a,children:e}),additionalProps:{metadata:u}}),p=f();return new Proxy(p,{get(t,n,r){return n===`value`?e:n===`metadata`?u:n===`use`?e=>f(e):Reflect.get(t,n,r)}})}},_={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:l.NodeType.Markdown}],i=e[l.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[g,...t.plugins??[]]})}},v={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===l.NodeType.HTML,transform:(e,t)=>{let r=e[l.NodeType.HTML],{plugins:i,...a}=t,o=e=>(0,u.createElement)(n.HTMLRendererPlugin,{...a,html:r,userComponents:e}),s=o();return new Proxy(s,{get(e,t,n){return t===`value`?r:t===`use`?e=>o(e):Reflect.get(e,t,n)}})}},y=(e,t=!0)=>[(0,s.translationPlugin)(e??o.default.internationalization.defaultLocale,t?o.default.internationalization.defaultLocale:void 0),s.enumerationPlugin,s.conditionPlugin,(0,s.nestedPlugin)(e??o.default.internationalization.defaultLocale),s.filePlugin,s.genderPlugin,f,p,h,_,v];exports.getPlugins=y,exports.htmlPlugin=v,exports.insertionPlugin=h,exports.intlayerNodePlugins=f,exports.markdownPlugin=_,exports.markdownStringPlugin=g,exports.reactNodePlugins=p;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_editor_ContentSelector = require('./editor/ContentSelector.cjs');
4
+ const require_html_HTMLRendererPlugin = require('./html/HTMLRendererPlugin.cjs');
5
+ const require_IntlayerNode = require('./IntlayerNode.cjs');
6
+ const require_markdown_MarkdownRendererPlugin = require('./markdown/MarkdownRendererPlugin.cjs');
7
+ const require_reactElement_renderReactElement = require('./reactElement/renderReactElement.cjs');
8
+ let _intlayer_config_built = require("@intlayer/config/built");
9
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
10
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
11
+ let _intlayer_core_markdown = require("@intlayer/core/markdown");
12
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
13
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
14
+ let react = require("react");
15
+ let react_jsx_runtime = require("react/jsx-runtime");
16
+
17
+ //#region src/plugins.tsx
18
+ /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
19
+ const intlayerNodePlugins = {
20
+ id: "intlayer-node-plugin",
21
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
22
+ transform: (_node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
23
+ ...rest,
24
+ value: rest.children,
25
+ children: _intlayer_config_built.default?.editor.enabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
26
+ ...rest,
27
+ children: rest.children
28
+ }) : rest.children
29
+ })
30
+ };
31
+ /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
32
+ const reactNodePlugins = {
33
+ id: "react-node-plugin",
34
+ canHandle: (node) => typeof node === "object" && typeof node?.props !== "undefined" && typeof node.key !== "undefined",
35
+ transform: (node, { plugins, ...rest }) => require_IntlayerNode.renderIntlayerNode({
36
+ ...rest,
37
+ value: "[[react-element]]",
38
+ children: _intlayer_config_built.default?.editor.enabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
39
+ ...rest,
40
+ children: require_reactElement_renderReactElement.renderReactElement(node)
41
+ }) : require_reactElement_renderReactElement.renderReactElement(node)
42
+ })
43
+ };
44
+ /**
45
+ * Split insertion string and join with React nodes using shared core logic
46
+ */
47
+ const splitAndJoinInsertion = (template, values) => {
48
+ const result = (0, _intlayer_core_interpreter.splitInsertionTemplate)(template, values);
49
+ if (result.isSimple) return result.parts;
50
+ return (0, react.createElement)(react.Fragment, null, ...result.parts.map((part, index) => (0, react.createElement)(react.Fragment, { key: index }, part)));
51
+ };
52
+ /** Insertion plugin for React. Handles component/node insertion. */
53
+ const insertionPlugin = {
54
+ id: "insertion-plugin",
55
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
56
+ transform: (node, props, deepTransformNode) => {
57
+ const newKeyPath = [...props.keyPath, { type: _intlayer_types_nodeType.INSERTION }];
58
+ const children = node[_intlayer_types_nodeType.INSERTION];
59
+ /** Insertion string plugin. Replaces string node with a component that render the insertion. */
60
+ const insertionStringPlugin = {
61
+ id: "insertion-string-plugin",
62
+ canHandle: (node) => typeof node === "string",
63
+ transform: (node, subProps, deepTransformNode) => {
64
+ const transformedResult = deepTransformNode(node, {
65
+ ...subProps,
66
+ children: node,
67
+ plugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")]
68
+ });
69
+ return (values) => {
70
+ const result = splitAndJoinInsertion(transformedResult, values);
71
+ return deepTransformNode(result, {
72
+ ...subProps,
73
+ plugins: props.plugins,
74
+ children: result
75
+ });
76
+ };
77
+ }
78
+ };
79
+ const result = deepTransformNode(children, {
80
+ ...props,
81
+ children,
82
+ keyPath: newKeyPath,
83
+ plugins: [insertionStringPlugin, ...props.plugins ?? []]
84
+ });
85
+ if (typeof children === "object" && children !== null && "nodeType" in children && [_intlayer_types_nodeType.ENUMERATION, _intlayer_types_nodeType.CONDITION].includes(children.nodeType)) return (values) => (arg) => {
86
+ const inner = result(arg);
87
+ if (typeof inner === "function") return inner(values);
88
+ return inner;
89
+ };
90
+ return result;
91
+ }
92
+ };
93
+ /** Markdown string plugin. Replaces string node with a component that render the markdown. */
94
+ const markdownStringPlugin = {
95
+ id: "markdown-string-plugin",
96
+ canHandle: (node) => typeof node === "string",
97
+ transform: (node, props, deepTransformNode) => {
98
+ const { plugins, ...rest } = props;
99
+ const metadataNodes = deepTransformNode((0, _intlayer_core_markdown.getMarkdownMetadata)(node), {
100
+ plugins: [{
101
+ id: "markdown-metadata-plugin",
102
+ canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
103
+ transform: (metadataNode, props) => require_IntlayerNode.renderIntlayerNode({
104
+ ...props,
105
+ value: metadataNode,
106
+ children: _intlayer_config_built.default?.editor.enabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
107
+ ...rest,
108
+ children: node
109
+ }) : node
110
+ })
111
+ }],
112
+ dictionaryKey: rest.dictionaryKey,
113
+ keyPath: []
114
+ });
115
+ const render = (components) => require_IntlayerNode.renderIntlayerNode({
116
+ ...props,
117
+ value: node,
118
+ children: _intlayer_config_built.default.editor.enabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
119
+ ...rest,
120
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_markdown_MarkdownRendererPlugin.MarkdownRendererPlugin, {
121
+ ...rest,
122
+ components,
123
+ children: node
124
+ })
125
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_markdown_MarkdownRendererPlugin.MarkdownRendererPlugin, {
126
+ ...rest,
127
+ components,
128
+ children: node
129
+ }),
130
+ additionalProps: { metadata: metadataNodes }
131
+ });
132
+ const element = render();
133
+ return new Proxy(element, { get(target, prop, receiver) {
134
+ if (prop === "value") return node;
135
+ if (prop === "metadata") return metadataNodes;
136
+ if (prop === "use") return (components) => render(components);
137
+ return Reflect.get(target, prop, receiver);
138
+ } });
139
+ }
140
+ };
141
+ const markdownPlugin = {
142
+ id: "markdown-plugin",
143
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
144
+ transform: (node, props, deepTransformNode) => {
145
+ const newKeyPath = [...props.keyPath, { type: _intlayer_types_nodeType.MARKDOWN }];
146
+ const children = node[_intlayer_types_nodeType.MARKDOWN];
147
+ return deepTransformNode(children, {
148
+ ...props,
149
+ children,
150
+ keyPath: newKeyPath,
151
+ plugins: [markdownStringPlugin, ...props.plugins ?? []]
152
+ });
153
+ }
154
+ };
155
+ /** HTML plugin. Replaces node with a function that takes components => ReactNode. */
156
+ const htmlPlugin = {
157
+ id: "html-plugin",
158
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
159
+ transform: (node, props) => {
160
+ const html = node[_intlayer_types_nodeType.HTML];
161
+ const { plugins, ...rest } = props;
162
+ const render = (userComponents) => (0, react.createElement)(require_html_HTMLRendererPlugin.HTMLRendererPlugin, {
163
+ ...rest,
164
+ html,
165
+ userComponents
166
+ });
167
+ const element = render();
168
+ return new Proxy(element, { get(target, prop, receiver) {
169
+ if (prop === "value") return html;
170
+ if (prop === "use") return (userComponents) => render(userComponents);
171
+ return Reflect.get(target, prop, receiver);
172
+ } });
173
+ }
174
+ };
175
+ /**
176
+ * Get the plugins array for React content transformation.
177
+ * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
178
+ */
179
+ const getPlugins = (locale, fallback = true) => [
180
+ (0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.default.internationalization.defaultLocale, fallback ? _intlayer_config_built.default.internationalization.defaultLocale : void 0),
181
+ _intlayer_core_interpreter.enumerationPlugin,
182
+ _intlayer_core_interpreter.conditionPlugin,
183
+ (0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.default.internationalization.defaultLocale),
184
+ _intlayer_core_interpreter.filePlugin,
185
+ _intlayer_core_interpreter.genderPlugin,
186
+ intlayerNodePlugins,
187
+ reactNodePlugins,
188
+ insertionPlugin,
189
+ markdownPlugin,
190
+ htmlPlugin
191
+ ];
192
+
193
+ //#endregion
194
+ exports.getPlugins = getPlugins;
195
+ exports.htmlPlugin = htmlPlugin;
196
+ exports.insertionPlugin = insertionPlugin;
197
+ exports.intlayerNodePlugins = intlayerNodePlugins;
198
+ exports.markdownPlugin = markdownPlugin;
199
+ exports.markdownStringPlugin = markdownStringPlugin;
200
+ exports.reactNodePlugins = reactNodePlugins;
2
201
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderReactElement","Fragment","NodeType","MarkdownRendererPlugin","HTMLRendererPlugin","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n splitInsertionTemplate,\n translationPlugin,\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 type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { 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: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\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: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\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: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\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: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ) : (\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown 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\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"kjBA+CA,MAAa,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,SAClB,WACE,EACA,CACE,UACA,GAAG,KAGLA,EAAAA,mBAAmB,CACjB,GAAG,EACH,MAAO,EAAK,SACZ,SAAUC,EAAAA,SAAe,OAAO,SAC9B,EAAA,EAAA,KAACC,EAAAA,gBAAD,CAAiB,GAAI,WAAO,EAAK,SAA2B,CAAA,CAE5D,EAAK,S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AAA,QAAc,qBAAqB,cAAc,CACxES,EAAAA,WACAC,EAAAA,aACA,EACA,EACA,EACA,EACA,EACD"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelector","renderReactElement","Fragment","NodeTypes","MarkdownRendererPlugin","HTMLRendererPlugin","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n splitInsertionTemplate,\n translationPlugin,\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 type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRendererPlugin } from './html';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { 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: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{rest.children}</ContentSelector>\n ) : (\n rest.children\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: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderReactElement(node)}</ContentSelector>\n ) : (\n renderReactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.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 === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.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 [NodeTypes.ENUMERATION, NodeTypes.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: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{node}</ContentSelector>\n ) : (\n node\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: configuration.editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ) : (\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as unknown 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 [NodeTypes.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 === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.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 [NodeTypes.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 === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.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\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n reactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgDA,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLA,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UAAUC,gCAAe,OAAO,UAC9B,2CAACC,gDAAD;GAAiB,GAAI;aAAO,KAAK;GAA2B,IAE5D,KAAK;EAER,CAAC;CACL;;AAcD,MAAa,mBAA4B;CACvC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,MAAM,UAAU,eACvB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGLF,wCAAmB;EACjB,GAAG;EACH,O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AAaD,yBAAU;CAC3D,YAAY,MAAuB,OAAO,sBAAsB;EAC9D,MAAM,aAAwB,CAC5B,GAAG,MAAM,SACT,EACE,MAAMA,yBAAU,UACjB,CACF;EAED,MAAM,WAAW,KAAKA,yBAAU;AAEhC,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL;;AA4BD,MAAa,aAAsB;CACjC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAE3D,YAAY,MAA2B,UAAU;EAC/C,MAAM,OAAO,KAAKA,yBAAU;EAC5B,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,4CACAE,oDAAoB;GAAE,GAAG;GAAM;GAAM;GAAgB,CAAC;EAEtE,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,MAEX,SAAQ,mBAAoC,OAAO,eAAe;AAGpE,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;;;;;AAuCD,MAAa,cACX,QACA,WAAoB,SACN;mDAEZ,UAAUN,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACDO;CACAC;8CACa,UAAUR,+BAAc,qBAAqB,cAAc;CACxES;CACAC;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1,2 +1,53 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`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(0,e.createElement)(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(0,e.createElement)(r??`span`,i,...i.children)};exports.renderReactElement=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+
5
+ //#region src/reactElement/renderReactElement.ts
6
+ const renderReactElement = (element) => {
7
+ if (element === null || typeof element !== "object") return element;
8
+ const convertChildrenAsArray = (element) => {
9
+ const children = element.props?.children;
10
+ if (Array.isArray(children)) {
11
+ const childrenResult = children.map((child, index) => {
12
+ const renderedChild = renderReactElement(child);
13
+ if (typeof renderedChild === "object" && renderedChild !== null && "type" in renderedChild) {
14
+ const childElement = renderedChild;
15
+ return (0, react.createElement)(childElement.type, {
16
+ ...childElement.props,
17
+ key: index
18
+ }, ...Array.isArray(childElement.props?.children) ? childElement.props.children : typeof childElement.props?.children !== "undefined" ? [childElement.props.children] : []);
19
+ }
20
+ return renderedChild;
21
+ });
22
+ return {
23
+ ...element,
24
+ props: {
25
+ ...element.props,
26
+ children: childrenResult
27
+ }
28
+ };
29
+ } else if (typeof children !== "undefined" && children !== null) {
30
+ const renderedChild = renderReactElement(children);
31
+ return {
32
+ ...element,
33
+ props: {
34
+ ...element.props,
35
+ children: [renderedChild]
36
+ }
37
+ };
38
+ }
39
+ return {
40
+ ...element,
41
+ props: {
42
+ ...element.props,
43
+ children: []
44
+ }
45
+ };
46
+ };
47
+ const { type, props } = convertChildrenAsArray(element);
48
+ return (0, react.createElement)(type ?? "span", props, ...props.children);
49
+ };
50
+
51
+ //#endregion
52
+ exports.renderReactElement = renderReactElement;
2
53
  //# sourceMappingURL=renderReactElement.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderReactElement.cjs","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":"uIAGA,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,OAAA,EAAA,EAAA,eACE,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,OAAA,EAAA,EAAA,eACE,GAAQ,OACR,EACA,GAAI,EAAM,SACX"}
1
+ {"version":3,"file":"renderReactElement.cjs","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,qCACE,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,iCACE,QAAQ,QACR,OACA,GAAI,MAAM,SACX"}
@@ -1,2 +1,35 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./serverContext.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);let r=require(`react/jsx-runtime`);const{defaultLocale:i}=n.default?.internationalization??{},a=t.createServerContext(i),o=()=>t.getServerContext(a),s=t.getServerContext(a),c=({children:e,locale:t=i})=>(0,r.jsx)(a.Provider,{value:t,children:e});exports.IntlayerServerContext=a,exports.IntlayerServerProvider=c,exports.locale=s,exports.useIntlayer=o;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_server_serverContext = require('./serverContext.cjs');
4
+ let _intlayer_config_built = require("@intlayer/config/built");
5
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/server/IntlayerServerProvider.tsx
9
+ const { defaultLocale } = _intlayer_config_built.default?.internationalization ?? {};
10
+ /**
11
+ * Context that store the current locale on the server side
12
+ */
13
+ const IntlayerServerContext = require_server_serverContext.createServerContext(defaultLocale);
14
+ /**
15
+ * Hook that provides the current locale
16
+ */
17
+ const useIntlayer = () => require_server_serverContext.getServerContext(IntlayerServerContext);
18
+ /**
19
+ * Get the current locale
20
+ */
21
+ const locale = require_server_serverContext.getServerContext(IntlayerServerContext);
22
+ /**
23
+ * Provider that store the current locale on the server side
24
+ */
25
+ const IntlayerServerProvider = ({ children, locale = defaultLocale }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerServerContext.Provider, {
26
+ value: locale,
27
+ children
28
+ });
29
+
30
+ //#endregion
31
+ exports.IntlayerServerContext = IntlayerServerContext;
32
+ exports.IntlayerServerProvider = IntlayerServerProvider;
33
+ exports.locale = locale;
34
+ exports.useIntlayer = useIntlayer;
2
35
  //# sourceMappingURL=IntlayerServerProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerServerProvider.cjs","names":["configuration","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"mPAMA,KAAM,CAAE,iBAAkBA,EAAAA,SAAe,sBAAwB,EAAE,CAKtD,EACXC,EAAAA,oBAAmC,EAAc,CAKtC,MAAoBC,EAAAA,iBAAiB,EAAsB,CAK3D,EAASA,EAAAA,iBAAiB,EAAsB,CAShD,GAA2D,CACtE,WACA,SAAS,MAET,EAAA,EAAA,KAAC,EAAsB,SAAvB,CAAgC,MAAO,EACpC,WAC8B,CAAA"}
1
+ {"version":3,"file":"IntlayerServerProvider.cjs","names":["configuration","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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,kBAAkBA,gCAAe,wBAAwB,EAAE;;;;AAKnE,MAAa,wBACXC,iDAAmC,cAAc;;;;AAKnD,MAAa,oBAAoBC,8CAAiB,sBAAsB;;;;AAKxE,MAAa,SAASA,8CAAiB,sBAAsB;;;;AAS7D,MAAa,0BAA2D,EACtE,UACA,SAAS,oBAET,2CAAC,sBAAsB,UAAvB;CAAgC,OAAO;CACpC;CAC8B"}
@@ -1 +1,18 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useUnit.cjs`),t=require(`./useDate.cjs`),n=require(`./useNumber.cjs`),r=require(`./useRelativeTime.cjs`),i=require(`./useCompact.cjs`),a=require(`./useList.cjs`),o=require(`./usePercentage.cjs`),s=require(`./useCurrency.cjs`);exports.useCompact=i.useCompact,exports.useCurrency=s.useCurrency,exports.useDate=t.useDate,exports.useList=a.useList,exports.useNumber=n.useNumber,exports.usePercentage=o.usePercentage,exports.useRelativeTime=r.useRelativeTime,exports.useUnit=e.useUnit;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_server_format_useUnit = require('./useUnit.cjs');
3
+ const require_server_format_useDate = require('./useDate.cjs');
4
+ const require_server_format_useNumber = require('./useNumber.cjs');
5
+ const require_server_format_useRelativeTime = require('./useRelativeTime.cjs');
6
+ const require_server_format_useCompact = require('./useCompact.cjs');
7
+ const require_server_format_useList = require('./useList.cjs');
8
+ const require_server_format_usePercentage = require('./usePercentage.cjs');
9
+ const require_server_format_useCurrency = require('./useCurrency.cjs');
10
+
11
+ exports.useCompact = require_server_format_useCompact.useCompact;
12
+ exports.useCurrency = require_server_format_useCurrency.useCurrency;
13
+ exports.useDate = require_server_format_useDate.useDate;
14
+ exports.useList = require_server_format_useList.useList;
15
+ exports.useNumber = require_server_format_useNumber.useNumber;
16
+ exports.usePercentage = require_server_format_usePercentage.usePercentage;
17
+ exports.useRelativeTime = require_server_format_useRelativeTime.useRelativeTime;
18
+ exports.useUnit = require_server_format_useUnit.useUnit;
@@ -1,2 +1,28 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.compact)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useCompact=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_server_serverContext = require('../serverContext.cjs');
4
+ const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
5
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
6
+
7
+ //#region src/server/format/useCompact.ts
8
+ /**
9
+ * React client hook that provides a compact number formatter
10
+ * bound to the current application locale.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const formatCompact = useCompact();
15
+ * formatCompact(1500); // "1.5K"
16
+ * ```
17
+ */
18
+ const useCompact = () => {
19
+ const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
20
+ return (...args) => (0, _intlayer_core_formatters.compact)(args[0], {
21
+ ...args[1],
22
+ locale: args[1]?.locale ?? locale
23
+ });
24
+ };
25
+
26
+ //#endregion
27
+ exports.useCompact = useCompact;
2
28
  //# sourceMappingURL=useCompact.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"iPAeA,MAAa,MAAmB,CAC9B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,SACD,EAAK,GAAI,CACf,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
1
+ {"version":3,"file":"useCompact.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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,SAASA,8CAAgCC,4DAAsB;AAErE,SAAQ,GAAG,gDACD,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
@@ -1,2 +1,39 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.currency)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useCurrency=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_server_serverContext = require('../serverContext.cjs');
4
+ const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
5
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
6
+
7
+ //#region src/server/format/useCurrency.ts
8
+ /**
9
+ * React client hook that provides a currency formatter
10
+ * bound to the current application locale.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const formatCurrency = useCurrency();
15
+ *
16
+ * formatCurrency(1500, { currency: "USD" });
17
+ * // "$1,500.00"
18
+ *
19
+ * formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
20
+ * // "1.500,00 €"
21
+ *
22
+ * formatCurrency(9876543.21, {
23
+ * currency: "JPY",
24
+ * fractionDigits: 0,
25
+ * });
26
+ * // "¥9,876,543"
27
+ * ```
28
+ */
29
+ const useCurrency = () => {
30
+ const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
31
+ return (...args) => (0, _intlayer_core_formatters.currency)(args[0], {
32
+ ...args[1],
33
+ locale: args[1]?.locale ?? locale
34
+ });
35
+ };
36
+
37
+ //#endregion
38
+ exports.useCurrency = useCurrency;
2
39
  //# sourceMappingURL=useCurrency.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"iPA0BA,MAAa,MAAoB,CAC/B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,UACA,EAAK,GAAI,CAChB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
1
+ {"version":3,"file":"useCurrency.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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,SAASA,8CAAgCC,4DAAsB;AAErE,SAAQ,GAAG,iDACA,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}