angular-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 (168) hide show
  1. package/dist/cjs/UI/ContentSelector.component.cjs +2 -116
  2. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs +1 -11
  4. package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs +1 -8
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  6. package/dist/cjs/client/index.cjs +1 -28
  7. package/dist/cjs/client/installIntlayer.cjs +1 -77
  8. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionary.cjs +1 -15
  10. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
  12. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  13. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
  14. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  15. package/dist/cjs/client/useIntl.cjs +1 -40
  16. package/dist/cjs/client/useIntl.cjs.map +1 -1
  17. package/dist/cjs/client/useIntlayer.cjs +1 -44
  18. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  19. package/dist/cjs/client/useLoadDynamic.cjs +1 -28
  20. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  21. package/dist/cjs/client/useLocale.cjs +1 -60
  22. package/dist/cjs/client/useLocale.cjs.map +1 -1
  23. package/dist/cjs/client/useLocaleStorage.cjs +1 -60
  24. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  25. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +2 -51
  26. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  27. package/dist/cjs/editor/EditedContentRenderer.component.cjs +1 -54
  28. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  29. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +2 -35
  30. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  31. package/dist/cjs/editor/communicator.cjs +1 -63
  32. package/dist/cjs/editor/communicator.cjs.map +1 -1
  33. package/dist/cjs/editor/configuration.cjs +1 -22
  34. package/dist/cjs/editor/configuration.cjs.map +1 -1
  35. package/dist/cjs/editor/createSharedComposable.cjs +1 -50
  36. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
  37. package/dist/cjs/editor/dictionariesRecord.cjs +1 -49
  38. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
  39. package/dist/cjs/editor/editedContent.cjs +1 -61
  40. package/dist/cjs/editor/editedContent.cjs.map +1 -1
  41. package/dist/cjs/editor/editorEnabled.cjs +1 -49
  42. package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
  43. package/dist/cjs/editor/editorLocale.cjs +1 -21
  44. package/dist/cjs/editor/editorLocale.cjs.map +1 -1
  45. package/dist/cjs/editor/focusDictionary.cjs +1 -62
  46. package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
  47. package/dist/cjs/editor/index.cjs +1 -25
  48. package/dist/cjs/editor/installIntlayerEditor.cjs +1 -52
  49. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
  50. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -73
  51. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  52. package/dist/cjs/editor/useCrossFrameState.cjs +1 -114
  53. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  54. package/dist/cjs/editor/useCrossURLPathState.cjs +1 -65
  55. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  56. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -35
  57. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  58. package/dist/cjs/editor/useEditor.cjs +1 -24
  59. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  60. package/dist/cjs/editor/useIframeClickInterceptor.cjs +1 -39
  61. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  62. package/dist/cjs/getDictionary.cjs +1 -17
  63. package/dist/cjs/getDictionary.cjs.map +1 -1
  64. package/dist/cjs/getIntlayer.cjs +1 -18
  65. package/dist/cjs/getIntlayer.cjs.map +1 -1
  66. package/dist/cjs/index.cjs +1 -49
  67. package/dist/cjs/markdown/index.cjs +1 -13
  68. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -79
  69. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  70. package/dist/cjs/plugins.cjs +1 -188
  71. package/dist/cjs/plugins.cjs.map +1 -1
  72. package/dist/cjs/renderIntlayerNode.cjs +1 -28
  73. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  74. package/dist/cjs/webpack/index.cjs +1 -4
  75. package/dist/cjs/webpack/mergeConfig.cjs +1 -44
  76. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  77. package/dist/esm/UI/ContentSelector.component.mjs +2 -109
  78. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
  79. package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +1 -10
  80. package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +1 -7
  81. package/dist/esm/client/index.mjs +1 -10
  82. package/dist/esm/client/installIntlayer.mjs +1 -65
  83. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  84. package/dist/esm/client/useDictionary.mjs +1 -13
  85. package/dist/esm/client/useDictionary.mjs.map +1 -1
  86. package/dist/esm/client/useDictionaryAsync.mjs +1 -21
  87. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  88. package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
  89. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  90. package/dist/esm/client/useIntl.mjs +1 -38
  91. package/dist/esm/client/useIntl.mjs.map +1 -1
  92. package/dist/esm/client/useIntlayer.mjs +1 -41
  93. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  94. package/dist/esm/client/useLoadDynamic.mjs +1 -26
  95. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  96. package/dist/esm/client/useLocale.mjs +1 -57
  97. package/dist/esm/client/useLocale.mjs.map +1 -1
  98. package/dist/esm/client/useLocaleStorage.mjs +1 -53
  99. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  100. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +2 -44
  101. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
  102. package/dist/esm/editor/EditedContentRenderer.component.mjs +1 -47
  103. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
  104. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +2 -28
  105. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
  106. package/dist/esm/editor/communicator.mjs +1 -58
  107. package/dist/esm/editor/communicator.mjs.map +1 -1
  108. package/dist/esm/editor/configuration.mjs +1 -19
  109. package/dist/esm/editor/configuration.mjs.map +1 -1
  110. package/dist/esm/editor/createSharedComposable.mjs +1 -47
  111. package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
  112. package/dist/esm/editor/dictionariesRecord.mjs +1 -45
  113. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
  114. package/dist/esm/editor/editedContent.mjs +1 -57
  115. package/dist/esm/editor/editedContent.mjs.map +1 -1
  116. package/dist/esm/editor/editorEnabled.mjs +1 -45
  117. package/dist/esm/editor/editorEnabled.mjs.map +1 -1
  118. package/dist/esm/editor/editorLocale.mjs +1 -19
  119. package/dist/esm/editor/editorLocale.mjs.map +1 -1
  120. package/dist/esm/editor/focusDictionary.mjs +1 -58
  121. package/dist/esm/editor/focusDictionary.mjs.map +1 -1
  122. package/dist/esm/editor/index.mjs +1 -6
  123. package/dist/esm/editor/installIntlayerEditor.mjs +1 -49
  124. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
  125. package/dist/esm/editor/useCrossFrameMessageListener.mjs +1 -71
  126. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  127. package/dist/esm/editor/useCrossFrameState.mjs +1 -112
  128. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  129. package/dist/esm/editor/useCrossURLPathState.mjs +1 -62
  130. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  131. package/dist/esm/editor/useEditedContentRenderer.mjs +1 -26
  132. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  133. package/dist/esm/editor/useEditor.mjs +1 -23
  134. package/dist/esm/editor/useEditor.mjs.map +1 -1
  135. package/dist/esm/editor/useIframeClickInterceptor.mjs +1 -36
  136. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  137. package/dist/esm/getDictionary.mjs +1 -15
  138. package/dist/esm/getDictionary.mjs.map +1 -1
  139. package/dist/esm/getIntlayer.mjs +1 -16
  140. package/dist/esm/getIntlayer.mjs.map +1 -1
  141. package/dist/esm/index.mjs +1 -14
  142. package/dist/esm/markdown/index.mjs +1 -3
  143. package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -68
  144. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  145. package/dist/esm/plugins.mjs +1 -182
  146. package/dist/esm/plugins.mjs.map +1 -1
  147. package/dist/esm/renderIntlayerNode.mjs +1 -26
  148. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  149. package/dist/esm/webpack/index.mjs +1 -3
  150. package/dist/esm/webpack/mergeConfig.mjs +1 -42
  151. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  152. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  153. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  154. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +1 -1
  155. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
  156. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +1 -1
  157. package/dist/types/getDictionary.d.ts +3 -3
  158. package/dist/types/getDictionary.d.ts.map +1 -1
  159. package/dist/types/getIntlayer.d.ts +1 -1
  160. package/dist/types/getIntlayer.d.ts.map +1 -1
  161. package/dist/types/index.d.ts +1 -1
  162. package/dist/types/index.d.ts.map +1 -1
  163. package/dist/types/markdown/installIntlayerMarkdown.d.ts +1 -1
  164. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  165. package/dist/types/plugins.d.ts +1 -1
  166. package/dist/types/plugins.d.ts.map +1 -1
  167. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  168. package/package.json +8 -8
@@ -1,66 +1,2 @@
1
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
2
- import { Injectable, InjectionToken, signal } from "@angular/core";
3
- import configuration from "@intlayer/config/built";
4
-
5
- //#region src/client/installIntlayer.ts
6
- const INTLAYER_TOKEN = new InjectionToken("intlayer");
7
- /**
8
- * Singleton instance
9
- */
10
- let instance = null;
11
- let IntlayerProvider = class IntlayerProvider {
12
- isCookieEnabled = signal(true);
13
- _locale = signal(configuration.internationalization?.defaultLocale);
14
- locale = this._locale.asReadonly();
15
- setLocale = (locale) => {
16
- this._locale.set(locale);
17
- };
18
- };
19
- IntlayerProvider = __decorate([Injectable({ providedIn: "root" })], IntlayerProvider);
20
- /**
21
- * Create and return a single IntlayerProvider instance
22
- */
23
- const createIntlayerClient = (locale, isCookieEnabled = true) => {
24
- if (instance) return instance;
25
- instance = new IntlayerProvider();
26
- if (locale) instance.setLocale(locale);
27
- instance.isCookieEnabled.set(isCookieEnabled);
28
- return instance;
29
- };
30
- /**
31
- * Provides Intlayer to your Angular application.
32
- *
33
- * This function should be used in your application's provider list (e.g., in `app.config.ts`)
34
- * to initialize the Intlayer service.
35
- *
36
- * @param locale - Initial locale to use.
37
- * @param isCookieEnabled - Whether to store the locale in cookies.
38
- * @returns A provider configuration for Intlayer.
39
- *
40
- * @example
41
- * ```ts
42
- * // app.config.ts
43
- * import { ApplicationConfig } from '@angular/core';
44
- * import { provideIntlayer } from 'angular-intlayer';
45
- *
46
- * export const appConfig: ApplicationConfig = {
47
- * providers: [
48
- * provideIntlayer({ locale: 'en' }),
49
- * ],
50
- * };
51
- * ```
52
- */
53
- const provideIntlayer = (locale, isCookieEnabled = true) => ({
54
- provide: INTLAYER_TOKEN,
55
- useValue: installIntlayer(locale, isCookieEnabled)
56
- });
57
- /**
58
- * Helper to install the Intlayer provider.
59
- */
60
- const installIntlayer = (locale, isCookieEnabled = true) => {
61
- return createIntlayerClient(locale, isCookieEnabled);
62
- };
63
-
64
- //#endregion
65
- export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer };
1
+ import{__decorate as e}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";import{Injectable as t,InjectionToken as n,signal as r}from"@angular/core";import i from"@intlayer/config/built";const a=new n(`intlayer`);let o=null,s=class{isCookieEnabled=r(!0);_locale=r(i.internationalization?.defaultLocale);locale=this._locale.asReadonly();setLocale=e=>{this._locale.set(e)}};s=e([t({providedIn:`root`})],s);const c=(e,t=!0)=>o||(o=new s,e&&o.setLocale(e),o.isCookieEnabled.set(t),o),l=(e,t=!0)=>({provide:a,useValue:u(e,t)}),u=(e,t=!0)=>c(e,t);export{a as INTLAYER_TOKEN,s as IntlayerProvider,c as createIntlayerClient,u as installIntlayer,l as provideIntlayer};
66
2
  //# sourceMappingURL=installIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;;AAIA,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;AAKjC,6BAAM,iBAAiB;CAC5B,kBAAkB,OAAO,KAAK;CAC9B,AAAQ,UAAU,OAChB,cAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;+BAZ3B,WAAW,EACV,YAAY,QACb,CAAC;;;;AAiBF,MAAa,wBACX,QACA,kBAAkB,SACG;AACrB,KAAI,SAAU,QAAO;AAErB,YAAW,IAAI,kBAAkB;AAEjC,KAAI,OACF,UAAS,UAAU,OAAO;AAE5B,UAAS,gBAAgB,IAAI,gBAAgB;AAE7C,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,mBACX,QACA,kBAAkB,UACd;CACJ,SAAS;CACT,UAAU,gBAAgB,QAAQ,gBAAgB;CACnD;;;;AAKD,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
1
+ {"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"6MAIA,MAAa,EAAiB,IAAI,EAAiC,WAAW,CAK9E,IAAI,EAAoC,KAKjC,EAAA,KAAuB,CAC5B,gBAAkB,EAAO,GAAK,CAC9B,QAAkB,EAChB,EAAc,sBAAsB,cACrC,CAED,OAAyC,KAAK,QAAQ,YAAY,CAElE,UAAa,GAA0B,CACrC,KAAK,QAAQ,IAAI,EAAO,QAZ3B,EAAW,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,GACX,EACA,EAAkB,KAEd,IAEJ,EAAW,IAAI,EAEX,GACF,EAAS,UAAU,EAAO,CAE5B,EAAS,gBAAgB,IAAI,EAAgB,CAEtC,GA0BI,GACX,EACA,EAAkB,MACd,CACJ,QAAS,EACT,SAAU,EAAgB,EAAQ,EAAgB,CACnD,EAKY,GACX,EACA,EAAkB,KAEH,EAAqB,EAAQ,EAAgB"}
@@ -1,14 +1,2 @@
1
- import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
2
- import { getDictionary } from "../getDictionary.mjs";
3
- import { computed, inject } from "@angular/core";
4
-
5
- //#region src/client/useDictionary.ts
6
- const useDictionary = (dictionary, locale) => {
7
- const intlayer = inject(INTLAYER_TOKEN);
8
- const localeTarget = computed(() => locale ?? intlayer?.locale());
9
- return computed(() => getDictionary(dictionary, localeTarget()));
10
- };
11
-
12
- //#endregion
13
- export { useDictionary };
1
+ import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{getDictionary as t}from"../getDictionary.mjs";import{computed as n,inject as r}from"@angular/core";const i=(i,a)=>{let o=r(e),s=n(()=>a??o?.locale());return n(()=>t(i,s()))};export{i as useDictionary};
14
2
  //# sourceMappingURL=useDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary, LocalesValues } from '@intlayer/types';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,YACA,WAC+C;CAC/C,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAAe,UAAU,UAAU,QAAQ,CAAC;AAOjE,QAJgB,eACd,cAAgC,YAAY,cAAc,CAAC,CAC5D"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary, LocalesValues } from '@intlayer/types';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"iKAMA,MAAa,GACX,EACA,IAC+C,CAC/C,IAAM,EAAW,EAAyB,EAAe,CAEnD,EAAe,MAAe,GAAU,GAAU,QAAQ,CAAC,CAOjE,OAJgB,MACd,EAAgC,EAAY,GAAc,CAAC,CAC5D"}
@@ -1,22 +1,2 @@
1
- 'use client';
2
-
3
- import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
4
- import { useDictionary } from "./useDictionary.mjs";
5
- import { computed, inject } from "@angular/core";
6
- import configuration from "@intlayer/config/built";
7
-
8
- //#region src/client/useDictionaryAsync.ts
9
- /**
10
- * On the server side, Hook that transform a dictionary and return the content
11
- *
12
- * If the locale is not provided, it will use the locale from the client context
13
- */
14
- const useDictionaryAsync = async (dictionaryPromise, locale) => {
15
- const intlayer = inject(INTLAYER_TOKEN);
16
- const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
17
- return useDictionary(await dictionaryPromise[localeTarget()]?.(), localeTarget());
18
- };
19
-
20
- //#endregion
21
- export { useDictionaryAsync };
1
+ "use client";import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{useDictionary as t}from"./useDictionary.mjs";import{computed as n,inject as r}from"@angular/core";import i from"@intlayer/config/built";const a=async(a,o)=>{let s=r(e),c=n(()=>o??s?.locale()??i?.internationalization.defaultLocale);return t(await a[c()]?.(),c())};export{a as useDictionaryAsync};
22
2
  //# sourceMappingURL=useDictionaryAsync.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\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) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAID,QAAO,cAFY,MAAM,kBAAkB,cAAc,KAAK,EAE7B,cAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\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) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"mNAiBA,MAAa,EAAqB,MAChC,EACA,IACG,CACH,IAAM,EAAW,EAAyB,EAAe,CAEnD,EAAe,MAEjB,GACA,GAAU,QAAQ,EAClB,GAAe,qBAAqB,cACvC,CAID,OAAO,EAFY,MAAM,EAAkB,GAAc,KAAK,CAE7B,GAAc,CAAQ"}
@@ -1,23 +1,2 @@
1
- 'use client';
2
-
3
- import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
4
- import { useDictionary } from "./useDictionary.mjs";
5
- import { useLoadDynamic } from "./useLoadDynamic.mjs";
6
- import { computed, inject } from "@angular/core";
7
- import configuration from "@intlayer/config/built";
8
-
9
- //#region src/client/useDictionaryDynamic.ts
10
- /**
11
- * On the server side, Hook that transform a dictionary and return the content
12
- *
13
- * If the locale is not provided, it will use the locale from the client context
14
- */
15
- const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
16
- const intlayer = inject(INTLAYER_TOKEN);
17
- const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
18
- return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
19
- };
20
-
21
- //#endregion
22
- export { useDictionaryDynamic };
1
+ "use client";import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{useDictionary as t}from"./useDictionary.mjs";import{useLoadDynamic as n}from"./useLoadDynamic.mjs";import{computed as r,inject as i}from"@angular/core";import a from"@intlayer/config/built";const o=(o,s,c)=>{let l=i(e),u=r(()=>c??l?.locale()??a?.internationalization.defaultLocale);return t(n(`${String(s)}.${u()}`,o[u()]?.()),u())};export{o as useDictionaryDynamic};
23
2
  //# sourceMappingURL=useDictionaryDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"yQAmBA,MAAa,GAIX,EACA,EACA,IACG,CACH,IAAM,EAAW,EAAyB,EAAe,CAEnD,EAAe,MAEjB,GACA,GAAU,QAAQ,EAClB,GAAe,qBAAqB,cACvC,CAOD,OAAO,EALY,EACjB,GAAG,OAAO,EAAI,CAAC,GAAG,GAAc,GAChC,EAAkB,GAAc,KAAK,CACtC,CAEgC,GAAc,CAAQ"}
@@ -1,39 +1,2 @@
1
- import { IntlayerProvider } from "./installIntlayer.mjs";
2
- import { bindIntl } from "@intlayer/core";
3
- import { computed, inject } from "@angular/core";
4
-
5
- //#region src/client/useIntl.ts
6
- /**
7
- * Angular composable that provides a locale-bound `Intl` object.
8
- *
9
- * It acts exactly like the native `Intl` object, but acts as a proxy to:
10
- * 1. Inject the current locale automatically if none is provided.
11
- * 2. Use the performance-optimized `CachedIntl` under the hood.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { Component, computed } from '@angular/core';
16
- * import { useIntl } from 'angular-intlayer';
17
- *
18
- * @Component({ ... })
19
- * export class MyComponent {
20
- * intl = useIntl();
21
- * formattedPrice = computed(() =>
22
- * new this.intl().NumberFormat({
23
- * style: 'currency',
24
- * currency: 'USD'
25
- * }).format(123.45)
26
- * );
27
- * }
28
- * ```
29
- */
30
- const useIntl = (locale) => {
31
- const intlayer = inject(IntlayerProvider);
32
- return computed(() => {
33
- return bindIntl(locale ?? intlayer.locale());
34
- });
35
- };
36
-
37
- //#endregion
38
- export { useIntl };
1
+ import{IntlayerProvider as e}from"./installIntlayer.mjs";import{computed as t,inject as n}from"@angular/core";import{bindIntl as r}from"@intlayer/core/formatters";const i=i=>{let a=n(e);return t(()=>r(i??a.locale()))};export{i as useIntl};
39
2
  //# sourceMappingURL=useIntl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable 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 * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,WAAW,WAA2B;CACjD,MAAM,WAAW,OAAO,iBAAiB;AAEzC,QAAO,eAAe;AAGpB,SAAO,SAFe,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
1
+ {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable 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 * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"mKA6BA,MAAa,EAAW,GAA2B,CACjD,IAAM,EAAW,EAAO,EAAiB,CAEzC,OAAO,MAGE,EAFe,GAAU,EAAS,QAAQ,CAEnB,CAC9B"}
@@ -1,42 +1,2 @@
1
- import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
2
- import { getIntlayer } from "../getIntlayer.mjs";
3
- import { computed, inject } from "@angular/core";
4
-
5
- //#region src/client/useIntlayer.ts
6
- /** guard utility - true only for objects generated by `renderIntlayerNode()` */
7
- const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
8
- /**
9
- * Angular hook that picks one dictionary by its key and returns its reactive content.
10
- *
11
- * It utilizes Angular signals to provide deep reactivity, ensuring your components
12
- * update automatically when the locale changes.
13
- *
14
- * @param key - The unique key of the dictionary to retrieve.
15
- * @param locale - Optional locale to override the current context locale.
16
- * @returns The transformed dictionary content.
17
- *
18
- * @example
19
- * ```ts
20
- * import { Component } from '@angular/core';
21
- * import { useIntlayer } from 'angular-intlayer';
22
- *
23
- * @Component({
24
- * standalone: true,
25
- * selector: 'app-my-component',
26
- * template: `<div>{{ content().myField.value }}</div>`,
27
- * })
28
- * export class MyComponent {
29
- * content = useIntlayer('my-dictionary-key');
30
- * }
31
- * ```
32
- */
33
- const useIntlayer = (key, locale) => {
34
- const intlayer = inject(INTLAYER_TOKEN);
35
- /** which locale should we use right now? */
36
- const localeTarget = computed(() => locale ?? intlayer.locale());
37
- return computed(() => getIntlayer(key, localeTarget()));
38
- };
39
-
40
- //#endregion
41
- export { isUpdatableNode, useIntlayer };
1
+ import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{getIntlayer as t}from"../getIntlayer.mjs";import{computed as n,inject as r}from"@angular/core";const i=e=>!!e&&typeof e==`object`&&typeof e.__update==`function`,a=(i,a)=>{let o=r(e),s=n(()=>a??o.locale());return n(()=>t(i,s()))};export{i as isUpdatableNode,a as useIntlayer};
42
2
  //# sourceMappingURL=useIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eACX,KACA,WAC+D;CAC/D,MAAM,WAAW,OAAyB,eAAe;;CAGzD,MAAM,eAAe,eAAe,UAAU,SAAS,QAAQ,CAAC;AAMhE,QAFgB,eAAe,YAAkB,KAAK,cAAc,CAAM,CAAC"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"6JAWA,MAAa,EACX,GAEA,CAAC,CAAC,GACF,OAAO,GAAQ,UACf,OAAQ,EAAY,UAAa,WA2BtB,GACX,EACA,IAC+D,CAC/D,IAAM,EAAW,EAAyB,EAAe,CAGnD,EAAe,MAAe,GAAU,EAAS,QAAQ,CAAC,CAMhE,OAFgB,MAAe,EAAkB,EAAK,GAAc,CAAM,CAAC"}
@@ -1,27 +1,2 @@
1
- import { signal } from "@angular/core";
2
-
3
- //#region src/client/useLoadDynamic.ts
4
- /**
5
- * A "synchronous" loader for a dynamically‐imported JSON (or anything).
6
- *
7
- * - Immediately returns a reactive signal so that Angular can properly track changes.
8
- * - When the Promise resolves, it replaces the signal's value with the real data.
9
- */
10
- const useLoadDynamic = (key, promise) => {
11
- const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
12
- const container = signal({});
13
- if (!cache.has(key)) {
14
- const p = promise.then((real) => {
15
- container.set(real);
16
- return real;
17
- });
18
- cache.set(key, p);
19
- } else cache.get(key)?.then((real) => {
20
- container.set(real);
21
- });
22
- return container();
23
- };
24
-
25
- //#endregion
26
- export { useLoadDynamic };
1
+ import{signal as e}from"@angular/core";const t=(n,r)=>{let i=t._cache||=new Map,a=e({});if(i.has(n))i.get(n)?.then(e=>{a.set(e)});else{let e=r.then(e=>(a.set(e),e));i.set(n,e)}return a()};export{t as useLoadDynamic};
27
2
  //# sourceMappingURL=useLoadDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.mjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBACX,KACA,YACM;CAEN,MAAM,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,KAAK;CAI3C,MAAM,YAAY,OAAO,EAAE,CAAM;AAEjC,KAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;AAE/B,aAAU,IAAI,KAAK;AACnB,UAAO;IACP;AACF,QAAM,IAAI,KAAK,EAAE;OAGjB,OAAM,IAAI,IAAI,EAAE,MAAM,SAAS;AAC7B,YAAU,IAAI,KAAK;GACnB;AAIJ,QAAO,WAAW"}
1
+ {"version":3,"file":"useLoadDynamic.mjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"uCAQA,MAAa,GACX,EACA,IACM,CAEN,IAAM,EAAkC,AACvC,EAAwB,SAAS,IAAI,IAIhC,EAAY,EAAO,EAAE,CAAM,CAEjC,GAAK,EAAM,IAAI,EAAI,CAUjB,EAAM,IAAI,EAAI,EAAE,KAAM,GAAS,CAC7B,EAAU,IAAI,EAAK,EACnB,KAZiB,CAEnB,IAAM,EAAI,EAAQ,KAAM,IAEtB,EAAU,IAAI,EAAK,CACZ,GACP,CACF,EAAM,IAAI,EAAK,EAAE,CASnB,OAAO,GAAW"}
@@ -1,58 +1,2 @@
1
- import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
2
- import { setLocaleInStorage } from "./useLocaleStorage.mjs";
3
- import { computed, inject } from "@angular/core";
4
- import configuration from "@intlayer/config/built";
5
-
6
- //#region src/client/useLocale.ts
7
- /**
8
- * Angular hook to manage the current locale and related functions.
9
- *
10
- * @param props - Optional configuration for locale management.
11
- * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.
12
- *
13
- * @example
14
- * ```ts
15
- * import { Component } from '@angular/core';
16
- * import { useLocale } from 'angular-intlayer';
17
- *
18
- * @Component({
19
- * standalone: true,
20
- * selector: 'app-locale-switcher',
21
- * template: `
22
- * <select [value]="locale()" (change)="setLocale($any($event.target).value)">
23
- * @for (loc of availableLocales; track loc) {
24
- * <option [value]="loc">{{ loc }}</option>
25
- * }
26
- * </select>
27
- * `,
28
- * })
29
- * export class LocaleSwitcher {
30
- * const { locale, setLocale, availableLocales } = useLocale();
31
- * }
32
- * ```
33
- */
34
- const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
35
- const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
36
- const intlayer = inject(INTLAYER_TOKEN);
37
- const locale = computed(() => intlayer?.locale() ?? defaultLocale);
38
- const isCookieEnabledContext = computed(() => intlayer?.isCookieEnabled() ?? true);
39
- const setLocale = (newLocale) => {
40
- if (!availableLocales?.map(String).includes(newLocale)) {
41
- console.error(`Locale ${newLocale} is not available`);
42
- return;
43
- }
44
- if (intlayer) intlayer.setLocale(newLocale);
45
- setLocaleInStorage(newLocale, isCookieEnabled ?? isCookieEnabledContext() ?? true);
46
- onLocaleChange?.(newLocale);
47
- };
48
- return {
49
- locale,
50
- defaultLocale,
51
- availableLocales,
52
- setLocale
53
- };
54
- };
55
-
56
- //#endregion
57
- export { useLocale };
1
+ import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{setLocaleInStorage as t}from"./useLocaleStorage.mjs";import{computed as n,inject as r}from"@angular/core";import i from"@intlayer/config/built";const a=({isCookieEnabled:a,onLocaleChange:o}={})=>{let{defaultLocale:s,locales:c}=i?.internationalization??{},l=r(e),u=n(()=>l?.locale()??s),d=n(()=>l?.isCookieEnabled()??!0);return{locale:u,defaultLocale:s,availableLocales:c,setLocale:e=>{if(!c?.map(String).includes(e)){console.error(`Locale ${e} is not available`);return}l&&l.setLocale(e),t(e,a??d()??!0),o?.(e)}}};export{a as useLocale};
58
2
  //# sourceMappingURL=useLocale.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9B,eAAe,wBAAwB,EAAE;CAC3C,MAAM,WAAW,OAAyB,eAAe;CAGzD,MAAM,SAAS,eAAe,UAAU,QAAQ,IAAI,cAAc;CAClE,MAAM,yBAAyB,eACvB,UAAU,iBAAiB,IAAI,KACtC;CAED,MAAM,aAAa,cAA6B;AAC9C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,MAAI,SACF,UAAS,UAAU,UAAU;AAE/B,qBACE,WACA,mBAAmB,wBAAwB,IAAI,KAChD;AACD,mBAAiB,UAAU;;AAG7B,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":"8MAsCA,MAAa,GAAa,CACxB,kBACA,kBACkB,EAAE,GAAK,CACzB,GAAM,CAAE,gBAAe,QAAS,GAC9B,GAAe,sBAAwB,EAAE,CACrC,EAAW,EAAyB,EAAe,CAGnD,EAAS,MAAe,GAAU,QAAQ,EAAI,EAAc,CAC5D,EAAyB,MACvB,GAAU,iBAAiB,EAAI,GACtC,CAkBD,MAAO,CACL,SACA,gBACA,mBACA,UApBiB,GAA6B,CAC9C,GAAI,CAAC,GAAkB,IAAI,OAAO,CAAC,SAAS,EAAU,CAAE,CACtD,QAAQ,MAAM,UAAU,EAAU,mBAAmB,CACrD,OAGE,GACF,EAAS,UAAU,EAAU,CAE/B,EACE,EACA,GAAmB,GAAwB,EAAI,GAChD,CACD,IAAiB,EAAU,EAQ5B"}
@@ -1,54 +1,2 @@
1
- import { LocaleStorage, getLocaleFromStorage, localeStorageOptions, setLocaleInStorage as setLocaleInStorage$1 } from "@intlayer/core";
2
-
3
- //#region src/client/useLocaleStorage.ts
4
- /**
5
- * Get the locale cookie
6
- */
7
- /**
8
- * Get the locale cookie
9
- */
10
- const localeInStorage = getLocaleFromStorage(localeStorageOptions);
11
- /**
12
- * @deprecated Use localeInStorage instead
13
- *
14
- * Get the locale cookie
15
- */
16
- const localeCookie = localeInStorage;
17
- /**
18
- * Set the locale cookie
19
- */
20
- const setLocaleInStorage = (locale, isCookieEnabled) => setLocaleInStorage$1(locale, {
21
- ...localeStorageOptions,
22
- isCookieEnabled
23
- });
24
- /**
25
- * @deprecated Use setLocaleInStorage instead
26
- *
27
- * Set the locale cookie
28
- */
29
- const setLocaleCookie = setLocaleInStorage;
30
- /**
31
- * Hook that provides the locale storage and a function to set it
32
- */
33
- const useLocaleStorage = (isCookieEnabled) => LocaleStorage({
34
- ...localeStorageOptions,
35
- isCookieEnabled
36
- });
37
- /**
38
- * @deprecated Use useLocaleStorage instead
39
- *
40
- * For GDPR compliance, use useLocaleStorage instead
41
- *
42
- * Hook that provides the locale cookie and a function to set it
43
- */
44
- const useLocaleCookie = (isCookieEnabled) => {
45
- const storage = useLocaleStorage(isCookieEnabled);
46
- return {
47
- localeCookie: storage.getLocale(),
48
- setLocaleCookie: storage.setLocale
49
- };
50
- };
51
-
52
- //#endregion
53
- export { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage };
1
+ import{LocaleStorage as e,getLocaleFromStorage as t,setLocaleInStorage as n}from"@intlayer/core/utils";import{localeStorageOptions as r}from"@intlayer/core/localization";const i=t(r),a=i,o=(e,t)=>n(e,{...r,isCookieEnabled:t}),s=o,c=t=>e({...r,isCookieEnabled:t}),l=e=>{let t=c(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};export{a as localeCookie,i as localeInStorage,s as setLocaleCookie,o as setLocaleInStorage,l as useLocaleCookie,c as useLocaleStorage};
54
2
  //# sourceMappingURL=useLocaleStorage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.mjs","names":["setLocaleInStorageCore"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorage,\n LocaleStorage,\n localeStorageOptions,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,kBAAkB,qBAAqB,qBAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,oBAEAA,qBAAuB,QAAQ;CAC7B,GAAG;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,oBAC/B,cAAc;CACZ,GAAG;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
1
+ {"version":3,"file":"useLocaleStorage.mjs","names":["setLocaleInStorageCore"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":"0KAcA,MAAa,EAAkB,EAAqB,EAAqB,CAM5D,EAAe,EAKf,GACX,EACA,IAEAA,EAAuB,EAAQ,CAC7B,GAAG,EACH,kBACD,CAAC,CAOS,EAAkB,EAKlB,EAAoB,GAC/B,EAAc,CACZ,GAAG,EACH,kBACD,CAAC,CASS,EAAmB,GAA8B,CAC5D,IAAM,EAAU,EAAiB,EAAgB,CAEjD,MAAO,CACL,aAAc,EAAQ,WAAW,CACjC,gBAAiB,EAAQ,UAC1B"}
@@ -1,42 +1,4 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
3
- import { ContentSelectorComponent } from "../UI/ContentSelector.component.mjs";
4
- import { useEditorEnabled } from "./editorEnabled.mjs";
5
- import { useFocusDictionary } from "./focusDictionary.mjs";
6
- import { useEditor } from "./useEditor.mjs";
7
- import { isSameKeyPath } from "@intlayer/core";
8
- import { NodeType } from "@intlayer/types";
9
- import { CommonModule } from "@angular/common";
10
- import { Component, Input, computed } from "@angular/core";
11
-
12
- //#region src/editor/ContentSelectorWrapper.component.ts
13
- let ContentSelectorWrapperComponent = class ContentSelectorWrapperComponent {
14
- dictionaryKey;
15
- keyPath;
16
- focusDictionary = useFocusDictionary();
17
- editorEnabled = useEditorEnabled();
18
- constructor() {
19
- useEditor();
20
- }
21
- isSelected = computed(() => {
22
- const focusedContent = this.focusDictionary.focusedContent();
23
- return focusedContent?.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath);
24
- });
25
- enabled = computed(() => this.editorEnabled.enabled());
26
- handleSelect() {
27
- this.focusDictionary.setFocusedContent({
28
- dictionaryKey: this.dictionaryKey,
29
- keyPath: this.keyPath.filter((key) => key.type !== NodeType.Translation)
30
- });
31
- }
32
- };
33
- __decorate([Input(), __decorateMetadata("design:type", String)], ContentSelectorWrapperComponent.prototype, "dictionaryKey", void 0);
34
- __decorate([Input(), __decorateMetadata("design:type", Array)], ContentSelectorWrapperComponent.prototype, "keyPath", void 0);
35
- ContentSelectorWrapperComponent = __decorate([Component({
36
- selector: "app-content-selector-wrapper",
37
- standalone: true,
38
- imports: [CommonModule, ContentSelectorComponent],
39
- template: `
1
+ import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";import{__decorate as t}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";import{ContentSelectorComponent as n}from"../UI/ContentSelector.component.mjs";import{useEditorEnabled as r}from"./editorEnabled.mjs";import{useFocusDictionary as i}from"./focusDictionary.mjs";import{useEditor as a}from"./useEditor.mjs";import{NodeType as o}from"@intlayer/types";import{CommonModule as s}from"@angular/common";import{Component as c,Input as l,computed as u}from"@angular/core";import{isSameKeyPath as d}from"@intlayer/core/utils";let f=class{dictionaryKey;keyPath;focusDictionary=i();editorEnabled=r();constructor(){a()}isSelected=u(()=>{let e=this.focusDictionary.focusedContent();return e?.dictionaryKey===this.dictionaryKey&&(e.keyPath?.length??0)>0&&d(e.keyPath??[],this.keyPath)});enabled=u(()=>this.editorEnabled.enabled());handleSelect(){this.focusDictionary.setFocusedContent({dictionaryKey:this.dictionaryKey,keyPath:this.keyPath.filter(e=>e.type!==o.Translation)})}};t([l(),e(`design:type`,String)],f.prototype,`dictionaryKey`,void 0),t([l(),e(`design:type`,Array)],f.prototype,`keyPath`,void 0),f=t([c({selector:`app-content-selector-wrapper`,standalone:!0,imports:[s,n],template:`
40
2
  <app-content-selector
41
3
  *ngIf="enabled()"
42
4
  (press)="handleSelect()"
@@ -45,9 +7,5 @@ ContentSelectorWrapperComponent = __decorate([Component({
45
7
  <ng-content></ng-content>
46
8
  </app-content-selector>
47
9
  <ng-content *ngIf="!enabled()"></ng-content>
48
- `
49
- }), __decorateMetadata("design:paramtypes", [])], ContentSelectorWrapperComponent);
50
-
51
- //#endregion
52
- export { ContentSelectorWrapperComponent };
10
+ `}),e(`design:paramtypes`,[])],f);export{f as ContentSelectorWrapperComponent};
53
11
  //# sourceMappingURL=ContentSelectorWrapper.component.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.component.mjs","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input } from '@angular/core';\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport { NodeType } from '@intlayer/types';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath.filter((key) => key.type !== NodeType.Translation),\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgCO,4CAAM,gCAAgC;CAC3C,AAAS;CACT,AAAS;CAGT,AAAQ,kBAAkB,oBAAoB;CAC9C,AAAQ,gBAAgB,kBAAkB;CAE1C,cAAc;AACZ,aAAW;;CAIb,aAAa,eAAe;EAC1B,MAAM,iBAAiB,KAAK,gBAAgB,gBAAgB;AAC5D,SACE,gBAAgB,kBAAkB,KAAK,kBACtC,eAAe,SAAS,UAAU,KAAK,KACxC,cAAc,eAAe,WAAW,EAAE,EAAE,KAAK,QAAQ;GAE3D;CAEF,UAAU,eAAe,KAAK,cAAc,SAAS,CAAC;CAGtD,eAAe;AACb,OAAK,gBAAgB,kBAAkB;GACrC,eAAe,KAAK;GACpB,SAAS,KAAK,QAAQ,QAAQ,QAAQ,IAAI,SAAS,SAAS,YAAY;GACzE,CAAC;;;YA5BH,OAAO;YACP,OAAO;8CAjBT,UAAU;CACT,UAAU;CACV,YAAY;CACZ,SAAS,CAAC,cAAc,yBAAyB;CACjD,UAAU;;;;;;;;;;CAUX,CAAC"}
1
+ {"version":3,"file":"ContentSelectorWrapper.component.mjs","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input } from '@angular/core';\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport { NodeType } from '@intlayer/types';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath.filter((key) => key.type !== NodeType.Translation),\n });\n }\n}\n"],"mappings":"uoBAiCO,IAAA,EAAA,KAAsC,CAC3C,cACA,QAGA,gBAA0B,GAAoB,CAC9C,cAAwB,GAAkB,CAE1C,aAAc,CACZ,GAAW,CAIb,WAAa,MAAe,CAC1B,IAAM,EAAiB,KAAK,gBAAgB,gBAAgB,CAC5D,OACE,GAAgB,gBAAkB,KAAK,gBACtC,EAAe,SAAS,QAAU,GAAK,GACxC,EAAc,EAAe,SAAW,EAAE,CAAE,KAAK,QAAQ,EAE3D,CAEF,QAAU,MAAe,KAAK,cAAc,SAAS,CAAC,CAGtD,cAAe,CACb,KAAK,gBAAgB,kBAAkB,CACrC,cAAe,KAAK,cACpB,QAAS,KAAK,QAAQ,OAAQ,GAAQ,EAAI,OAAS,EAAS,YAAY,CACzE,CAAC,MA5BH,GAAO,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,IACP,GAAO,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,MAjBT,EAAU,CACT,SAAU,+BACV,WAAY,GACZ,QAAS,CAAC,EAAc,EAAyB,CACjD,SAAU;;;;;;;;;IAUX,CAAC,CAAA,EAAA,oBAAA,EAAA,CAAA,CAAA,CAAA,EAAA"}
@@ -1,48 +1,2 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
3
- import { useEditedContentRenderer } from "./useEditedContentRenderer.mjs";
4
- import { getContent } from "@intlayer/core";
5
- import { CommonModule } from "@angular/common";
6
- import { Component, Input, computed, signal } from "@angular/core";
7
-
8
- //#region src/editor/EditedContentRenderer.component.ts
9
- let EditedContentRendererComponent = class EditedContentRendererComponent {
10
- dictionaryKey;
11
- keyPath;
12
- locale;
13
- fallback = signal("");
14
- rawContent = computed(() => {
15
- return useEditedContentRenderer(this.dictionaryKey, this.keyPath, this.fallback);
16
- });
17
- /**
18
- * Object → getContent → string, same as the React version.
19
- */
20
- renderedContent = computed(() => {
21
- const rawContentValue = this.rawContent();
22
- if (typeof rawContentValue === "object" && rawContentValue !== null) {
23
- const transformed = getContent(rawContentValue, {
24
- dictionaryKey: this.dictionaryKey,
25
- keyPath: this.keyPath
26
- }, this.locale);
27
- if (typeof transformed !== "string") {
28
- console.error(`Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(transformed)}`);
29
- return this.fallback();
30
- }
31
- return transformed;
32
- }
33
- return rawContentValue();
34
- });
35
- };
36
- __decorate([Input(), __decorateMetadata("design:type", String)], EditedContentRendererComponent.prototype, "dictionaryKey", void 0);
37
- __decorate([Input(), __decorateMetadata("design:type", Array)], EditedContentRendererComponent.prototype, "keyPath", void 0);
38
- __decorate([Input(), __decorateMetadata("design:type", Object)], EditedContentRendererComponent.prototype, "locale", void 0);
39
- EditedContentRendererComponent = __decorate([Component({
40
- selector: "app-edited-content-renderer",
41
- standalone: true,
42
- imports: [CommonModule],
43
- template: ` <span [innerHTML]="renderedContent()"></span> `
44
- })], EditedContentRendererComponent);
45
-
46
- //#endregion
47
- export { EditedContentRendererComponent };
1
+ import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";import{__decorate as t}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";import{useEditedContentRenderer as n}from"./useEditedContentRenderer.mjs";import{getContent as r}from"@intlayer/core/interpreter";import{CommonModule as i}from"@angular/common";import{Component as a,Input as o,computed as s,signal as c}from"@angular/core";let l=class{dictionaryKey;keyPath;locale;fallback=c(``);rawContent=s(()=>n(this.dictionaryKey,this.keyPath,this.fallback));renderedContent=s(()=>{let e=this.rawContent();if(typeof e==`object`&&e){let t=r(e,{dictionaryKey:this.dictionaryKey,keyPath:this.keyPath},this.locale);return typeof t==`string`?t:(console.error(`Incorrect edited content format. Content type: ${typeof t}. Expected string. Value ${JSON.stringify(t)}`),this.fallback())}return e()})};t([o(),e(`design:type`,String)],l.prototype,`dictionaryKey`,void 0),t([o(),e(`design:type`,Array)],l.prototype,`keyPath`,void 0),t([o(),e(`design:type`,Object)],l.prototype,`locale`,void 0),l=t([a({selector:`app-edited-content-renderer`,standalone:!0,imports:[i],template:` <span [innerHTML]="renderedContent()"></span> `})],l);export{l as EditedContentRendererComponent};
48
2
  //# sourceMappingURL=EditedContentRenderer.component.mjs.map