preact-intlayer 6.1.6 → 7.0.0-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/dist/cjs/IntlayerNode.cjs +15 -45
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +98 -130
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  6. package/dist/cjs/client/IntlayerProvider.cjs +67 -95
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +17 -50
  9. package/dist/cjs/client/format/useCompact.cjs +29 -39
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +43 -39
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +45 -36
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useList.cjs +40 -39
  16. package/dist/cjs/client/format/useList.cjs.map +1 -1
  17. package/dist/cjs/client/format/useNumber.cjs +41 -39
  18. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  19. package/dist/cjs/client/format/usePercentage.cjs +37 -39
  20. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  21. package/dist/cjs/client/format/useRelativeTime.cjs +37 -39
  22. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  23. package/dist/cjs/client/format/useUnit.cjs +36 -39
  24. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  25. package/dist/cjs/client/index.cjs +29 -69
  26. package/dist/cjs/client/t.cjs +21 -34
  27. package/dist/cjs/client/t.cjs.map +1 -1
  28. package/dist/cjs/client/useContent.cjs +16 -36
  29. package/dist/cjs/client/useContent.cjs.map +1 -1
  30. package/dist/cjs/client/useDictionary.cjs +26 -36
  31. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionaryAsync.cjs +23 -52
  33. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  34. package/dist/cjs/client/useDictionaryDynamic.cjs +22 -42
  35. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  36. package/dist/cjs/client/useIntlayer.cjs +26 -36
  37. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  38. package/dist/cjs/client/useLoadDynamic.cjs +21 -50
  39. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  40. package/dist/cjs/client/useLocale.cjs +36 -67
  41. package/dist/cjs/client/useLocale.cjs.map +1 -1
  42. package/dist/cjs/client/useLocaleBase.cjs +25 -53
  43. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleStorage.cjs +60 -0
  45. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
  46. package/dist/cjs/client/useTraduction.cjs +34 -35
  47. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  48. package/dist/cjs/editor/CommunicatorContext.cjs +40 -62
  49. package/dist/cjs/editor/CommunicatorContext.cjs.map +1 -1
  50. package/dist/cjs/editor/ConfigurationContext.cjs +26 -47
  51. package/dist/cjs/editor/ConfigurationContext.cjs.map +1 -1
  52. package/dist/cjs/editor/ContentSelectorWrapper.cjs +58 -94
  53. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  54. package/dist/cjs/editor/DictionariesRecordContext.cjs +47 -73
  55. package/dist/cjs/editor/DictionariesRecordContext.cjs.map +1 -1
  56. package/dist/cjs/editor/EditedContentContext.cjs +160 -211
  57. package/dist/cjs/editor/EditedContentContext.cjs.map +1 -1
  58. package/dist/cjs/editor/EditorEnabledContext.cjs +34 -59
  59. package/dist/cjs/editor/EditorEnabledContext.cjs.map +1 -1
  60. package/dist/cjs/editor/EditorProvider.cjs +62 -66
  61. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  62. package/dist/cjs/editor/FocusDictionaryContext.cjs +51 -75
  63. package/dist/cjs/editor/FocusDictionaryContext.cjs.map +1 -1
  64. package/dist/cjs/editor/IntlayerEditorProvider.cjs +45 -94
  65. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  66. package/dist/cjs/editor/index.cjs +3 -23
  67. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +73 -50
  68. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  69. package/dist/cjs/editor/useCrossFrameState.cjs +106 -73
  70. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  71. package/dist/cjs/editor/useCrossURLPathState.cjs +67 -66
  72. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  73. package/dist/cjs/editor/useEditedContentRenderer.cjs +27 -59
  74. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  75. package/dist/cjs/editor/useIframeClickInterceptor.cjs +24 -47
  76. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  77. package/dist/cjs/getDictionary.cjs +15 -40
  78. package/dist/cjs/getDictionary.cjs.map +1 -1
  79. package/dist/cjs/getIntlayer.cjs +15 -36
  80. package/dist/cjs/getIntlayer.cjs.map +1 -1
  81. package/dist/cjs/index.cjs +30 -62
  82. package/dist/cjs/markdown/MarkdownProvider.cjs +19 -39
  83. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  84. package/dist/cjs/markdown/MarkdownRenderer.cjs +39 -80
  85. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  86. package/dist/cjs/markdown/index.cjs +7 -25
  87. package/dist/cjs/plugins.cjs +97 -119
  88. package/dist/cjs/plugins.cjs.map +1 -1
  89. package/dist/cjs/preactElement/renderPreactElement.cjs +34 -59
  90. package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
  91. package/dist/esm/IntlayerNode.mjs +13 -25
  92. package/dist/esm/IntlayerNode.mjs.map +1 -1
  93. package/dist/esm/UI/ContentSelector.mjs +94 -105
  94. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  95. package/dist/esm/client/IntlayerProvider.mjs +51 -54
  96. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  97. package/dist/esm/client/format/index.mjs +2 -11
  98. package/dist/esm/client/format/useCompact.mjs +24 -13
  99. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  100. package/dist/esm/client/format/useCurrency.mjs +38 -13
  101. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  102. package/dist/esm/client/format/useDate.mjs +40 -10
  103. package/dist/esm/client/format/useDate.mjs.map +1 -1
  104. package/dist/esm/client/format/useList.mjs +35 -13
  105. package/dist/esm/client/format/useList.mjs.map +1 -1
  106. package/dist/esm/client/format/useNumber.mjs +36 -13
  107. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  108. package/dist/esm/client/format/usePercentage.mjs +32 -13
  109. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  110. package/dist/esm/client/format/useRelativeTime.mjs +32 -13
  111. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  112. package/dist/esm/client/format/useUnit.mjs +31 -13
  113. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  114. package/dist/esm/client/index.mjs +5 -32
  115. package/dist/esm/client/t.mjs +16 -8
  116. package/dist/esm/client/t.mjs.map +1 -1
  117. package/dist/esm/client/useContent.mjs +14 -10
  118. package/dist/esm/client/useContent.mjs.map +1 -1
  119. package/dist/esm/client/useDictionary.mjs +23 -11
  120. package/dist/esm/client/useDictionary.mjs.map +1 -1
  121. package/dist/esm/client/useDictionaryAsync.mjs +18 -16
  122. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  123. package/dist/esm/client/useDictionaryDynamic.mjs +17 -15
  124. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  125. package/dist/esm/client/useIntlayer.mjs +23 -11
  126. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  127. package/dist/esm/client/useLoadDynamic.mjs +20 -26
  128. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  129. package/dist/esm/client/useLocale.mjs +31 -31
  130. package/dist/esm/client/useLocale.mjs.map +1 -1
  131. package/dist/esm/client/useLocaleBase.mjs +19 -16
  132. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  133. package/dist/esm/client/useLocaleStorage.mjs +52 -0
  134. package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  135. package/dist/esm/client/useTraduction.mjs +29 -9
  136. package/dist/esm/client/useTraduction.mjs.map +1 -1
  137. package/dist/esm/editor/CommunicatorContext.mjs +28 -24
  138. package/dist/esm/editor/CommunicatorContext.mjs.map +1 -1
  139. package/dist/esm/editor/ConfigurationContext.mjs +20 -24
  140. package/dist/esm/editor/ConfigurationContext.mjs.map +1 -1
  141. package/dist/esm/editor/ContentSelectorWrapper.mjs +50 -70
  142. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  143. package/dist/esm/editor/DictionariesRecordContext.mjs +37 -47
  144. package/dist/esm/editor/DictionariesRecordContext.mjs.map +1 -1
  145. package/dist/esm/editor/EditedContentContext.mjs +146 -187
  146. package/dist/esm/editor/EditedContentContext.mjs.map +1 -1
  147. package/dist/esm/editor/EditorEnabledContext.mjs +23 -33
  148. package/dist/esm/editor/EditorEnabledContext.mjs.map +1 -1
  149. package/dist/esm/editor/EditorProvider.mjs +57 -54
  150. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  151. package/dist/esm/editor/FocusDictionaryContext.mjs +42 -49
  152. package/dist/esm/editor/FocusDictionaryContext.mjs.map +1 -1
  153. package/dist/esm/editor/IntlayerEditorProvider.mjs +37 -55
  154. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  155. package/dist/esm/editor/index.mjs +3 -2
  156. package/dist/esm/editor/useCrossFrameMessageListener.mjs +68 -24
  157. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  158. package/dist/esm/editor/useCrossFrameState.mjs +102 -47
  159. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  160. package/dist/esm/editor/useCrossURLPathState.mjs +60 -40
  161. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  162. package/dist/esm/editor/useEditedContentRenderer.mjs +23 -33
  163. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  164. package/dist/esm/editor/useIframeClickInterceptor.mjs +18 -20
  165. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  166. package/dist/esm/getDictionary.mjs +13 -22
  167. package/dist/esm/getDictionary.mjs.map +1 -1
  168. package/dist/esm/getIntlayer.mjs +13 -18
  169. package/dist/esm/getIntlayer.mjs.map +1 -1
  170. package/dist/esm/index.mjs +13 -39
  171. package/dist/esm/markdown/MarkdownProvider.mjs +14 -16
  172. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  173. package/dist/esm/markdown/MarkdownRenderer.mjs +34 -57
  174. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  175. package/dist/esm/markdown/index.mjs +4 -3
  176. package/dist/esm/plugins.mjs +86 -92
  177. package/dist/esm/plugins.mjs.map +1 -1
  178. package/dist/esm/preactElement/renderPreactElement.mjs +31 -34
  179. package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
  180. package/dist/types/IntlayerNode.d.ts +19 -12
  181. package/dist/types/IntlayerNode.d.ts.map +1 -1
  182. package/dist/types/UI/ContentSelector.d.ts +12 -9
  183. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  184. package/dist/types/client/IntlayerProvider.d.ts +22 -16
  185. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  186. package/dist/types/client/format/index.d.ts +9 -9
  187. package/dist/types/client/format/useCompact.d.ts +8 -2
  188. package/dist/types/client/format/useCompact.d.ts.map +1 -1
  189. package/dist/types/client/format/useCurrency.d.ts +8 -2
  190. package/dist/types/client/format/useCurrency.d.ts.map +1 -1
  191. package/dist/types/client/format/useDate.d.ts +7 -2
  192. package/dist/types/client/format/useDate.d.ts.map +1 -1
  193. package/dist/types/client/format/useList.d.ts +8 -2
  194. package/dist/types/client/format/useList.d.ts.map +1 -1
  195. package/dist/types/client/format/useNumber.d.ts +8 -2
  196. package/dist/types/client/format/useNumber.d.ts.map +1 -1
  197. package/dist/types/client/format/usePercentage.d.ts +8 -2
  198. package/dist/types/client/format/usePercentage.d.ts.map +1 -1
  199. package/dist/types/client/format/useRelativeTime.d.ts +9 -3
  200. package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
  201. package/dist/types/client/format/useUnit.d.ts +8 -2
  202. package/dist/types/client/format/useUnit.d.ts.map +1 -1
  203. package/dist/types/client/index.d.ts +11 -12
  204. package/dist/types/client/t.d.ts +7 -3
  205. package/dist/types/client/t.d.ts.map +1 -1
  206. package/dist/types/client/useContent.d.ts +10 -5
  207. package/dist/types/client/useContent.d.ts.map +1 -1
  208. package/dist/types/client/useDictionary.d.ts +9 -3
  209. package/dist/types/client/useDictionary.d.ts.map +1 -1
  210. package/dist/types/client/useDictionaryAsync.d.ts +7 -3
  211. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  212. package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
  213. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  214. package/dist/types/client/useIntlayer.d.ts +8 -5
  215. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  216. package/dist/types/client/useLoadDynamic.d.ts +4 -1
  217. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  218. package/dist/types/client/useLocale.d.ts +16 -8
  219. package/dist/types/client/useLocale.d.ts.map +1 -1
  220. package/dist/types/client/useLocaleBase.d.ts +10 -5
  221. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  222. package/dist/types/client/useLocaleStorage.d.ts +45 -0
  223. package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
  224. package/dist/types/client/useTraduction.d.ts +7 -2
  225. package/dist/types/client/useTraduction.d.ts.map +1 -1
  226. package/dist/types/editor/CommunicatorContext.d.ts +15 -11
  227. package/dist/types/editor/CommunicatorContext.d.ts.map +1 -1
  228. package/dist/types/editor/ConfigurationContext.d.ts +12 -7
  229. package/dist/types/editor/ConfigurationContext.d.ts.map +1 -1
  230. package/dist/types/editor/ContentSelectorWrapper.d.ts +8 -4
  231. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  232. package/dist/types/editor/DictionariesRecordContext.d.ts +15 -12
  233. package/dist/types/editor/DictionariesRecordContext.d.ts.map +1 -1
  234. package/dist/types/editor/EditedContentContext.d.ts +32 -29
  235. package/dist/types/editor/EditedContentContext.d.ts.map +1 -1
  236. package/dist/types/editor/EditorEnabledContext.d.ts +14 -9
  237. package/dist/types/editor/EditorEnabledContext.d.ts.map +1 -1
  238. package/dist/types/editor/EditorProvider.d.ts +9 -5
  239. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  240. package/dist/types/editor/FocusDictionaryContext.d.ts +18 -15
  241. package/dist/types/editor/FocusDictionaryContext.d.ts.map +1 -1
  242. package/dist/types/editor/IntlayerEditorProvider.d.ts +7 -3
  243. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  244. package/dist/types/editor/index.d.ts +2 -2
  245. package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
  246. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
  247. package/dist/types/editor/useCrossFrameState.d.ts +11 -7
  248. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
  249. package/dist/types/editor/useCrossURLPathState.d.ts +8 -3
  250. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
  251. package/dist/types/editor/useEditedContentRenderer.d.ts +16 -10
  252. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
  253. package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
  254. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
  255. package/dist/types/getDictionary.d.ts +8 -4
  256. package/dist/types/getDictionary.d.ts.map +1 -1
  257. package/dist/types/getIntlayer.d.ts +8 -4
  258. package/dist/types/getIntlayer.d.ts.map +1 -1
  259. package/dist/types/index.d.ts +18 -6
  260. package/dist/types/index.d.ts.map +1 -1
  261. package/dist/types/markdown/MarkdownProvider.d.ts +8 -5
  262. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
  263. package/dist/types/markdown/MarkdownRenderer.d.ts +13 -11
  264. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  265. package/dist/types/markdown/index.d.ts +3 -3
  266. package/dist/types/plugins.d.ts +33 -27
  267. package/dist/types/plugins.d.ts.map +1 -1
  268. package/dist/types/preactElement/renderPreactElement.d.ts +7 -3
  269. package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
  270. package/package.json +40 -46
  271. package/LICENSE +0 -202
  272. package/dist/cjs/client/format/index.cjs.map +0 -1
  273. package/dist/cjs/client/getBrowserLocale.cjs +0 -173
  274. package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
  275. package/dist/cjs/client/index.cjs.map +0 -1
  276. package/dist/cjs/client/useLocaleCookie.cjs +0 -60
  277. package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
  278. package/dist/cjs/editor/index.cjs.map +0 -1
  279. package/dist/cjs/index.cjs.map +0 -1
  280. package/dist/cjs/markdown/index.cjs.map +0 -1
  281. package/dist/esm/client/format/index.mjs.map +0 -1
  282. package/dist/esm/client/getBrowserLocale.mjs +0 -138
  283. package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
  284. package/dist/esm/client/index.mjs.map +0 -1
  285. package/dist/esm/client/useLocaleCookie.mjs +0 -24
  286. package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
  287. package/dist/esm/editor/index.mjs.map +0 -1
  288. package/dist/esm/index.mjs.map +0 -1
  289. package/dist/esm/markdown/index.mjs.map +0 -1
  290. package/dist/types/client/format/index.d.ts.map +0 -1
  291. package/dist/types/client/getBrowserLocale.d.ts +0 -25
  292. package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
  293. package/dist/types/client/index.d.ts.map +0 -1
  294. package/dist/types/client/useLocaleCookie.d.ts +0 -17
  295. package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
  296. package/dist/types/editor/index.d.ts.map +0 -1
  297. package/dist/types/markdown/index.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA2B;AAC3B,mBAAwC;AACxC,8BAAsC;AAoB/B,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,wBAAW,KAAK,CAAC,GAAG;AAAA,MAClB,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"file":"usePercentage.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,yCACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,42 +1,40 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var useRelativeTime_exports = {};
21
- __export(useRelativeTime_exports, {
22
- useRelativeTime: () => useRelativeTime
23
- });
24
- module.exports = __toCommonJS(useRelativeTime_exports);
25
- var import_core = require("@intlayer/core");
26
- var import_hooks = require("preact/hooks");
27
- var import_IntlayerProvider = require('../IntlayerProvider.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let __intlayer_core = require("@intlayer/core");
7
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
8
+ let preact_hooks = require("preact/hooks");
9
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
10
+
11
+ //#region src/client/format/useRelativeTime.ts
12
+ /**
13
+ * Client-side React hook for accessing a localized relative time formatter.
14
+ *
15
+ * This hook:
16
+ * - Reads the current locale from {@link useLocaleBase}.
17
+ * - Creates a new relative time formatter with {@link createRelativeTime}.
18
+ * - Returns a function that can format time differences into localized strings.
19
+ *
20
+ * Example:
21
+ * ```tsx
22
+ * const relativeTime = useRelativeTime();
23
+ * const formatted = relativeTime(new Date("2024-08-01"), new Date());
24
+ * // e.g., "2 weeks ago"
25
+ * ```
26
+ *
27
+ * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
28
+ * bound to the current client locale.
29
+ */
28
30
  const useRelativeTime = () => {
29
- const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
- return (0, import_hooks.useCallback)(
31
- (...args) => (0, import_core.relativeTime)(args[0], args[1], {
32
- ...args[2],
33
- locale: args[2]?.locale ?? locale
34
- }),
35
- [locale]
36
- );
31
+ const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
32
+ return (0, preact_hooks.useCallback)((...args) => (0, __intlayer_core.relativeTime)(args[0], args[1], {
33
+ ...args[2],
34
+ locale: args[2]?.locale ?? locale
35
+ }), [locale]);
37
36
  };
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- useRelativeTime
41
- });
37
+
38
+ //#endregion
39
+ exports.useRelativeTime = useRelativeTime;
42
40
  //# sourceMappingURL=useRelativeTime.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA6B;AAC7B,mBAAwC;AACxC,8BAAsC;AAoB/B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,0BAAa,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG;AAAA,MAC7B,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"file":"useRelativeTime.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,2CACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,42 +1,39 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var useUnit_exports = {};
21
- __export(useUnit_exports, {
22
- useUnit: () => useUnit
23
- });
24
- module.exports = __toCommonJS(useUnit_exports);
25
- var import_core = require("@intlayer/core");
26
- var import_hooks = require("preact/hooks");
27
- var import_IntlayerProvider = require('../IntlayerProvider.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
6
+ let __intlayer_core = require("@intlayer/core");
7
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
8
+ let preact_hooks = require("preact/hooks");
9
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
10
+
11
+ //#region src/client/format/useUnit.ts
12
+ /**
13
+ * React hook that provides a unit formatting function
14
+ * based on the current locale from {@link useLocaleBase}.
15
+ *
16
+ * This hook wraps {@link createUnit} to return a formatter
17
+ * that can convert values into human-readable localized units
18
+ * (e.g., "10 km", "5 lbs").
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const formatUnit = useUnit();
23
+ * const distance = formatUnit(10, { unit: "kilometer" });
24
+ * // "10 km" (depending on locale)
25
+ * ```
26
+ *
27
+ * @returns {Function} A unit formatting function that accepts a value and optional formatting options.
28
+ */
28
29
  const useUnit = () => {
29
- const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
- return (0, import_hooks.useCallback)(
31
- (...args) => (0, import_core.units)(args[0], {
32
- ...args[1],
33
- locale: args[1]?.locale ?? locale
34
- }),
35
- [locale]
36
- );
30
+ const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
31
+ return (0, preact_hooks.useCallback)((...args) => (0, __intlayer_core.units)(args[0], {
32
+ ...args[1],
33
+ locale: args[1]?.locale ?? locale
34
+ }), [locale]);
37
35
  };
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- useUnit
41
- });
36
+
37
+ //#endregion
38
+ exports.useUnit = useUnit;
42
39
  //# sourceMappingURL=useUnit.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAsB;AACtB,mBAAwC;AACxC,8BAAsC;AAmB/B,MAAM,UAAU,MAAM;AAC3B,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,IAAI,aACF,mBAAM,KAAK,CAAC,GAAG;AAAA,MACb,GAAG,KAAK,CAAC;AAAA,MACT,QAAQ,KAAK,CAAC,GAAG,UAAU;AAAA,IAC7B,CAAC;AAAA,IACH,CAAC,MAAM;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"file":"useUnit.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,oCACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
@@ -1,69 +1,29 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var client_exports = {};
20
- __export(client_exports, {
21
- IntlayerClientContext: () => import_IntlayerProvider.IntlayerClientContext,
22
- IntlayerProvider: () => import_IntlayerProvider.IntlayerProvider,
23
- IntlayerProviderContent: () => import_IntlayerProvider.IntlayerProviderContent,
24
- getBrowserLocale: () => import_getBrowserLocale.getBrowserLocale,
25
- localeCookie: () => import_useLocaleCookie.localeCookie,
26
- setLocaleCookie: () => import_useLocaleCookie.setLocaleCookie,
27
- t: () => import_t.t,
28
- useDictionary: () => import_useDictionary.useDictionary,
29
- useDictionaryAsync: () => import_useDictionaryAsync.useDictionaryAsync,
30
- useDictionaryDynamic: () => import_useDictionaryDynamic.useDictionaryDynamic,
31
- useIntlayer: () => import_useIntlayer.useIntlayer,
32
- useIntlayerContext: () => import_IntlayerProvider.useIntlayerContext,
33
- useLoadDynamic: () => import_useLoadDynamic.useLoadDynamic,
34
- useLocale: () => import_useLocale.useLocale,
35
- useLocaleBase: () => import_useLocaleBase.useLocaleBase,
36
- useLocaleCookie: () => import_useLocaleCookie.useLocaleCookie
37
- });
38
- module.exports = __toCommonJS(client_exports);
39
- var import_getBrowserLocale = require('./getBrowserLocale.cjs');
40
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
41
- var import_t = require('./t.cjs');
42
- var import_useDictionary = require('./useDictionary.cjs');
43
- var import_useDictionaryAsync = require('./useDictionaryAsync.cjs');
44
- var import_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
45
- var import_useIntlayer = require('./useIntlayer.cjs');
46
- var import_useLoadDynamic = require('./useLoadDynamic.cjs');
47
- var import_useLocale = require('./useLocale.cjs');
48
- var import_useLocaleBase = require('./useLocaleBase.cjs');
49
- var import_useLocaleCookie = require('./useLocaleCookie.cjs');
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- IntlayerClientContext,
53
- IntlayerProvider,
54
- IntlayerProviderContent,
55
- getBrowserLocale,
56
- localeCookie,
57
- setLocaleCookie,
58
- t,
59
- useDictionary,
60
- useDictionaryAsync,
61
- useDictionaryDynamic,
62
- useIntlayer,
63
- useIntlayerContext,
64
- useLoadDynamic,
65
- useLocale,
66
- useLocaleBase,
67
- useLocaleCookie
68
- });
69
- //# sourceMappingURL=index.cjs.map
1
+ const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
2
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
3
+ const require_client_t = require('./t.cjs');
4
+ const require_client_useDictionary = require('./useDictionary.cjs');
5
+ const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
6
+ const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
7
+ const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
8
+ const require_client_useIntlayer = require('./useIntlayer.cjs');
9
+ const require_client_useLocale = require('./useLocale.cjs');
10
+ const require_client_useLocaleBase = require('./useLocaleBase.cjs');
11
+
12
+ exports.IntlayerClientContext = require_client_IntlayerProvider.IntlayerClientContext;
13
+ exports.IntlayerProvider = require_client_IntlayerProvider.IntlayerProvider;
14
+ exports.IntlayerProviderContent = require_client_IntlayerProvider.IntlayerProviderContent;
15
+ exports.localeCookie = require_client_useLocaleStorage.localeCookie;
16
+ exports.localeInStorage = require_client_useLocaleStorage.localeInStorage;
17
+ exports.setLocaleCookie = require_client_useLocaleStorage.setLocaleCookie;
18
+ exports.setLocaleInStorage = require_client_useLocaleStorage.setLocaleInStorage;
19
+ exports.t = require_client_t.t;
20
+ exports.useDictionary = require_client_useDictionary.useDictionary;
21
+ exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
22
+ exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
23
+ exports.useIntlayer = require_client_useIntlayer.useIntlayer;
24
+ exports.useIntlayerContext = require_client_IntlayerProvider.useIntlayerContext;
25
+ exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
26
+ exports.useLocale = require_client_useLocale.useLocale;
27
+ exports.useLocaleBase = require_client_useLocaleBase.useLocaleBase;
28
+ exports.useLocaleCookie = require_client_useLocaleStorage.useLocaleCookie;
29
+ exports.useLocaleStorage = require_client_useLocaleStorage.useLocaleStorage;
@@ -1,37 +1,24 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var t_exports = {};
21
- __export(t_exports, {
22
- t: () => t
23
- });
24
- module.exports = __toCommonJS(t_exports);
25
- var import_core = require("@intlayer/core");
26
- var import_hooks = require("preact/hooks");
27
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
+ let __intlayer_core = require("@intlayer/core");
7
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
8
+ let preact_hooks = require("preact/hooks");
9
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
10
+
11
+ //#region src/client/t.ts
12
+ /**
13
+ * On the client side, this function returns the translation of the provided multilang content.
14
+ *
15
+ * If the locale is not provided, it will use the locale from the client context
16
+ */
28
17
  const t = (multilangContent, locale) => {
29
- const { locale: currentLocale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
- const localeTarget = locale ?? currentLocale;
31
- return (0, import_core.getTranslation)(multilangContent, localeTarget);
18
+ const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
19
+ return (0, __intlayer_core.getTranslation)(multilangContent, locale ?? currentLocale);
32
20
  };
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- t
36
- });
21
+
22
+ //#endregion
23
+ exports.t = t;
37
24
  //# sourceMappingURL=t.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslation } from '@intlayer/core';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAqD;AACrD,mBAA2B;AAC3B,8BAAsC;AAO/B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,aAAO,4BAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
1
+ {"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core';\nimport type { Locale, StrictModeLocaleMap } from '@intlayer/types';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAYA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;AAGnE,4CAA+B,kBAFV,UAAU,cAE+B"}
@@ -1,39 +1,19 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useContent_exports = {};
20
- __export(useContent_exports, {
21
- useContent: () => useContent
22
- });
23
- module.exports = __toCommonJS(useContent_exports);
24
- var import_useLocaleBase = require('./useLocaleBase.cjs');
25
- var import_useTraduction = require('./useTraduction.cjs');
1
+ const require_client_useLocaleBase = require('./useLocaleBase.cjs');
2
+ const require_client_useTraduction = require('./useTraduction.cjs');
3
+
4
+ //#region src/client/useContent.ts
5
+ /**
6
+ * On the client side, hook to get the translation content based on the locale
7
+ */
26
8
  const useContent = (languageContent) => {
27
- const { locale } = (0, import_useLocaleBase.useLocaleBase)();
28
- const content = (0, import_useTraduction.useTranslation)(languageContent);
29
- return {
30
- locale,
31
- content,
32
- t: import_useTraduction.useTranslation
33
- };
9
+ const { locale } = require_client_useLocaleBase.useLocaleBase();
10
+ return {
11
+ locale,
12
+ content: require_client_useTraduction.useTranslation(languageContent),
13
+ t: require_client_useTraduction.useTranslation
14
+ };
34
15
  };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- useContent
38
- });
16
+
17
+ //#endregion
18
+ exports.useContent = useContent;
39
19
  //# sourceMappingURL=useContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAA8B;AAC9B,2BAA+B;AAKxB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,QAAI,oCAAc;AAEjC,QAAM,cAAU,qCAAe,eAAe;AAE9C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
1
+ {"version":3,"file":"useContent.cjs","names":["useLocaleBase","useTranslation"],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAWA,4CAAe;AAIlC,QAAO;EACL;EACA,SAJcC,4CAAe,gBAAgB;EAK7C,GAAGA;EACJ"}
@@ -1,39 +1,29 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var useDictionary_exports = {};
21
- __export(useDictionary_exports, {
22
- useDictionary: () => useDictionary
23
- });
24
- module.exports = __toCommonJS(useDictionary_exports);
25
- var import_hooks = require("preact/hooks");
26
- var import_getDictionary = require('../getDictionary.cjs');
27
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
+ const require_getDictionary = require('../getDictionary.cjs');
7
+ let preact_hooks = require("preact/hooks");
8
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
9
+
10
+ //#region src/client/useDictionary.ts
11
+ /**
12
+ * On the server side, Hook that transform a dictionary and return the content
13
+ *
14
+ * If the locale is not provided, it will use the locale from the client context
15
+ */
28
16
  const useDictionary = (dictionary, locale) => {
29
- const { locale: currentLocale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
- return (0, import_hooks.useMemo)(() => {
31
- const localeTarget = locale ?? currentLocale;
32
- return (0, import_getDictionary.getDictionary)(dictionary, localeTarget);
33
- }, [dictionary, currentLocale, locale]);
17
+ const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
18
+ return (0, preact_hooks.useMemo)(() => {
19
+ return require_getDictionary.getDictionary(dictionary, locale ?? currentLocale);
20
+ }, [
21
+ dictionary,
22
+ currentLocale,
23
+ locale
24
+ ]);
34
25
  };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- useDictionary
38
- });
26
+
27
+ //#endregion
28
+ exports.useDictionary = useDictionary;
39
29
  //# sourceMappingURL=useDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n }, [dictionary, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAoC;AACpC,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAElE,aAAO,sBAAQ,MAAM;AACnB,UAAM,eAAe,UAAU;AAE/B,eAAO,oCAAgC,YAAY,YAAY;AAAA,EACjE,GAAG,CAAC,YAAY,eAAe,MAAM,CAAC;AACxC;","names":[]}
1
+ {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;AAEnE,wCAAqB;AAGnB,SAAOC,oCAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC;EAAY;EAAe;EAAO,CAAC"}
@@ -1,55 +1,26 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var useDictionaryAsync_exports = {};
31
- __export(useDictionaryAsync_exports, {
32
- useDictionaryAsync: () => useDictionaryAsync
33
- });
34
- module.exports = __toCommonJS(useDictionaryAsync_exports);
35
- var import_built = __toESM(require("@intlayer/config/built"));
36
- var import_hooks = require("preact/hooks");
37
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
38
- var import_useDictionary = require('./useDictionary.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
+ const require_client_useDictionary = require('./useDictionary.cjs');
7
+ let __intlayer_config_built = require("@intlayer/config/built");
8
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
9
+ let preact_hooks = require("preact/hooks");
10
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
11
+
12
+ //#region src/client/useDictionaryAsync.ts
13
+ /**
14
+ * On the server side, Hook that transform a dictionary and return the content
15
+ *
16
+ * If the locale is not provided, it will use the locale from the client context
17
+ */
39
18
  const useDictionaryAsync = async (dictionaryPromise, locale) => {
40
- const { locale: currentLocale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
41
- const localeTarget = (0, import_hooks.useMemo)(
42
- () => locale ?? currentLocale ?? import_built.default?.internationalization.defaultLocale,
43
- [currentLocale, locale]
44
- );
45
- const dictionary = await (0, import_hooks.useMemo)(
46
- async () => await dictionaryPromise[localeTarget](),
47
- [dictionaryPromise, localeTarget]
48
- );
49
- return (0, import_useDictionary.useDictionary)(dictionary, localeTarget);
19
+ const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
20
+ const localeTarget = (0, preact_hooks.useMemo)(() => locale ?? currentLocale ?? __intlayer_config_built.default?.internationalization.defaultLocale, [currentLocale, locale]);
21
+ return require_client_useDictionary.useDictionary(await (0, preact_hooks.useMemo)(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
50
22
  };
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- useDictionaryAsync
54
- });
23
+
24
+ //#endregion
25
+ exports.useDictionaryAsync = useDictionaryAsync;
55
26
  //# sourceMappingURL=useDictionaryAsync.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary, LanguageContent } from '@intlayer/core';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]!()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAG1B,mBAAoC;AACpC,8BAAsC;AACtC,2BAA8B;AAOvB,MAAM,qBAAqB,OAChC,mBACA,WACe;AACf,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAElE,QAAM,mBAAe;AAAA,IACnB,MACE,UACA,iBACA,aAAAA,SAAe,qBAAqB;AAAA,IACtC,CAAC,eAAe,MAAM;AAAA,EACxB;AAEA,QAAM,aAAa,UAAM;AAAA,IACvB,YACG,MAAM,kBACL,YACF,EAAG;AAAA,IACL,CAAC,mBAAmB,YAAY;AAAA,EAClC;AAEA,aAAO,oCAAc,YAAY,YAAY;AAC/C;","names":["configuration"]}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;CAEnE,MAAM,+CAEF,UACA,iBACAC,iCAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CARY,gCACjB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}