preact-intlayer 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/cjs/IntlayerNode.cjs +1 -16
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +1 -98
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  6. package/dist/cjs/client/IntlayerProvider.cjs +1 -91
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +1 -18
  9. package/dist/cjs/client/format/useCompact.cjs +1 -29
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +1 -43
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +1 -45
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useIntl.cjs +1 -33
  16. package/dist/cjs/client/format/useIntl.cjs.map +1 -1
  17. package/dist/cjs/client/format/useList.cjs +1 -40
  18. package/dist/cjs/client/format/useList.cjs.map +1 -1
  19. package/dist/cjs/client/format/useNumber.cjs +1 -41
  20. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  21. package/dist/cjs/client/format/usePercentage.cjs +1 -37
  22. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  23. package/dist/cjs/client/format/useRelativeTime.cjs +1 -37
  24. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  25. package/dist/cjs/client/format/useUnit.cjs +1 -36
  26. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  27. package/dist/cjs/client/index.cjs +1 -32
  28. package/dist/cjs/client/t.cjs +1 -21
  29. package/dist/cjs/client/t.cjs.map +1 -1
  30. package/dist/cjs/client/useContent.cjs +1 -19
  31. package/dist/cjs/client/useContent.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionary.cjs +1 -27
  33. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  34. package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
  35. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  36. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -23
  37. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  38. package/dist/cjs/client/useIntlayer.cjs +1 -42
  39. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  40. package/dist/cjs/client/useLoadDynamic.cjs +1 -27
  41. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  42. package/dist/cjs/client/useLocale.cjs +1 -56
  43. package/dist/cjs/client/useLocale.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleBase.cjs +1 -26
  45. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  46. package/dist/cjs/client/useLocaleStorage.cjs +1 -58
  47. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  48. package/dist/cjs/client/useTraduction.cjs +1 -35
  49. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  50. package/dist/cjs/editor/CommunicatorContext.cjs +1 -39
  51. package/dist/cjs/editor/CommunicatorContext.cjs.map +1 -1
  52. package/dist/cjs/editor/ConfigurationContext.cjs +1 -26
  53. package/dist/cjs/editor/ConfigurationContext.cjs.map +1 -1
  54. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -58
  55. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  56. package/dist/cjs/editor/DictionariesRecordContext.cjs +1 -48
  57. package/dist/cjs/editor/DictionariesRecordContext.cjs.map +1 -1
  58. package/dist/cjs/editor/EditedContentContext.cjs +1 -163
  59. package/dist/cjs/editor/EditedContentContext.cjs.map +1 -1
  60. package/dist/cjs/editor/EditorEnabledContext.cjs +1 -34
  61. package/dist/cjs/editor/EditorEnabledContext.cjs.map +1 -1
  62. package/dist/cjs/editor/EditorProvider.cjs +1 -64
  63. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  64. package/dist/cjs/editor/FocusDictionaryContext.cjs +1 -54
  65. package/dist/cjs/editor/FocusDictionaryContext.cjs.map +1 -1
  66. package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -63
  67. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  68. package/dist/cjs/editor/index.cjs +1 -4
  69. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -78
  70. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  71. package/dist/cjs/editor/useCrossFrameState.cjs +1 -108
  72. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  73. package/dist/cjs/editor/useCrossURLPathState.cjs +1 -67
  74. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  75. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -29
  76. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  77. package/dist/cjs/editor/useIframeClickInterceptor.cjs +1 -24
  78. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  79. package/dist/cjs/getDictionary.cjs +1 -19
  80. package/dist/cjs/getDictionary.cjs.map +1 -1
  81. package/dist/cjs/getIntlayer.cjs +1 -19
  82. package/dist/cjs/getIntlayer.cjs.map +1 -1
  83. package/dist/cjs/html/HTMLProvider.cjs +1 -19
  84. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  85. package/dist/cjs/html/HTMLRenderer.cjs +1 -61
  86. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  87. package/dist/cjs/html/index.cjs +1 -10
  88. package/dist/cjs/index.cjs +1 -57
  89. package/dist/cjs/markdown/MarkdownProvider.cjs +1 -49
  90. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  91. package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -77
  92. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  93. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -31
  94. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  95. package/dist/cjs/markdown/compiler.cjs +1 -24
  96. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  97. package/dist/cjs/markdown/index.cjs +1 -23
  98. package/dist/cjs/markdown/runtime.cjs +1 -18
  99. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  100. package/dist/cjs/plugins.cjs +1 -197
  101. package/dist/cjs/plugins.cjs.map +1 -1
  102. package/dist/cjs/preactElement/renderPreactElement.cjs +1 -42
  103. package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
  104. package/dist/esm/IntlayerNode.mjs +1 -14
  105. package/dist/esm/IntlayerNode.mjs.map +1 -1
  106. package/dist/esm/UI/ContentSelector.mjs +1 -96
  107. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  108. package/dist/esm/client/IntlayerProvider.mjs +1 -85
  109. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  110. package/dist/esm/client/format/index.mjs +1 -10
  111. package/dist/esm/client/format/useCompact.mjs +1 -27
  112. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  113. package/dist/esm/client/format/useCurrency.mjs +1 -41
  114. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  115. package/dist/esm/client/format/useDate.mjs +1 -43
  116. package/dist/esm/client/format/useDate.mjs.map +1 -1
  117. package/dist/esm/client/format/useIntl.mjs +1 -31
  118. package/dist/esm/client/format/useIntl.mjs.map +1 -1
  119. package/dist/esm/client/format/useList.mjs +1 -38
  120. package/dist/esm/client/format/useList.mjs.map +1 -1
  121. package/dist/esm/client/format/useNumber.mjs +1 -39
  122. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  123. package/dist/esm/client/format/usePercentage.mjs +1 -35
  124. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  125. package/dist/esm/client/format/useRelativeTime.mjs +1 -35
  126. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  127. package/dist/esm/client/format/useUnit.mjs +1 -34
  128. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  129. package/dist/esm/client/index.mjs +1 -13
  130. package/dist/esm/client/t.mjs +1 -19
  131. package/dist/esm/client/t.mjs.map +1 -1
  132. package/dist/esm/client/useContent.mjs +1 -18
  133. package/dist/esm/client/useContent.mjs.map +1 -1
  134. package/dist/esm/client/useDictionary.mjs +1 -25
  135. package/dist/esm/client/useDictionary.mjs.map +1 -1
  136. package/dist/esm/client/useDictionaryAsync.mjs +1 -21
  137. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  138. package/dist/esm/client/useDictionaryDynamic.mjs +1 -21
  139. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  140. package/dist/esm/client/useIntlayer.mjs +1 -40
  141. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  142. package/dist/esm/client/useLoadDynamic.mjs +1 -25
  143. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  144. package/dist/esm/client/useLocale.mjs +1 -53
  145. package/dist/esm/client/useLocale.mjs.map +1 -1
  146. package/dist/esm/client/useLocaleBase.mjs +1 -23
  147. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  148. package/dist/esm/client/useLocaleStorage.mjs +1 -51
  149. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  150. package/dist/esm/client/useTraduction.mjs +1 -33
  151. package/dist/esm/client/useTraduction.mjs.map +1 -1
  152. package/dist/esm/editor/CommunicatorContext.mjs +1 -35
  153. package/dist/esm/editor/CommunicatorContext.mjs.map +1 -1
  154. package/dist/esm/editor/ConfigurationContext.mjs +1 -22
  155. package/dist/esm/editor/ConfigurationContext.mjs.map +1 -1
  156. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -56
  157. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  158. package/dist/esm/editor/DictionariesRecordContext.mjs +1 -44
  159. package/dist/esm/editor/DictionariesRecordContext.mjs.map +1 -1
  160. package/dist/esm/editor/EditedContentContext.mjs +1 -157
  161. package/dist/esm/editor/EditedContentContext.mjs.map +1 -1
  162. package/dist/esm/editor/EditorEnabledContext.mjs +1 -28
  163. package/dist/esm/editor/EditorEnabledContext.mjs.map +1 -1
  164. package/dist/esm/editor/EditorProvider.mjs +1 -62
  165. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  166. package/dist/esm/editor/FocusDictionaryContext.mjs +1 -50
  167. package/dist/esm/editor/FocusDictionaryContext.mjs.map +1 -1
  168. package/dist/esm/editor/IntlayerEditorProvider.mjs +1 -60
  169. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  170. package/dist/esm/editor/index.mjs +1 -3
  171. package/dist/esm/editor/useCrossFrameMessageListener.mjs +1 -76
  172. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  173. package/dist/esm/editor/useCrossFrameState.mjs +1 -106
  174. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  175. package/dist/esm/editor/useCrossURLPathState.mjs +1 -64
  176. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  177. package/dist/esm/editor/useEditedContentRenderer.mjs +1 -26
  178. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  179. package/dist/esm/editor/useIframeClickInterceptor.mjs +1 -21
  180. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  181. package/dist/esm/getDictionary.mjs +1 -17
  182. package/dist/esm/getDictionary.mjs.map +1 -1
  183. package/dist/esm/getIntlayer.mjs +1 -17
  184. package/dist/esm/getIntlayer.mjs.map +1 -1
  185. package/dist/esm/html/HTMLProvider.mjs +1 -16
  186. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  187. package/dist/esm/html/HTMLRenderer.mjs +1 -56
  188. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  189. package/dist/esm/html/index.mjs +1 -4
  190. package/dist/esm/index.mjs +1 -22
  191. package/dist/esm/markdown/MarkdownProvider.mjs +1 -46
  192. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  193. package/dist/esm/markdown/MarkdownRenderer.mjs +1 -73
  194. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  195. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -28
  196. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  197. package/dist/esm/markdown/compiler.mjs +1 -17
  198. package/dist/esm/markdown/compiler.mjs.map +1 -1
  199. package/dist/esm/markdown/index.mjs +1 -7
  200. package/dist/esm/markdown/runtime.mjs +1 -15
  201. package/dist/esm/markdown/runtime.mjs.map +1 -1
  202. package/dist/esm/plugins.mjs +1 -190
  203. package/dist/esm/plugins.mjs.map +1 -1
  204. package/dist/esm/preactElement/renderPreactElement.mjs +1 -40
  205. package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
  206. package/dist/types/IntlayerNode.d.ts +1 -1
  207. package/dist/types/client/format/useDate.d.ts +1 -1
  208. package/dist/types/client/useDictionary.d.ts +2 -2
  209. package/dist/types/client/useDictionary.d.ts.map +1 -1
  210. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  211. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  212. package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
  213. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  214. package/dist/types/editor/EditedContentContext.d.ts.map +1 -1
  215. package/dist/types/getDictionary.d.ts +1 -1
  216. package/dist/types/getIntlayer.d.ts +1 -1
  217. package/dist/types/getIntlayer.d.ts.map +1 -1
  218. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  219. package/dist/types/html/types.d.ts +1 -1
  220. package/dist/types/html/types.d.ts.map +1 -1
  221. package/dist/types/index.d.ts +1 -1
  222. package/dist/types/index.d.ts.map +1 -1
  223. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  224. package/dist/types/markdown/compiler.d.ts +1 -1
  225. package/dist/types/markdown/runtime.d.ts +1 -1
  226. package/dist/types/plugins.d.ts +2 -2
  227. package/dist/types/plugins.d.ts.map +1 -1
  228. package/package.json +8 -8
@@ -1,17 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- let preact = require("preact");
4
-
5
- //#region src/IntlayerNode.tsx
6
- const renderIntlayerNode = ({ children, value, additionalProps }) => {
7
- const element = (0, preact.isValidElement)(children) ? children : (0, preact.h)(preact.Fragment, {}, children);
8
- return new Proxy(element, { get(target, prop, receiver) {
9
- if (prop === "value") return value;
10
- if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
11
- return Reflect.get(target, prop, receiver);
12
- } });
13
- };
14
-
15
- //#endregion
16
- exports.renderIntlayerNode = renderIntlayerNode;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);let e=require(`preact`);const t=({children:t,value:n,additionalProps:r})=>{let i=(0,e.isValidElement)(t)?t:(0,e.h)(e.Fragment,{},t);return new Proxy(i,{get(e,t,i){return t===`value`?n:r&&Object.keys(r).includes(t)?r[t]:Reflect.get(e,t,i)}})};exports.renderIntlayerNode=t;
17
2
  //# sourceMappingURL=IntlayerNode.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerNode.cjs","names":["Fragment"],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core';\nimport {\n type ComponentChildren,\n Fragment,\n h,\n isValidElement,\n type VNode,\n} from 'preact';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = VNode & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: ComponentChildren;\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 VNode, wrap it in a fragment\n const element: VNode<any> = isValidElement(children)\n ? children\n : h(Fragment, {}, children);\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 VNode, {\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,qCAAqC,SAAS,GAChD,yBACEA,iBAAU,EAAE,EAAE,SAAS;AAI7B,QAAO,IAAI,MAAM,SAAkB,EACjC,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
+ {"version":3,"file":"IntlayerNode.cjs","names":["Fragment"],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport {\n type ComponentChildren,\n Fragment,\n h,\n isValidElement,\n type VNode,\n} from 'preact';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = VNode & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: ComponentChildren;\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 VNode, wrap it in a fragment\n const element: VNode<any> = isValidElement(children)\n ? children\n : h(Fragment, {}, children);\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 VNode, {\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":"uIAsBA,MAAa,GAEX,CACA,WACA,QACA,qBACiD,CAEjD,IAAM,GAAA,EAAA,EAAA,gBAAqC,EAAS,CAChD,GAAA,EAAA,EAAA,GACEA,EAAAA,SAAU,EAAE,CAAE,EAAS,CAI7B,OAAO,IAAI,MAAM,EAAkB,CACjC,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,99 +1,2 @@
1
- 'use client';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
- let preact_hooks = require("preact/hooks");
6
- let preact_jsx_runtime = require("preact/jsx-runtime");
7
-
8
- //#region src/UI/ContentSelector.tsx
9
- const DEFAULT_PRESS_DETECT_DURATION = 250;
10
- const ContentSelector = ({ children, onPress: onSelect, onHover, onUnhover, onClickOutside: onUnselect, pressDuration = DEFAULT_PRESS_DETECT_DURATION, isSelecting: isSelectingProp, ...props }) => {
11
- const divRef = (0, preact_hooks.useRef)(null);
12
- const [isHovered, setIsHovered] = (0, preact_hooks.useState)(false);
13
- const [isSelectingState, setIsSelectingState] = (0, preact_hooks.useState)(isSelectingProp);
14
- const pressTimerRef = (0, preact_hooks.useRef)(null);
15
- const isChildrenString = typeof children === "string";
16
- const handleOnLongPress = () => {
17
- setIsSelectingState(true);
18
- onSelect();
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
- if (isHovered) {
41
- setIsHovered(false);
42
- onUnhover?.();
43
- }
44
- clearPressTimer();
45
- };
46
- const handleClickOutside = (0, preact_hooks.useCallback)((event) => {
47
- if (divRef.current && !divRef.current.contains(event.target)) {
48
- setIsSelectingState(false);
49
- onUnselect?.();
50
- }
51
- }, [onUnselect]);
52
- (0, preact_hooks.useEffect)(() => {
53
- document.addEventListener("mousedown", handleClickOutside);
54
- return () => {
55
- document.removeEventListener("mousedown", handleClickOutside);
56
- };
57
- }, [handleClickOutside]);
58
- const handleOnClick = (e) => {
59
- if (isSelectingState) {
60
- e.preventDefault();
61
- e.stopPropagation();
62
- }
63
- };
64
- const handleOnBlur = () => {
65
- setIsSelectingState(false);
66
- };
67
- return /* @__PURE__ */ (0, preact_jsx_runtime.jsx)("span", {
68
- style: {
69
- display: isChildrenString ? "inline" : "inline-block",
70
- cursor: "pointer",
71
- userSelect: "none",
72
- borderRadius: "0.375rem",
73
- outlineWidth: "2px",
74
- outlineOffset: "4px",
75
- outlineStyle: "solid",
76
- outlineColor: isSelectingProp || isSelectingState || isHovered ? "inherit" : "transparent",
77
- transition: "all 100ms 50ms ease-in-out"
78
- },
79
- role: "button",
80
- tabIndex: 0,
81
- onKeyUp: () => null,
82
- onClick: handleOnClick,
83
- onMouseDown: handleMouseDown,
84
- onMouseUp: handleMouseUp,
85
- onMouseLeave: handleMouseUp,
86
- onTouchStart: handleMouseDown,
87
- onTouchEnd: handleMouseUp,
88
- onTouchCancel: handleMouseUp,
89
- onBlur: handleOnBlur,
90
- onMouseEnter: handleMouseEnter,
91
- ref: divRef,
92
- ...props,
93
- children
94
- });
95
- };
96
-
97
- //#endregion
98
- exports.ContentSelector = ContentSelector;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`preact/hooks`),t=require(`preact/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=()=>{d&&(f(!1),a?.()),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;
99
2
  //# sourceMappingURL=ContentSelector.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport type { FunctionalComponent, JSX } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\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<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\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 onSelect();\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 if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\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: JSX.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":";;;;;;;;AAKA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,kCAAgC,KAAK;CAC3C,MAAM,CAAC,WAAW,2CAAyB,MAAM;CACjD,MAAM,CAAC,kBAAkB,kDAAgC,gBAAgB;CACzE,MAAM,yCAA6D,KAAK;CACxE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;AAC9B,sBAAoB,KAAK;AACzB,YAAU;;CAGZ,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,MAAI,WAAW;AACb,gBAAa,MAAM;AACnB,gBAAa;;AAEf,mBAAiB;;CAInB,MAAM,oDACH,UAAsB;AACrB,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,OAAe,EAAE;AACpE,uBAAoB,MAAM;AAC1B,iBAAc;;IAGlB,CAAC,WAAW,CACb;AAED,mCAAgB;AAEd,WAAS,iBAAiB,aAAa,mBAAmB;AAE1D,eAAa;AAEX,YAAS,oBAAoB,aAAa,mBAAmB;;IAG9D,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAwD,MAAM;AAClE,MAAI,kBAAkB;AACpB,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;;CAIvB,MAAM,qBAAqB;AAEzB,sBAAoB,MAAM;;AAG5B,QACE,4CAAC;EACC,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;GACI"}
1
+ {"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport type { FunctionalComponent, JSX } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\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<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\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 onSelect();\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 if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\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: JSX.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":"2LAKA,MAWa,GAA8D,CACzE,WACA,QAAS,EACT,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,GAAU,EAGN,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,CACtB,IACF,EAAa,GAAM,CACnB,KAAa,EAEf,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,OAAA,CACC,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/B0D,GAAM,CAC9D,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,YACI"}
@@ -1,29 +1 @@
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
+ 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,92 +1,2 @@
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_useCrossFrameState = require('../editor/useCrossFrameState.cjs');
6
- const require_editor_IntlayerEditorProvider = require('../editor/IntlayerEditorProvider.cjs');
7
- const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
8
- let preact = require("preact");
9
- let _intlayer_core = require("@intlayer/core");
10
- let _intlayer_editor = require("@intlayer/editor");
11
- let preact_hooks = require("preact/hooks");
12
- let _intlayer_config_built = require("@intlayer/config/built");
13
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
14
- let preact_jsx_runtime = require("preact/jsx-runtime");
15
-
16
- //#region src/client/IntlayerProvider.tsx
17
- /**
18
- * Context that store the current locale on the client side
19
- */
20
- const IntlayerClientContext = (0, preact.createContext)({
21
- locale: require_client_useLocaleStorage.localeInStorage ?? _intlayer_config_built.default?.internationalization?.defaultLocale,
22
- setLocale: () => null,
23
- disableEditor: false
24
- });
25
- /**
26
- * Hook that provides the current locale
27
- */
28
- const useIntlayerContext = () => (0, preact_hooks.useContext)(IntlayerClientContext);
29
- /**
30
- * Provider that store the current locale on the client side
31
- */
32
- const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
33
- const { internationalization } = _intlayer_config_built.default ?? {};
34
- const { defaultLocale: defaultLocaleConfig, locales: availableLocales } = internationalization ?? {};
35
- const defaultLocale = localeProp ?? require_client_useLocaleStorage.localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;
36
- const [currentLocale, setCurrentLocale] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_CURRENT_LOCALE, defaultLocale);
37
- (0, preact_hooks.useEffect)(() => {
38
- if (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);
39
- }, [
40
- localeProp,
41
- currentLocale,
42
- setCurrentLocale
43
- ]);
44
- const setLocaleBase = (newLocale) => {
45
- if (currentLocale.toString() === newLocale.toString()) return;
46
- if (!availableLocales?.map(String).includes(newLocale)) {
47
- console.error(`Locale ${newLocale} is not available`);
48
- return;
49
- }
50
- setCurrentLocale(newLocale);
51
- require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled ?? true);
52
- };
53
- const setLocale = setLocaleProp ?? setLocaleBase;
54
- const resolvedLocale = (0, _intlayer_core.localeResolver)(localeProp ?? currentLocale);
55
- return /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(IntlayerClientContext.Provider, {
56
- value: {
57
- locale: resolvedLocale,
58
- setLocale,
59
- disableEditor,
60
- isCookieEnabled
61
- },
62
- children
63
- });
64
- };
65
- /**
66
- * Main provider for Intlayer in Preact applications.
67
- *
68
- * It provides the Intlayer context to your application, allowing the use
69
- * of hooks like `useIntlayer` and `useLocale`.
70
- *
71
- * @param props - The provider props.
72
- * @returns The provider component.
73
- *
74
- * @example
75
- * ```tsx
76
- * import { IntlayerProvider } from 'preact-intlayer';
77
- *
78
- * const App = () => (
79
- * <IntlayerProvider>
80
- * <MyComponent />
81
- * </IntlayerProvider>
82
- * );
83
- * ```
84
- */
85
- const IntlayerProvider = (props) => /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_IntlayerEditorProvider.IntlayerEditorProvider, { children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(IntlayerProviderContent, { ...props }) });
86
-
87
- //#endregion
88
- exports.IntlayerClientContext = IntlayerClientContext;
89
- exports.IntlayerProvider = IntlayerProvider;
90
- exports.IntlayerProviderContent = IntlayerProviderContent;
91
- exports.useIntlayerContext = useIntlayerContext;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../editor/useCrossFrameState.cjs`),n=require(`../editor/IntlayerEditorProvider.cjs`),r=require(`./useLocaleStorage.cjs`);let i=require(`preact`),a=require(`@intlayer/editor`),o=require(`preact/hooks`),s=require(`@intlayer/config/built`);s=e.__toESM(s);let c=require(`@intlayer/core/localization`),l=require(`preact/jsx-runtime`);const u=(0,i.createContext)({locale:r.localeInStorage??s.default?.internationalization?.defaultLocale,setLocale:()=>null,disableEditor:!1}),d=()=>(0,o.useContext)(u),f=({locale:e,defaultLocale:n,children:i,setLocale:d,disableEditor:f,isCookieEnabled:p})=>{let{internationalization:m}=s.default??{},{defaultLocale:h,locales:g}=m??{},_=e??r.localeInStorage??n??h,[v,y]=t.useCrossFrameState(a.MessageKey.INTLAYER_CURRENT_LOCALE,_);(0,o.useEffect)(()=>{e&&e!==v&&y(e)},[e,v,y]);let b=d??(e=>{if(v.toString()!==e.toString()){if(!g?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}y(e),r.setLocaleInStorage(e,p??!0)}}),x=(0,c.localeResolver)(e??v);return(0,l.jsx)(u.Provider,{value:{locale:x,setLocale:b,disableEditor:f,isCookieEnabled:p},children:i})},p=e=>(0,l.jsx)(n.IntlayerEditorProvider,{children:(0,l.jsx)(f,{...e})});exports.IntlayerClientContext=u,exports.IntlayerProvider=p,exports.IntlayerProviderContent=f,exports.useIntlayerContext=d;
92
2
  //# sourceMappingURL=IntlayerProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","useCrossFrameState","MessageKey","IntlayerEditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { LocalesValues } from '@intlayer/types';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect } from 'preact/hooks';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { useCrossFrameState } from '../editor/useCrossFrameState';\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 store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = (\n props\n) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kDAAqD;CAChE,QAAQA,mDAAmBC,gCAAe,sBAAsB;CAChE,iBAAiB;CACjB,eAAe;CAChB,CAAC;;;;AAKF,MAAa,wDAAsC,sBAAsB;;;;AAczE,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyBA,kCAAiB,EAAE;CACpD,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnD,wBAAwB,EAAE;CAE5B,MAAM,gBACJ,cAAcD,mDAAmB,qBAAqB;CAExD,MAAM,CAAC,eAAe,oBAAoBE,qDACxCC,4BAAW,yBACX,cACD;AAED,mCAAgB;AACd,MAAI,cAAc,eAAe,cAC/B,kBAAiB,WAAW;IAE7B;EAAC;EAAY;EAAe;EAAiB,CAAC;CAEjD,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,mBAAmB,KAAK;;CAGxD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,oDAAgC,cAAc,cAAc;AAElE,QACE,4CAAC,sBAAsB;EACrB,OAAO;GACL,QAAQ;GACR;GACA;GACA;GACD;EAEA;GAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBACX,UAEA,4CAACC,0EACC,4CAAC,2BAAwB,GAAI,QAAS,GACf"}
1
+ {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","configuration","useCrossFrameState","MessageKey","IntlayerEditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core/localization';\nimport { MessageKey } from '@intlayer/editor';\nimport type { LocalesValues } from '@intlayer/types';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect } from 'preact/hooks';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { useCrossFrameState } from '../editor/useCrossFrameState';\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 store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = (\n props\n) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":"ydA0BA,MAAa,GAAA,EAAA,EAAA,eAAqD,CAChE,OAAQA,EAAAA,iBAAmBC,EAAAA,SAAe,sBAAsB,cAChE,cAAiB,KACjB,cAAe,GAChB,CAAC,CAKW,OAAA,EAAA,EAAA,YAAsC,EAAsB,CAc5D,GAER,CACH,OAAQ,EACR,cAAe,EACf,WACA,UAAW,EACX,gBACA,qBACI,CACJ,GAAM,CAAE,wBAAyBA,EAAAA,SAAiB,EAAE,CAC9C,CAAE,cAAe,EAAqB,QAAS,GACnD,GAAwB,EAAE,CAEtB,EACJ,GAAcD,EAAAA,iBAAmB,GAAqB,EAElD,CAAC,EAAe,GAAoBE,EAAAA,mBACxCC,EAAAA,WAAW,wBACX,EACD,EAED,EAAA,EAAA,eAAgB,CACV,GAAc,IAAe,GAC/B,EAAiB,EAAW,EAE7B,CAAC,EAAY,EAAe,EAAiB,CAAC,CAcjD,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,GAAmB,GAAK,IAKlD,GAAA,EAAA,EAAA,gBAAgC,GAAc,EAAc,CAElE,OACE,EAAA,EAAA,KAAC,EAAsB,SAAA,CACrB,MAAO,CACL,OAAQ,EACR,YACA,gBACA,kBACD,CAEA,YAC8B,EAwBxB,EACX,IAEA,EAAA,EAAA,KAACC,EAAAA,uBAAAA,CAAAA,UACC,EAAA,EAAA,KAAC,EAAA,CAAwB,GAAI,EAAA,CAAS,CAAA,CACf"}
@@ -1,18 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_client_format_useCompact = require('./useCompact.cjs');
3
- const require_client_format_useCurrency = require('./useCurrency.cjs');
4
- const require_client_format_useDate = require('./useDate.cjs');
5
- const require_client_format_useList = require('./useList.cjs');
6
- const require_client_format_useNumber = require('./useNumber.cjs');
7
- const require_client_format_usePercentage = require('./usePercentage.cjs');
8
- const require_client_format_useRelativeTime = require('./useRelativeTime.cjs');
9
- const require_client_format_useUnit = require('./useUnit.cjs');
10
-
11
- exports.useCompact = require_client_format_useCompact.useCompact;
12
- exports.useCurrency = require_client_format_useCurrency.useCurrency;
13
- exports.useDate = require_client_format_useDate.useDate;
14
- exports.useList = require_client_format_useList.useList;
15
- exports.useNumber = require_client_format_useNumber.useNumber;
16
- exports.usePercentage = require_client_format_usePercentage.usePercentage;
17
- exports.useRelativeTime = require_client_format_useRelativeTime.useRelativeTime;
18
- exports.useUnit = require_client_format_useUnit.useUnit;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useCompact.cjs`),t=require(`./useCurrency.cjs`),n=require(`./useDate.cjs`),r=require(`./useList.cjs`),i=require(`./useNumber.cjs`),a=require(`./usePercentage.cjs`),o=require(`./useRelativeTime.cjs`),s=require(`./useUnit.cjs`);exports.useCompact=e.useCompact,exports.useCurrency=t.useCurrency,exports.useDate=n.useDate,exports.useList=r.useList,exports.useNumber=i.useNumber,exports.usePercentage=a.usePercentage,exports.useRelativeTime=o.useRelativeTime,exports.useUnit=s.useUnit;
@@ -1,30 +1,2 @@
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 _intlayer_core = require("@intlayer/core");
7
- let preact_hooks = require("preact/hooks");
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, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
22
- return (0, preact_hooks.useCallback)((...args) => (0, _intlayer_core.compact)(args[0], {
23
- ...args[1],
24
- locale: args[1]?.locale ?? locale
25
- }), [locale]);
26
- };
27
-
28
- //#endregion
29
- exports.useCompact = useCompact;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`preact/hooks`),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;
30
2
  //# 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';\nimport { useCallback, useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,qCACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,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 'preact/hooks';\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":"gPAgBA,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,44 +1,2 @@
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 _intlayer_core = require("@intlayer/core");
7
- let preact_hooks = require("preact/hooks");
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, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
36
- return (0, preact_hooks.useCallback)((...args) => (0, _intlayer_core.currency)(args[0], {
37
- ...args[1],
38
- locale: args[1]?.locale ?? locale
39
- }), [locale]);
40
- };
41
-
42
- //#endregion
43
- exports.useCurrency = useCurrency;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`preact/hooks`),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;
44
2
  //# 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';\nimport { useCallback, useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,sCACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,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 'preact/hooks';\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":"gPA8BA,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,46 +1,2 @@
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 _intlayer_core = require("@intlayer/core");
7
- let preact_hooks = require("preact/hooks");
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, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
38
- return (...args) => (0, _intlayer_core.date)(args[0], {
39
- ...args[1],
40
- locale: args[1]?.locale ?? locale
41
- });
42
- };
43
-
44
- //#endregion
45
- exports.useDate = useDate;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`preact/hooks`),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;
46
2
  //# 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';\nimport { useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,SAAQ,GAAG,kCACJ,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;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 'preact/hooks';\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":"gPAgCA,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,34 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
- const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
4
- let _intlayer_core = require("@intlayer/core");
5
- let preact_hooks = require("preact/hooks");
6
-
7
- //#region src/client/format/useIntl.ts
8
- /**
9
- * Preact client hook that provides a locale-bound `Intl` object.
10
- *
11
- * It acts exactly like the native `Intl` object, but acts as a proxy to:
12
- * 1. Inject the current locale automatically if none is provided.
13
- * 2. Use the performance-optimized `CachedIntl` under the hood.
14
- *
15
- * @example
16
- * ```tsx
17
- * const intl = useIntl(); // uses context locale
18
- *
19
- * // Standard API, but no need to pass locale as the first argument
20
- * const formatted = new intl.NumberFormat({
21
- * style: 'currency',
22
- * currency: 'USD'
23
- * }).format(123.45);
24
- * ```
25
- */
26
- const useIntl = (locale) => {
27
- const { locale: contextLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
28
- const currentLocale = locale ?? contextLocale;
29
- return (0, preact_hooks.useMemo)(() => (0, _intlayer_core.bindIntl)(currentLocale), [currentLocale]);
30
- };
31
-
32
- //#endregion
33
- exports.useIntl = useIntl;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`preact/hooks`),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;
34
2
  //# sourceMappingURL=useIntl.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["import { bindIntl } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Preact 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 locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;CACnE,MAAM,gBAAgB,UAAU;AAEhC,qEAA8B,cAAc,EAAE,CAAC,cAAc,CAAC"}
1
+ {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["import { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Preact 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 locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"mOAuBA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,UAA8B,EAAc,CAAE,CAAC,EAAc,CAAC"}
@@ -1,41 +1,2 @@
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 _intlayer_core = require("@intlayer/core");
7
- let preact_hooks = require("preact/hooks");
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, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
33
- return (0, preact_hooks.useCallback)((...args) => (0, _intlayer_core.list)(args[0], {
34
- ...args[1],
35
- locale: args[1]?.locale ?? locale
36
- }), [locale]);
37
- };
38
-
39
- //#endregion
40
- exports.useList = useList;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../IntlayerProvider.cjs`);let t=require(`preact/hooks`),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;
41
2
  //# 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';\nimport { useCallback, useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,kCACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,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 'preact/hooks';\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":"gPA2BA,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"}