react-intlayer 8.4.3 → 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,18 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);let e=require(`react`),t=require(`react/jsx-runtime`);const n=({children:n,value:r,additionalProps:i})=>{let a=(0,e.isValidElement)(n)?n:(0,t.jsx)(t.Fragment,{children:n});return new Proxy(a,{get(e,t,n){return t===`value`?r:i&&Object.keys(i).includes(t)?i[t]:Reflect.get(e,t,n)}})};exports.renderIntlayerNode=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ let react = require("react");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+
6
+ //#region src/IntlayerNode.tsx
7
+ const renderIntlayerNode = ({ children, value, additionalProps }) => {
8
+ const element = (0, react.isValidElement)(children) ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
9
+ return new Proxy(element, { get(target, prop, receiver) {
10
+ if (prop === "value") return value;
11
+ if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
12
+ return Reflect.get(target, prop, receiver);
13
+ } });
14
+ };
15
+
16
+ //#endregion
17
+ exports.renderIntlayerNode = renderIntlayerNode;
2
18
  //# sourceMappingURL=IntlayerNode.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerNode.cjs","names":[],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n isValidElement,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = Record<string, never>,\n> = ResolvedEditor<T, ReactNode> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid ReactElement, wrap it in a fragment\n const element: ReactElement<any> = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as ReactElement, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":"qKAsBA,MAAa,GAEX,CACA,WACA,QACA,qBACiD,CAEjD,IAAM,GAAA,EAAA,EAAA,gBAA4C,EAAS,CACzD,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAG,WAAY,CAAA,CAKjB,OAAO,IAAI,MAAM,EAAyB,CACxC,IAAI,EAAQ,EAAM,EAAU,CAY1B,OAXI,IAAS,QACJ,EAIP,GACA,OAAO,KAAK,EAAgB,CAAC,SAAS,EAAe,CAE9C,EAAgB,GAGlB,QAAQ,IAAI,EAAQ,EAAM,EAAS,EAE7C,CAAC"}
1
+ {"version":3,"file":"IntlayerNode.cjs","names":[],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n isValidElement,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = Record<string, never>,\n> = ResolvedEditor<T, ReactNode> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid ReactElement, wrap it in a fragment\n const element: ReactElement<any> = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as ReactElement, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;;;;AAsBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CAEjD,MAAM,oCAA4C,SAAS,GACzD,WAEA,yEAAG,UAAY;AAKjB,QAAO,IAAI,MAAM,SAAyB,EACxC,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QACX,QAAO;AAGT,MACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC"}
@@ -1,2 +1,97 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`react`),t=require(`react/jsx-runtime`);const n=({children:n,onPress:r,onHover:i,onUnhover:a,onClickOutside:o,pressDuration:s=250,isSelecting:c,...l})=>{let u=(0,e.useRef)(null),[d,f]=(0,e.useState)(!1),[p,m]=(0,e.useState)(c),h=(0,e.useRef)(null),g=typeof n==`string`,_=()=>{m(!0),r()},v=()=>{h.current=setTimeout(()=>{_()},s)},y=()=>{h.current&&=(clearTimeout(h.current),null)},b=()=>{y(),v()},x=()=>{f(!0),i?.()},S=()=>{a?.(),f(!1),y()},C=(0,e.useCallback)(e=>{u.current&&!u.current.contains(e.target)&&(m(!1),o?.())},[o]);return(0,e.useEffect)(()=>(document.addEventListener(`mousedown`,C),()=>{document.removeEventListener(`mousedown`,C)}),[C]),(0,t.jsx)(`span`,{style:{display:g?`inline`:`inline-block`,cursor:`pointer`,userSelect:`none`,borderRadius:`0.375rem`,outlineWidth:`2px`,outlineOffset:`4px`,outlineStyle:`solid`,outlineColor:c||p||d?`inherit`:`transparent`,transition:`all 100ms 50ms ease-in-out`},role:`button`,tabIndex:0,onKeyUp:()=>null,onClick:e=>{p&&(e.preventDefault(),e.stopPropagation())},onMouseDown:b,onMouseUp:S,onMouseLeave:S,onTouchStart:b,onTouchEnd:S,onTouchCancel:S,onBlur:()=>{m(!1)},onMouseEnter:x,ref:u,...l,children:n})};exports.ContentSelector=n;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
+ let react = require("react");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+
8
+ //#region src/UI/ContentSelector.tsx
9
+ const DEFAULT_PRESS_DETECT_DURATION = 250;
10
+ const ContentSelector = ({ children, onPress, onHover, onUnhover, onClickOutside: onUnselect, pressDuration = DEFAULT_PRESS_DETECT_DURATION, isSelecting: isSelectingProp, ...props }) => {
11
+ const divRef = (0, react.useRef)(null);
12
+ const [isHovered, setIsHovered] = (0, react.useState)(false);
13
+ const [isSelectingState, setIsSelectingState] = (0, react.useState)(isSelectingProp);
14
+ const pressTimerRef = (0, react.useRef)(null);
15
+ const isChildrenString = typeof children === "string";
16
+ const handleOnLongPress = () => {
17
+ setIsSelectingState(true);
18
+ onPress();
19
+ };
20
+ const startPressTimer = () => {
21
+ pressTimerRef.current = setTimeout(() => {
22
+ handleOnLongPress();
23
+ }, pressDuration);
24
+ };
25
+ const clearPressTimer = () => {
26
+ if (pressTimerRef.current) {
27
+ clearTimeout(pressTimerRef.current);
28
+ pressTimerRef.current = null;
29
+ }
30
+ };
31
+ const handleMouseDown = () => {
32
+ clearPressTimer();
33
+ startPressTimer();
34
+ };
35
+ const handleMouseEnter = () => {
36
+ setIsHovered(true);
37
+ onHover?.();
38
+ };
39
+ const handleMouseUp = () => {
40
+ onUnhover?.();
41
+ setIsHovered(false);
42
+ clearPressTimer();
43
+ };
44
+ const handleClickOutside = (0, react.useCallback)((event) => {
45
+ if (divRef.current && !divRef.current.contains(event.target)) {
46
+ setIsSelectingState(false);
47
+ onUnselect?.();
48
+ }
49
+ }, [onUnselect]);
50
+ (0, react.useEffect)(() => {
51
+ document.addEventListener("mousedown", handleClickOutside);
52
+ return () => {
53
+ document.removeEventListener("mousedown", handleClickOutside);
54
+ };
55
+ }, [handleClickOutside]);
56
+ const handleOnClick = (e) => {
57
+ if (isSelectingState) {
58
+ e.preventDefault();
59
+ e.stopPropagation();
60
+ }
61
+ };
62
+ const handleOnBlur = () => {
63
+ setIsSelectingState(false);
64
+ };
65
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
66
+ style: {
67
+ display: isChildrenString ? "inline" : "inline-block",
68
+ cursor: "pointer",
69
+ userSelect: "none",
70
+ borderRadius: "0.375rem",
71
+ outlineWidth: "2px",
72
+ outlineOffset: "4px",
73
+ outlineStyle: "solid",
74
+ outlineColor: isSelectingProp || isSelectingState || isHovered ? "inherit" : "transparent",
75
+ transition: "all 100ms 50ms ease-in-out"
76
+ },
77
+ role: "button",
78
+ tabIndex: 0,
79
+ onKeyUp: () => null,
80
+ onClick: handleOnClick,
81
+ onMouseDown: handleMouseDown,
82
+ onMouseUp: handleMouseUp,
83
+ onMouseLeave: handleMouseUp,
84
+ onTouchStart: handleMouseDown,
85
+ onTouchEnd: handleMouseUp,
86
+ onTouchCancel: handleMouseUp,
87
+ onBlur: handleOnBlur,
88
+ onMouseEnter: handleMouseEnter,
89
+ ref: divRef,
90
+ ...props,
91
+ children
92
+ });
93
+ };
94
+
95
+ //#endregion
96
+ exports.ContentSelector = ContentSelector;
2
97
  //# sourceMappingURL=ContentSelector.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":"mLAYA,MAWa,GAA6C,CACxD,WACA,UACA,UACA,YACA,eAAgB,EAChB,gBAAgB,IAChB,YAAa,EACb,GAAG,KACC,CACJ,IAAM,GAAA,EAAA,EAAA,QAAgC,KAAK,CACrC,CAAC,EAAW,IAAA,EAAA,EAAA,UAAyB,GAAM,CAC3C,CAAC,EAAkB,IAAA,EAAA,EAAA,UAAgC,EAAgB,CACnE,GAAA,EAAA,EAAA,QAA6D,KAAK,CAClE,EAAmB,OAAO,GAAa,SAEvC,MAA0B,CAC9B,EAAoB,GAAK,CACzB,GAAS,EAGL,MAAwB,CAC5B,EAAc,QAAU,eAAiB,CACvC,GAAmB,EAClB,EAAc,EAGb,MAAwB,CAC5B,AAEE,EAAc,WADd,aAAa,EAAc,QAAQ,CACX,OAItB,MAAwB,CAC5B,GAAiB,CACjB,GAAiB,EAGb,MAAyB,CAC7B,EAAa,GAAK,CAClB,KAAW,EAGP,MAAsB,CAC1B,KAAa,CACb,EAAa,GAAM,CACnB,GAAiB,EAIb,GAAA,EAAA,EAAA,aACH,GAAsB,CACjB,EAAO,SAAW,CAAC,EAAO,QAAQ,SAAS,EAAM,OAAe,GAClE,EAAoB,GAAM,CAC1B,KAAc,GAGlB,CAAC,EAAW,CACb,CAyBD,OAvBA,EAAA,EAAA,gBAEE,SAAS,iBAAiB,YAAa,EAAmB,KAE7C,CAEX,SAAS,oBAAoB,YAAa,EAAmB,GAG9D,CAAC,EAAmB,CAAC,EAetB,EAAA,EAAA,KAAC,OAAD,CACE,MAAO,CACL,QAAS,EAAmB,SAAW,eACvC,OAAQ,UACR,WAAY,OACZ,aAAc,WACd,aAAc,MACd,cAAe,MACf,aAAc,QACd,aACE,GAAmB,GAAoB,EACnC,UACA,cACN,WAAY,6BACb,CACD,KAAK,SACL,SAAU,EACV,YAAe,KACf,QA/BsD,GAAM,CAC1D,IACF,EAAE,gBAAgB,CAClB,EAAE,iBAAiB,GA6BnB,YAAa,EACb,UAAW,EACX,aAAc,EACd,aAAc,EACd,WAAY,EACZ,cAAe,EACf,WA/BuB,CAEzB,EAAoB,GAAM,EA8BxB,aAAc,EACd,IAAK,EACL,GAAI,EAEH,WACI,CAAA"}
1
+ {"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,gCAAgC;AAWtC,MAAa,mBAA6C,EACxD,UACA,SACA,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,2BAAgC,KAAK;CAC3C,MAAM,CAAC,WAAW,oCAAyB,MAAM;CACjD,MAAM,CAAC,kBAAkB,2CAAgC,gBAAgB;CACzE,MAAM,kCAA6D,KAAK;CACxE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;AAC9B,sBAAoB,KAAK;AACzB,WAAS;;CAGX,MAAM,wBAAwB;AAC5B,gBAAc,UAAU,iBAAiB;AACvC,sBAAmB;KAClB,cAAc;;CAGnB,MAAM,wBAAwB;AAC5B,MAAI,cAAc,SAAS;AACzB,gBAAa,cAAc,QAAQ;AACnC,iBAAc,UAAU;;;CAI5B,MAAM,wBAAwB;AAC5B,mBAAiB;AACjB,mBAAiB;;CAGnB,MAAM,yBAAyB;AAC7B,eAAa,KAAK;AAClB,aAAW;;CAGb,MAAM,sBAAsB;AAC1B,eAAa;AACb,eAAa,MAAM;AACnB,mBAAiB;;CAInB,MAAM,6CACH,UAAsB;AACrB,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,OAAe,EAAE;AACpE,uBAAoB,MAAM;AAC1B,iBAAc;;IAGlB,CAAC,WAAW,CACb;AAED,4BAAgB;AAEd,WAAS,iBAAiB,aAAa,mBAAmB;AAE1D,eAAa;AAEX,YAAS,oBAAoB,aAAa,mBAAmB;;IAG9D,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAoD,MAAM;AAC9D,MAAI,kBAAkB;AACpB,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;;CAIvB,MAAM,qBAAqB;AAEzB,sBAAoB,MAAM;;AAG5B,QACE,2CAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;GACb;EACD,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;EACI"}
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1,2 +1,93 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../editor/EditorProvider.cjs`),n=require(`./useLocaleStorage.cjs`);let r=require(`@intlayer/config/built`);r=e.__toESM(r);let i=require(`react`),a=require(`react/jsx-runtime`),o=require(`@intlayer/core/localization`);const s=(0,i.createContext)({locale:n.localeInStorage??r.default?.internationalization?.defaultLocale,setLocale:()=>null,isCookieEnabled:!0}),c=()=>(0,i.useContext)(s),l=({locale:e,defaultLocale:t,children:c,setLocale:l,disableEditor:u,isCookieEnabled:d})=>{let{internationalization:f}=r.default??{},{locales:p,defaultLocale:m}=f??{},[h,g]=(0,i.useState)(e??n.localeInStorage??t??m);(0,i.useEffect)(()=>{e&&e!==h&&g(e)},[e]);let _=l??(e=>{if(h.toString()!==e.toString()){if(!p?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}g(e),n.setLocaleInStorage(e,d)}}),v=(0,o.localeResolver)(h);return(0,a.jsx)(s.Provider,{value:{locale:v,setLocale:_,disableEditor:u},children:c})},u=({children:e,...n})=>(0,a.jsxs)(l,{...n,children:[(0,a.jsx)(t.EditorProvider,{}),e]});exports.IntlayerClientContext=s,exports.IntlayerProvider=u,exports.IntlayerProviderContent=l,exports.useIntlayerContext=c;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
+ const require_editor_EditorProvider = require('../editor/EditorProvider.cjs');
6
+ const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
7
+ let _intlayer_config_built = require("@intlayer/config/built");
8
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
9
+ let react = require("react");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
11
+ let _intlayer_core_localization = require("@intlayer/core/localization");
12
+
13
+ //#region src/client/IntlayerProvider.tsx
14
+ /**
15
+ * Context that stores the current locale on the client side.
16
+ */
17
+ const IntlayerClientContext = (0, react.createContext)({
18
+ locale: require_client_useLocaleStorage.localeInStorage ?? _intlayer_config_built.default?.internationalization?.defaultLocale,
19
+ setLocale: () => null,
20
+ isCookieEnabled: true
21
+ });
22
+ /**
23
+ * Hook that provides the current Intlayer client context.
24
+ *
25
+ * @returns The current Intlayer context values.
26
+ */
27
+ const useIntlayerContext = () => (0, react.useContext)(IntlayerClientContext);
28
+ /**
29
+ * Provider that stores the current locale on the client side.
30
+ *
31
+ * This component is focused on content delivery without the editor features.
32
+ *
33
+ * @param props - The provider props.
34
+ * @returns The provider component.
35
+ */
36
+ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
37
+ const { internationalization } = _intlayer_config_built.default ?? {};
38
+ const { locales: availableLocales, defaultLocale: defaultLocaleConfig } = internationalization ?? {};
39
+ const [currentLocale, setCurrentLocale] = (0, react.useState)(localeProp ?? require_client_useLocaleStorage.localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
40
+ (0, react.useEffect)(() => {
41
+ if (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);
42
+ }, [localeProp]);
43
+ const setLocaleBase = (newLocale) => {
44
+ if (currentLocale.toString() === newLocale.toString()) return;
45
+ if (!availableLocales?.map(String).includes(newLocale)) {
46
+ console.error(`Locale ${newLocale} is not available`);
47
+ return;
48
+ }
49
+ setCurrentLocale(newLocale);
50
+ require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled);
51
+ };
52
+ const setLocale = setLocaleProp ?? setLocaleBase;
53
+ const resolvedLocale = (0, _intlayer_core_localization.localeResolver)(currentLocale);
54
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerClientContext.Provider, {
55
+ value: {
56
+ locale: resolvedLocale,
57
+ setLocale,
58
+ disableEditor
59
+ },
60
+ children
61
+ });
62
+ };
63
+ /**
64
+ * Main provider for Intlayer in React applications.
65
+ *
66
+ * It includes the editor provider by default, allowing for live content editing
67
+ * if configured.
68
+ *
69
+ * @param props - The provider props.
70
+ * @returns The provider component with editor support.
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * import { IntlayerProvider } from 'react-intlayer';
75
+ *
76
+ * const App = () => (
77
+ * <IntlayerProvider>
78
+ * <MyComponent />
79
+ * </IntlayerProvider>
80
+ * );
81
+ * ```
82
+ */
83
+ const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(IntlayerProviderContent, {
84
+ ...props,
85
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_EditorProvider.EditorProvider, {}), children]
86
+ });
87
+
88
+ //#endregion
89
+ exports.IntlayerClientContext = IntlayerClientContext;
90
+ exports.IntlayerProvider = IntlayerProvider;
91
+ exports.IntlayerProviderContent = IntlayerProviderContent;
92
+ exports.useIntlayerContext = useIntlayerContext;
2
93
  //# sourceMappingURL=IntlayerProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":"yWA0BA,MAAa,GAAA,EAAA,EAAA,eAAqD,CAChE,OAAQA,EAAAA,iBAAmBC,EAAAA,SAAe,sBAAsB,cAChE,cAAiB,KACjB,gBAAiB,GAClB,CAAC,CAOW,OAAA,EAAA,EAAA,YAAsC,EAAsB,CAoC5D,GAAsD,CACjE,OAAQ,EACR,cAAe,EACf,WACA,UAAW,EACX,gBACA,qBACI,CACJ,GAAM,CAAE,wBAAyBA,EAAAA,SAAiB,EAAE,CAC9C,CAAE,QAAS,EAAkB,cAAe,GAChD,GAAwB,EAAE,CAKtB,CAAC,EAAe,IAAA,EAAA,EAAA,UAFpB,GAAcD,EAAAA,iBAAmB,GAAqB,EAGhB,EAGxC,EAAA,EAAA,eAAgB,CACV,GAAc,IAAe,GAC/B,EAAiB,EAAW,EAE7B,CAAC,EAAW,CAAC,CAchB,IAAM,EAAY,IAZK,GAA6B,CAC9C,KAAc,UAAU,GAAK,EAAU,UAAU,CAErD,IAAI,CAAC,GAAkB,IAAI,OAAO,CAAC,SAAS,EAAU,CAAE,CACtD,QAAQ,MAAM,UAAU,EAAU,mBAAmB,CACrD,OAGF,EAAiB,EAAU,CAC3B,EAAA,mBAAmB,EAAW,EAAgB,IAM1C,GAAA,EAAA,EAAA,gBAAgC,EAAc,CAEpD,OACE,EAAA,EAAA,KAAC,EAAsB,SAAvB,CACE,MAAO,CACL,OAAQ,EACR,YACA,gBACD,CAEA,WAC8B,CAAA,EAwBxB,GAA+C,CAC1D,WACA,GAAG,MAEH,EAAA,EAAA,MAAC,EAAD,CAAyB,GAAI,WAA7B,EACE,EAAA,EAAA,KAACE,EAAAA,eAAD,EAAkB,CAAA,CACjB,EACuB"}
1
+ {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n const initialLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] =\n useState<LocalesValues>(initialLocale);\n\n // Sync the prop to state if the prop changes from the parent\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp]);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,MAAa,iDAAqD;CAChE,QAAQA,mDAAmBC,gCAAe,sBAAsB;CAChE,iBAAiB;CACjB,iBAAiB;CAClB,CAAC;;;;;;AAOF,MAAa,iDAAsC,sBAAsB;;;;;;;;;AAoCzE,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyBA,kCAAiB,EAAE;CACpD,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,wCAFpB,cAAcD,mDAAmB,qBAAqB,oBAGhB;AAGxC,4BAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B,CAAC,WAAW,CAAC;CAEhB,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,qDAAmB,WAAW,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAGnC,MAAM,iEAAgC,cAAc;AAEpD,QACE,2CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,4CAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,2CAACE,8CAAD,EAAkB,GACjB,SACuB"}
@@ -1 +1,20 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useIntl.cjs`),t=require(`./useUnit.cjs`),n=require(`./useDate.cjs`),r=require(`./useNumber.cjs`),i=require(`./useRelativeTime.cjs`),a=require(`./useCompact.cjs`),o=require(`./useList.cjs`),s=require(`./usePercentage.cjs`),c=require(`./useCurrency.cjs`);exports.useCompact=a.useCompact,exports.useCurrency=c.useCurrency,exports.useDate=n.useDate,exports.useIntl=e.useIntl,exports.useList=o.useList,exports.useNumber=r.useNumber,exports.usePercentage=s.usePercentage,exports.useRelativeTime=i.useRelativeTime,exports.useUnit=t.useUnit;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_client_format_useIntl = require('./useIntl.cjs');
3
+ const require_client_format_useUnit = require('./useUnit.cjs');
4
+ const require_client_format_useDate = require('./useDate.cjs');
5
+ const require_client_format_useNumber = require('./useNumber.cjs');
6
+ const require_client_format_useRelativeTime = require('./useRelativeTime.cjs');
7
+ const require_client_format_useCompact = require('./useCompact.cjs');
8
+ const require_client_format_useList = require('./useList.cjs');
9
+ const require_client_format_usePercentage = require('./usePercentage.cjs');
10
+ const require_client_format_useCurrency = require('./useCurrency.cjs');
11
+
12
+ exports.useCompact = require_client_format_useCompact.useCompact;
13
+ exports.useCurrency = require_client_format_useCurrency.useCurrency;
14
+ exports.useDate = require_client_format_useDate.useDate;
15
+ exports.useIntl = require_client_format_useIntl.useIntl;
16
+ exports.useList = require_client_format_useList.useList;
17
+ exports.useNumber = require_client_format_useNumber.useNumber;
18
+ exports.usePercentage = require_client_format_usePercentage.usePercentage;
19
+ exports.useRelativeTime = require_client_format_useRelativeTime.useRelativeTime;
20
+ exports.useUnit = require_client_format_useUnit.useUnit;
@@ -1,2 +1,30 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.compact)(e[0],{...e[1],locale:e[1]?.locale??r}),[r])};exports.useCompact=r;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let react = require("react");
7
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
8
+
9
+ //#region src/client/format/useCompact.ts
10
+ /**
11
+ * React client hook that provides a compact number formatter
12
+ * bound to the current application locale.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const formatCompact = useCompact();
17
+ * formatCompact(1500); // "1.5K"
18
+ * ```
19
+ */
20
+ const useCompact = () => {
21
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
22
+ return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.compact)(args[0], {
23
+ ...args[1],
24
+ locale: args[1]?.locale ?? locale
25
+ }), [locale]);
26
+ };
27
+
28
+ //#endregion
29
+ exports.useCompact = useCompact;
2
30
  //# sourceMappingURL=useCompact.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"yOAgBA,MAAa,MAAmB,CAC9B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,SACM,EAAK,GAAI,CACf,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useCompact.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,gDACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,2 +1,44 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.currency)(e[0],{...e[1],locale:e[1]?.locale??r}),[r])};exports.useCurrency=r;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let react = require("react");
7
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
8
+
9
+ //#region src/client/format/useCurrency.ts
10
+ /**
11
+ * React client hook that provides a currency formatter
12
+ * bound to the current application locale.
13
+ *
14
+ * @returns {(value: string | number, options?: CurrencyProps) => string}
15
+ * A function to format numbers into localized currency strings.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const formatCurrency = useCurrency();
20
+ *
21
+ * formatCurrency(1500, { currency: "USD" });
22
+ * // "$1,500.00"
23
+ *
24
+ * formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
25
+ * // "1.500,00 €"
26
+ *
27
+ * formatCurrency(9876543.21, {
28
+ * currency: "JPY",
29
+ * fractionDigits: 0,
30
+ * });
31
+ * // "¥9,876,543"
32
+ * ```
33
+ */
34
+ const useCurrency = () => {
35
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
36
+ return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.currency)(args[0], {
37
+ ...args[1],
38
+ locale: args[1]?.locale ?? locale
39
+ }), [locale]);
40
+ };
41
+
42
+ //#endregion
43
+ exports.useCurrency = useCurrency;
2
44
  //# sourceMappingURL=useCurrency.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"yOA8BA,MAAa,MAAoB,CAC/B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,UACO,EAAK,GAAI,CAChB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useCurrency.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,iDACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,2 +1,46 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(...e)=>(0,n.date)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useDate=r;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let react = require("react");
7
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
8
+
9
+ //#region src/client/format/useDate.ts
10
+ /**
11
+ * React client hook that provides a localized date/time formatter
12
+ * bound to the current application locale.
13
+ *
14
+ * @returns {(date: Date | string | number, options?: DateProps) => string}
15
+ * A function to format dates or timestamps into localized date/time strings.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const formatDate = useDate();
20
+ *
21
+ * formatDate(new Date("2025-01-01"));
22
+ * // "Jan 1, 2025"
23
+ *
24
+ * formatDate("2025-01-01T15:30:00Z", {
25
+ * dateStyle: "full",
26
+ * timeStyle: "short",
27
+ * });
28
+ * // "Wednesday, January 1, 2025 at 3:30 PM"
29
+ *
30
+ * formatDate(1735689600000, { locale: "fr-FR", dateStyle: "long" });
31
+ * // "1 janvier 2025"
32
+ * ```
33
+ *
34
+ * @see createDate
35
+ */
36
+ const useDate = () => {
37
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
38
+ return (...args) => (0, _intlayer_core_formatters.date)(args[0], {
39
+ ...args[1],
40
+ locale: args[1]?.locale ?? locale
41
+ });
42
+ };
43
+
44
+ //#endregion
45
+ exports.useDate = useDate;
2
46
  //# sourceMappingURL=useDate.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core/formatters';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"yOAgCA,MAAa,MAAgB,CAC3B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAQ,GAAG,KAAA,EAAA,EAAA,MACJ,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
1
+ {"version":3,"file":"useDate.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core/formatters';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,SAAQ,GAAG,6CACJ,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
@@ -1,2 +1,46 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=r=>{let{locale:i}=(0,t.useContext)(e.IntlayerClientContext),a=r??i;return(0,t.useMemo)(()=>(0,n.bindIntl)(a),[a])};exports.useIntl=r;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let react = require("react");
7
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
8
+
9
+ //#region src/client/format/useIntl.ts
10
+ /**
11
+ * React client hook that provides a locale-bound `Intl` object.
12
+ *
13
+ * It acts exactly like the native `Intl` object, but acts as a proxy to:
14
+ * 1. Inject the current locale automatically if none is provided.
15
+ * 2. Use the performance-optimized `CachedIntl` under the hood.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const intl = useIntl(); // uses context locale
20
+ *
21
+ * // Standard API, but no need to pass 'en-US' as the first argument
22
+ * const formatted = new intl.NumberFormat({
23
+ * style: 'currency',
24
+ * currency: 'USD'
25
+ * }).format(123.45);
26
+ * ```
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const intl = useIntl();
31
+ *
32
+ * // You can still override the locale if needed
33
+ * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());
34
+ * // or
35
+ * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());
36
+ * ```
37
+ */
38
+ const useIntl = (locale) => {
39
+ const { locale: contextLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
40
+ const currentLocale = locale ?? contextLocale;
41
+ return (0, react.useMemo)(() => (0, _intlayer_core_formatters.bindIntl)(currentLocale), [currentLocale]);
42
+ };
43
+
44
+ //#endregion
45
+ exports.useIntl = useIntl;
2
46
  //# sourceMappingURL=useIntl.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\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 { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"yOAmCA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,UAA2C,EAAc,CAAE,CAAC,EAAc,CAAC"}
1
+ {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\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 { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,wCAA6BA,sDAAsB;CACnE,MAAM,gBAAgB,UAAU;AAEhC,yEAA2C,cAAc,EAAE,CAAC,cAAc,CAAC"}
@@ -1,2 +1,41 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`react`),n=require(`@intlayer/core/formatters`);const r=()=>{let{locale:r}=(0,t.useContext)(e.IntlayerClientContext);return(0,t.useCallback)((...e)=>(0,n.list)(e[0],{...e[1],locale:e[1]?.locale??r}),[r])};exports.useList=r;
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let react = require("react");
7
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
8
+
9
+ //#region src/client/format/useList.ts
10
+ /**
11
+ * React client hook that provides a list formatter
12
+ * bound to the current application locale.
13
+ *
14
+ * @returns {(values: (string | number)[], options?: ListProps) => string}
15
+ * A function to format arrays into localized list strings.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const formatList = useList();
20
+ *
21
+ * formatList(['apple', 'banana', 'orange']);
22
+ * // "apple, banana, and orange"
23
+ *
24
+ * formatList(['red', 'green', 'blue'], { type: 'disjunction' });
25
+ * // "red, green, or blue"
26
+ *
27
+ * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });
28
+ * // "1, 2 und 3"
29
+ * ```
30
+ */
31
+ const useList = () => {
32
+ const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
33
+ return (0, react.useCallback)((...args) => (0, _intlayer_core_formatters.list)(args[0], {
34
+ ...args[1],
35
+ locale: args[1]?.locale ?? locale
36
+ }), [locale]);
37
+ };
38
+
39
+ //#endregion
40
+ exports.useList = useList;
2
41
  //# sourceMappingURL=useList.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useList.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"yOA2BA,MAAa,MAAgB,CAC3B,GAAM,CAAE,WAAA,EAAA,EAAA,YAAsBA,EAAAA,sBAAsB,CAEpD,OAAA,EAAA,EAAA,cACG,GAAG,KAAA,EAAA,EAAA,MACG,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC,CACJ,CAAC,EAAO,CACT"}
1
+ {"version":3,"file":"useList.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,iCAAsBA,sDAAsB;AAEpD,gCACG,GAAG,6CACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}