angular-intlayer 8.5.0 → 8.5.1
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.
- package/dist/cjs/@intlayer/editor/src/isEnabled.cjs +1 -1
- package/dist/cjs/@intlayer/editor/src/isEnabled.cjs.map +1 -1
- package/dist/cjs/UI/IntlayerNode.component.cjs +53 -0
- package/dist/cjs/UI/IntlayerNode.component.cjs.map +1 -0
- package/dist/cjs/UI/index.cjs +9 -0
- package/dist/cjs/client/index.cjs +4 -10
- package/dist/cjs/client/installIntlayer.cjs +19 -48
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/intlayerToken.cjs +36 -0
- package/dist/cjs/client/intlayerToken.cjs.map +1 -0
- package/dist/cjs/client/useDictionary.cjs +2 -2
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +2 -2
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +2 -2
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +2 -2
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +2 -2
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/editor/EditorProvider.component.cjs +27 -0
- package/dist/cjs/editor/EditorProvider.component.cjs.map +1 -0
- package/dist/cjs/editor/index.cjs +19 -0
- package/dist/cjs/editor/useEditor.cjs +47 -12
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/format/index.cjs +20 -0
- package/dist/cjs/format/useCompact.cjs +18 -0
- package/dist/cjs/format/useCompact.cjs.map +1 -0
- package/dist/cjs/format/useCurrency.cjs +18 -0
- package/dist/cjs/format/useCurrency.cjs.map +1 -0
- package/dist/cjs/format/useDate.cjs +28 -0
- package/dist/cjs/format/useDate.cjs.map +1 -0
- package/dist/cjs/format/useIntl.cjs +20 -0
- package/dist/cjs/format/useIntl.cjs.map +1 -0
- package/dist/cjs/format/useList.cjs +18 -0
- package/dist/cjs/format/useList.cjs.map +1 -0
- package/dist/cjs/format/useNumber.cjs +21 -0
- package/dist/cjs/format/useNumber.cjs.map +1 -0
- package/dist/cjs/format/usePercentage.cjs +18 -0
- package/dist/cjs/format/usePercentage.cjs.map +1 -0
- package/dist/cjs/format/useRelativeTime.cjs +18 -0
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -0
- package/dist/cjs/format/useUnit.cjs +18 -0
- package/dist/cjs/format/useUnit.cjs.map +1 -0
- package/dist/cjs/index.cjs +7 -6
- package/dist/cjs/renderIntlayerNode.cjs +2 -1
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/esm/@intlayer/editor/src/isEnabled.mjs +1 -1
- package/dist/esm/@intlayer/editor/src/isEnabled.mjs.map +1 -1
- package/dist/esm/UI/IntlayerNode.component.mjs +46 -0
- package/dist/esm/UI/IntlayerNode.component.mjs.map +1 -0
- package/dist/esm/UI/index.mjs +3 -0
- package/dist/esm/client/index.mjs +3 -3
- package/dist/esm/client/installIntlayer.mjs +15 -37
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/intlayerToken.mjs +31 -0
- package/dist/esm/client/intlayerToken.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -1
- package/dist/esm/editor/EditorProvider.component.mjs +20 -0
- package/dist/esm/editor/EditorProvider.component.mjs.map +1 -0
- package/dist/esm/editor/index.mjs +5 -0
- package/dist/esm/editor/useEditor.mjs +48 -14
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/format/index.mjs +11 -0
- package/dist/esm/format/useCompact.mjs +16 -0
- package/dist/esm/format/useCompact.mjs.map +1 -0
- package/dist/esm/format/useCurrency.mjs +16 -0
- package/dist/esm/format/useCurrency.mjs.map +1 -0
- package/dist/esm/format/useDate.mjs +26 -0
- package/dist/esm/format/useDate.mjs.map +1 -0
- package/dist/esm/format/useIntl.mjs +18 -0
- package/dist/esm/format/useIntl.mjs.map +1 -0
- package/dist/esm/format/useList.mjs +16 -0
- package/dist/esm/format/useList.mjs.map +1 -0
- package/dist/esm/format/useNumber.mjs +19 -0
- package/dist/esm/format/useNumber.mjs.map +1 -0
- package/dist/esm/format/usePercentage.mjs +16 -0
- package/dist/esm/format/usePercentage.mjs.map +1 -0
- package/dist/esm/format/useRelativeTime.mjs +16 -0
- package/dist/esm/format/useRelativeTime.mjs.map +1 -0
- package/dist/esm/format/useUnit.mjs +16 -0
- package/dist/esm/format/useUnit.mjs.map +1 -0
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/renderIntlayerNode.mjs +2 -1
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/types/UI/IntlayerNode.component.d.ts +27 -0
- package/dist/types/UI/IntlayerNode.component.d.ts.map +1 -0
- package/dist/types/UI/index.d.ts +2 -0
- package/dist/types/client/index.d.ts +3 -3
- package/dist/types/client/installIntlayer.d.ts +10 -21
- package/dist/types/client/installIntlayer.d.ts.map +1 -1
- package/dist/types/client/intlayerToken.d.ts +19 -0
- package/dist/types/client/intlayerToken.d.ts.map +1 -0
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +3 -3
- package/dist/types/client/useLocaleStorage.d.ts +5 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.component.d.ts +33 -0
- package/dist/types/editor/EditorProvider.component.d.ts.map +1 -0
- package/dist/types/editor/index.d.ts +4 -0
- package/dist/types/editor/useEditor.d.ts +35 -2
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/format/index.d.ts +10 -0
- package/dist/types/format/useCompact.d.ts +10 -0
- package/dist/types/format/useCompact.d.ts.map +1 -0
- package/dist/types/format/useCurrency.d.ts +10 -0
- package/dist/types/format/useCurrency.d.ts.map +1 -0
- package/dist/types/format/useDate.d.ts +14 -0
- package/dist/types/format/useDate.d.ts.map +1 -0
- package/dist/types/format/useIntl.d.ts +12 -0
- package/dist/types/format/useIntl.d.ts.map +1 -0
- package/dist/types/format/useList.d.ts +14 -0
- package/dist/types/format/useList.d.ts.map +1 -0
- package/dist/types/format/useNumber.d.ts +13 -0
- package/dist/types/format/useNumber.d.ts.map +1 -0
- package/dist/types/format/usePercentage.d.ts +10 -0
- package/dist/types/format/usePercentage.d.ts.map +1 -0
- package/dist/types/format/useRelativeTime.d.ts +11 -0
- package/dist/types/format/useRelativeTime.d.ts.map +1 -0
- package/dist/types/format/useUnit.d.ts +10 -0
- package/dist/types/format/useUnit.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/intlayer/dist/types/index.d.ts +4 -0
- package/package.json +32 -8
- package/dist/cjs/client/useIntl.cjs +0 -41
- package/dist/cjs/client/useIntl.cjs.map +0 -1
- package/dist/esm/client/useIntl.mjs +0 -39
- package/dist/esm/client/useIntl.mjs.map +0 -1
- package/dist/types/client/useIntl.d.ts +0 -33
- package/dist/types/client/useIntl.d.ts.map +0 -1
|
@@ -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 {
|
|
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/module_augmentation';\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(\n () => getIntlayer<T, L>(key, localeTarget() as L) as any\n );\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;AAQhE,QAJgB,eACR,YAAkB,KAAK,cAAc,CAAM,CAClD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN } from "./
|
|
1
|
+
import { INTLAYER_TOKEN } from "./intlayerToken.mjs";
|
|
2
2
|
import { setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
3
3
|
import configuration from "@intlayer/config/built";
|
|
4
4
|
import { computed, inject } from "@angular/core";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
|
|
3
|
+
import { useEditor } from "./useEditor.mjs";
|
|
4
|
+
import { Component } from "@angular/core";
|
|
5
|
+
|
|
6
|
+
//#region src/editor/EditorProvider.component.ts
|
|
7
|
+
let EditorProviderComponent = class EditorProviderComponent {
|
|
8
|
+
constructor() {
|
|
9
|
+
useEditor();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
EditorProviderComponent = __decorate([Component({
|
|
13
|
+
selector: "intlayer-editor-provider",
|
|
14
|
+
standalone: true,
|
|
15
|
+
template: `<ng-content />`
|
|
16
|
+
}), __decorateMetadata("design:paramtypes", [])], EditorProviderComponent);
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { EditorProviderComponent };
|
|
20
|
+
//# sourceMappingURL=EditorProvider.component.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorProvider.component.mjs","names":[],"sources":["../../../src/editor/EditorProvider.component.ts"],"sourcesContent":["import { Component } from '@angular/core';\nimport { useEditor } from './useEditor';\n\n/**\n * Drop-in Angular equivalent of React's `EditorProvider`.\n *\n * Wrap your root component (or any subtree) with this component to automatically\n * start the Intlayer editor client. The editor will be started on mount and\n * stopped when this component is destroyed.\n *\n * @example\n * ```html\n * <!-- app.component.html -->\n * <intlayer-editor-provider>\n * <router-outlet />\n * </intlayer-editor-provider>\n * ```\n *\n * ```ts\n * // app.component.ts\n * import { EditorProviderComponent } from 'angular-intlayer';\n *\n * @Component({\n * imports: [EditorProviderComponent],\n * …\n * })\n * export class AppComponent {}\n * ```\n */\n@Component({\n selector: 'intlayer-editor-provider',\n standalone: true,\n template: `<ng-content />`,\n})\nexport class EditorProviderComponent {\n constructor() {\n useEditor();\n }\n}\n"],"mappings":";;;;;;AAkCO,oCAAM,wBAAwB;CACnC,cAAc;AACZ,aAAW;;;sCAPd,UAAU;CACT,UAAU;CACV,YAAY;CACZ,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ContentSelectorWrapperComponent } from "./ContentSelector.component.mjs";
|
|
2
|
+
import { provideIntlayerEditor, useEditor } from "./useEditor.mjs";
|
|
3
|
+
import { EditorProviderComponent } from "./EditorProvider.component.mjs";
|
|
4
|
+
|
|
5
|
+
export { ContentSelectorWrapperComponent, EditorProviderComponent, provideIntlayerEditor, useEditor };
|
|
@@ -1,30 +1,64 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN } from "../client/
|
|
2
|
-
import { DestroyRef, Injector, effect, inject, runInInjectionContext } from "@angular/core";
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { DestroyRef, Injector, effect, inject, provideAppInitializer, runInInjectionContext, signal } from "@angular/core";
|
|
3
3
|
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
4
4
|
|
|
5
5
|
//#region src/editor/useEditor.ts
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Initialises the Intlayer editor client singleton when the editor is enabled.
|
|
8
|
+
* Syncs the current locale from the provided Intlayer client into the editor
|
|
9
|
+
* manager so the editor always knows which locale the app is displaying.
|
|
10
|
+
*
|
|
11
|
+
* Must be called inside an Angular injection context (e.g. a component
|
|
12
|
+
* constructor, `provideAppInitializer`, or `runInInjectionContext`).
|
|
13
|
+
*
|
|
14
|
+
* @param client - The IntlayerProvider instance to sync locale from.
|
|
15
|
+
* When omitted the function injects `INTLAYER_TOKEN` from the DI tree,
|
|
16
|
+
* so it still works when called directly from a component.
|
|
17
|
+
*/
|
|
18
|
+
const useEditor = (client) => {
|
|
19
|
+
if (!isEnabled) return;
|
|
8
20
|
const destroyRef = inject(DestroyRef, { optional: true });
|
|
9
|
-
const client = inject(INTLAYER_TOKEN, { optional: true });
|
|
10
21
|
const injector = inject(Injector);
|
|
22
|
+
const resolvedClient = client ?? inject(INTLAYER_TOKEN, { optional: true });
|
|
23
|
+
const manager = signal(null);
|
|
24
|
+
let stopped = false;
|
|
11
25
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const effectRef = runInInjectionContext(injector, () => effect(() => {
|
|
15
|
-
const locale = client.locale();
|
|
16
|
-
if (locale) manager.currentLocale.set(locale);
|
|
17
|
-
}));
|
|
18
|
-
destroyRef?.onDestroy(() => effectRef.destroy());
|
|
19
|
-
}
|
|
26
|
+
if (stopped) return;
|
|
27
|
+
manager.set(initEditorClient());
|
|
20
28
|
});
|
|
29
|
+
const effectRef = runInInjectionContext(injector, () => effect(() => {
|
|
30
|
+
const m = manager();
|
|
31
|
+
const locale = resolvedClient?.locale();
|
|
32
|
+
if (m && locale) m.currentLocale.set(locale);
|
|
33
|
+
}));
|
|
21
34
|
destroyRef?.onDestroy(() => {
|
|
35
|
+
stopped = true;
|
|
36
|
+
effectRef.destroy();
|
|
37
|
+
manager.set(null);
|
|
22
38
|
import("@intlayer/editor").then(({ stopEditorClient }) => {
|
|
23
39
|
stopEditorClient();
|
|
24
40
|
});
|
|
25
41
|
});
|
|
26
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Angular provider that wires `useEditor` into the application initialisation
|
|
45
|
+
* phase via `provideAppInitializer`.
|
|
46
|
+
*
|
|
47
|
+
* `provideIntlayer()` already calls this internally, so you only need this
|
|
48
|
+
* function when you want to manage providers individually.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // app.config.ts
|
|
53
|
+
* import { provideIntlayer, provideIntlayerEditor } from 'angular-intlayer';
|
|
54
|
+
*
|
|
55
|
+
* export const appConfig: ApplicationConfig = {
|
|
56
|
+
* providers: [provideIntlayer(), provideIntlayerEditor()],
|
|
57
|
+
* };
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const provideIntlayerEditor = (client) => provideAppInitializer(() => useEditor(client));
|
|
27
61
|
|
|
28
62
|
//#endregion
|
|
29
|
-
export { useEditor };
|
|
63
|
+
export { provideIntlayerEditor, useEditor };
|
|
30
64
|
//# sourceMappingURL=useEditor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (
|
|
1
|
+
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n provideAppInitializer,\n runInInjectionContext,\n signal,\n} from '@angular/core';\nimport type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\n// Import from the standalone token file to avoid a circular dependency:\n// installIntlayer.ts → useEditor.ts → ../client → installIntlayer.ts\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client/intlayerToken';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the provided Intlayer client into the editor\n * manager so the editor always knows which locale the app is displaying.\n *\n * Must be called inside an Angular injection context (e.g. a component\n * constructor, `provideAppInitializer`, or `runInInjectionContext`).\n *\n * @param client - The IntlayerProvider instance to sync locale from.\n * When omitted the function injects `INTLAYER_TOKEN` from the DI tree,\n * so it still works when called directly from a component.\n */\nexport const useEditor = (client?: IntlayerProvider | null): void => {\n if (!isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const injector = inject(Injector);\n\n // Resolve the client: use the passed-in reference or fall back to injection.\n const resolvedClient =\n client ??\n inject<IntlayerProvider>(INTLAYER_TOKEN, { optional: true } as any);\n\n // `manager` signal is set once the async import resolves.\n // Using a signal lets an `effect()` react to it becoming available.\n const manager = signal<EditorStateManager | null>(null);\n\n // Guard: prevents the async callback from acting after the view is destroyed.\n let stopped = false;\n\n // Initialise the editor client\n import('@intlayer/editor').then(({ initEditorClient }) => {\n if (stopped) return;\n manager.set(initEditorClient());\n });\n\n // Keep the editor locale in sync with the Angular locale signal\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const m = manager();\n const locale = resolvedClient?.locale();\n if (m && locale) m.currentLocale.set(locale as Locale);\n })\n );\n\n // Tear down on destroy\n destroyRef?.onDestroy(() => {\n stopped = true;\n effectRef.destroy();\n manager.set(null);\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n\n/**\n * Angular provider that wires `useEditor` into the application initialisation\n * phase via `provideAppInitializer`.\n *\n * `provideIntlayer()` already calls this internally, so you only need this\n * function when you want to manage providers individually.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { provideIntlayer, provideIntlayerEditor } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [provideIntlayer(), provideIntlayerEditor()],\n * };\n * ```\n */\nexport const provideIntlayerEditor = (client?: IntlayerProvider | null) =>\n provideAppInitializer(() => useEditor(client));\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,WAA2C;AACnE,KAAI,CAAC,UAAW;CAEhB,MAAM,aAAa,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC;CACzD,MAAM,WAAW,OAAO,SAAS;CAGjC,MAAM,iBACJ,UACA,OAAyB,gBAAgB,EAAE,UAAU,MAAM,CAAQ;CAIrE,MAAM,UAAU,OAAkC,KAAK;CAGvD,IAAI,UAAU;AAGd,QAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,MAAI,QAAS;AACb,UAAQ,IAAI,kBAAkB,CAAC;GAC/B;CAGF,MAAM,YAAY,sBAAsB,gBACtC,aAAa;EACX,MAAM,IAAI,SAAS;EACnB,MAAM,SAAS,gBAAgB,QAAQ;AACvC,MAAI,KAAK,OAAQ,GAAE,cAAc,IAAI,OAAiB;GACtD,CACH;AAGD,aAAY,gBAAgB;AAC1B,YAAU;AACV,YAAU,SAAS;AACnB,UAAQ,IAAI,KAAK;AACjB,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,qBAAkB;IAClB;GACF;;;;;;;;;;;;;;;;;;;AAoBJ,MAAa,yBAAyB,WACpC,4BAA4B,UAAU,OAAO,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useUnit } from "./useUnit.mjs";
|
|
2
|
+
import { useDate } from "./useDate.mjs";
|
|
3
|
+
import { useNumber } from "./useNumber.mjs";
|
|
4
|
+
import { useRelativeTime } from "./useRelativeTime.mjs";
|
|
5
|
+
import { useCompact } from "./useCompact.mjs";
|
|
6
|
+
import { useIntl } from "./useIntl.mjs";
|
|
7
|
+
import { useList } from "./useList.mjs";
|
|
8
|
+
import { usePercentage } from "./usePercentage.mjs";
|
|
9
|
+
import { useCurrency } from "./useCurrency.mjs";
|
|
10
|
+
|
|
11
|
+
export { useCompact, useCurrency, useDate, useIntl, useList, useNumber, usePercentage, useRelativeTime, useUnit };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { compact } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useCompact.ts
|
|
6
|
+
const useCompact = () => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
return computed(() => (...args) => compact(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useCompact };
|
|
16
|
+
//# sourceMappingURL=useCompact.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { compact } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\nexport const useCompact = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,mBAAmB;CAC9B,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { currency } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useCurrency.ts
|
|
6
|
+
const useCurrency = () => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
return computed(() => (...args) => currency(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useCurrency };
|
|
16
|
+
//# sourceMappingURL=useCurrency.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { currency } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\nexport const useCurrency = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,oBAAoB;CAC/B,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { date, presets } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useDate.ts
|
|
6
|
+
/**
|
|
7
|
+
* Angular client hook that provides a localized date/time formatter.
|
|
8
|
+
*/
|
|
9
|
+
const useDate = () => {
|
|
10
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
11
|
+
return computed(() => (...args) => {
|
|
12
|
+
const locale = intlayer.locale();
|
|
13
|
+
const options = typeof args[1] === "string" ? {
|
|
14
|
+
...presets[args[1]],
|
|
15
|
+
locale
|
|
16
|
+
} : {
|
|
17
|
+
...args[1],
|
|
18
|
+
locale: args[1]?.locale ?? locale
|
|
19
|
+
};
|
|
20
|
+
return date(args[0], options);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useDate };
|
|
26
|
+
//# sourceMappingURL=useDate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { date, presets } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\n/**\n * Angular client hook that provides a localized date/time formatter.\n */\nexport const useDate = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(() => (...args: Parameters<typeof date>) => {\n const locale = intlayer.locale();\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n });\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,gBAAgB;CAC3B,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAAgB,GAAG,SAAkC;EAC1D,MAAM,SAAS,SAAS,QAAQ;EAChC,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAK;GAAQ,GAC/B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,IAAI,UAAU;GAAQ;AAEvD,SAAO,KAAK,KAAK,IAAI,QAAsC;GAC3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { bindIntl } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useIntl.ts
|
|
6
|
+
/**
|
|
7
|
+
* Angular composable that provides a locale-bound `Intl` object as a Signal.
|
|
8
|
+
*/
|
|
9
|
+
const useIntl = (locale) => {
|
|
10
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
11
|
+
return computed(() => {
|
|
12
|
+
return bindIntl(locale ?? intlayer.locale());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useIntl };
|
|
18
|
+
//# sourceMappingURL=useIntl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object as a Signal.\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,WAAW,WAA2B;CACjD,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,eAA4B;AAGjC,SAAO,SAFe,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { list } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useList.ts
|
|
6
|
+
const useList = () => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
return computed(() => (...args) => list(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useList };
|
|
16
|
+
//# sourceMappingURL=useList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { list } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\nexport const useList = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,gBAAgB;CAC3B,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { number } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useNumber.ts
|
|
6
|
+
/**
|
|
7
|
+
* Angular client hook that provides a localized number formatter.
|
|
8
|
+
*/
|
|
9
|
+
const useNumber = () => {
|
|
10
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
11
|
+
return computed(() => (...args) => number(args[0], {
|
|
12
|
+
...args[1],
|
|
13
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { useNumber };
|
|
19
|
+
//# sourceMappingURL=useNumber.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { number } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\n/**\n * Angular client hook that provides a localized number formatter.\n */\nexport const useNumber = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,kBAAkB;CAC7B,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { percentage } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/usePercentage.ts
|
|
6
|
+
const usePercentage = () => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
return computed(() => (...args) => percentage(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { usePercentage };
|
|
16
|
+
//# sourceMappingURL=usePercentage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { percentage } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\nexport const usePercentage = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,sBAAsB;CACjC,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { relativeTime } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useRelativeTime.ts
|
|
6
|
+
const useRelativeTime = () => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
return computed(() => (...args) => relativeTime(args[0], args[1], {
|
|
9
|
+
...args[2],
|
|
10
|
+
locale: args[2]?.locale ?? intlayer.locale()
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useRelativeTime };
|
|
16
|
+
//# sourceMappingURL=useRelativeTime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { relativeTime } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\nexport const useRelativeTime = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,wBAAwB;CACnC,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,aAAa,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN } from "../client/intlayerToken.mjs";
|
|
2
|
+
import { computed, inject } from "@angular/core";
|
|
3
|
+
import { units } from "@intlayer/core/formatters";
|
|
4
|
+
|
|
5
|
+
//#region src/format/useUnit.ts
|
|
6
|
+
const useUnit = () => {
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
return computed(() => (...args) => units(args[0], {
|
|
9
|
+
...args[1],
|
|
10
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useUnit };
|
|
16
|
+
//# sourceMappingURL=useUnit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { units } from '@intlayer/core/formatters';\nimport { INTLAYER_TOKEN } from '../client/installIntlayer';\n\nexport const useUnit = () => {\n const intlayer = inject(INTLAYER_TOKEN);\n\n return computed(\n () =>\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? intlayer.locale(),\n })\n );\n};\n"],"mappings":";;;;;AAIA,MAAa,gBAAgB;CAC3B,MAAM,WAAW,OAAO,eAAe;AAEvC,QAAO,gBAEF,GAAG,SACF,MAAM,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.mjs";
|
|
2
2
|
import { getIntlayer } from "./getIntlayer.mjs";
|
|
3
3
|
import { getDictionary } from "./getDictionary.mjs";
|
|
4
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient
|
|
4
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./client/intlayerToken.mjs";
|
|
5
|
+
import { installIntlayer, provideIntlayer } from "./client/installIntlayer.mjs";
|
|
5
6
|
import { useDictionary } from "./client/useDictionary.mjs";
|
|
6
7
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
|
|
7
8
|
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
8
9
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
|
|
9
|
-
import { useIntl } from "./client/useIntl.mjs";
|
|
10
10
|
import { isUpdatableNode, useIntlayer } from "./client/useIntlayer.mjs";
|
|
11
11
|
import { useLocale } from "./client/useLocale.mjs";
|
|
12
|
+
import { IntlayerNodeComponent } from "./UI/IntlayerNode.component.mjs";
|
|
12
13
|
|
|
13
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, getDictionary, getIntlayer, getPlugins, htmlPlugin, insertionPlugin, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic,
|
|
14
|
+
export { INTLAYER_TOKEN, IntlayerNodeComponent, IntlayerProvider, createIntlayerClient, getDictionary, getIntlayer, getPlugins, htmlPlugin, insertionPlugin, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -5,7 +5,8 @@ const renderIntlayerNode = ({ children, value, additionalProps = {} }) => {
|
|
|
5
5
|
if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
|
|
6
6
|
return Reflect.get(target, prop, receiver);
|
|
7
7
|
} });
|
|
8
|
-
|
|
8
|
+
const target = typeof children === "object" || typeof children === "function" ? children : {};
|
|
9
|
+
return new Proxy(target, {
|
|
9
10
|
apply(target, thisArg, argumentsList) {
|
|
10
11
|
if (typeof value === "function") return Reflect.apply(value, thisArg, argumentsList);
|
|
11
12
|
return Reflect.apply(target, thisArg, argumentsList);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderIntlayerNode.mjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string, AdditionalProps = {}> = ResolvedEditor<\n T,\n any\n> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\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 null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\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\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(
|
|
1
|
+
{"version":3,"file":"renderIntlayerNode.mjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string, AdditionalProps = {}> = ResolvedEditor<\n T,\n any\n> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\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 null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\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\n // Proxy target must be an object or function; wrap primitives\n const target =\n typeof children === 'object' || typeof children === 'function'\n ? children\n : ({} as any);\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(target, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\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":";AAeA,MAAa,sBAEX,EACA,UACA,OACA,kBAAkB,EAAE,OAC6B;AAEjD,KAAI,YAAY,KACd,QAAO,IAAI,MAAM,EAAE,EAAS,EAC1B,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;CAIJ,MAAM,SACJ,OAAO,aAAa,YAAY,OAAO,aAAa,aAChD,WACC,EAAE;AAIT,QAAO,IAAI,MAAM,QAAQ;EACvB,MAAM,QAAQ,SAAS,eAAe;AACpC,OAAI,OAAO,UAAU,WACnB,QAAO,QAAQ,MAAM,OAAmB,SAAS,cAAc;AAEjE,UAAO,QAAQ,MAAM,QAAoB,SAAS,cAAc;;EAElE,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,WACX,cAAa;AAEX,WAAO,OAAO,MAAM;;AAIxB,OAAI,SAAS,OAAO,YAClB,cAAa;AAGf,OACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;;EAE7C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OnChanges, SimpleChanges } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/UI/IntlayerNode.component.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A transparent host element that renders Intlayer content nodes.
|
|
6
|
+
*
|
|
7
|
+
* `display: contents` makes the `<intlayer-node>` element invisible in the
|
|
8
|
+
* layout — its children appear as if they were direct children of the parent,
|
|
9
|
+
* so placing this component inside `<h1>`, `<p>`, etc. does not break the
|
|
10
|
+
* document structure.
|
|
11
|
+
*
|
|
12
|
+
* ### Usage
|
|
13
|
+
* ```html
|
|
14
|
+
* <h1><intlayer-node [node]="content().title"></intlayer-node></h1>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare class IntlayerNodeComponent implements OnChanges {
|
|
18
|
+
node: any;
|
|
19
|
+
private vcr;
|
|
20
|
+
private elRef;
|
|
21
|
+
private cdr;
|
|
22
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
23
|
+
private render;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { IntlayerNodeComponent };
|
|
27
|
+
//# sourceMappingURL=IntlayerNode.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerNode.component.d.ts","names":[],"sources":["../../../src/UI/IntlayerNode.component.ts"],"mappings":";;;;;AAyBA;;;;;;;;;;;cASa,qBAAA,YAAiC,SAAA;EACnC,IAAA;EAAA,QAED,GAAA;EAAA,QACA,KAAA;EAAA,QACA,GAAA;EAER,WAAA,CAAY,OAAA,EAAS,aAAA;EAAA,QAMb,MAAA;AAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./intlayerToken.js";
|
|
2
|
+
import { installIntlayer, provideIntlayer } from "./installIntlayer.js";
|
|
2
3
|
import { useDictionary } from "./useDictionary.js";
|
|
3
4
|
import { useDictionaryAsync } from "./useDictionaryAsync.js";
|
|
4
5
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
5
|
-
import { useIntl } from "./useIntl.js";
|
|
6
6
|
import { isUpdatableNode, useIntlayer } from "./useIntlayer.js";
|
|
7
7
|
import { useLoadDynamic } from "./useLoadDynamic.js";
|
|
8
8
|
import { useLocale } from "./useLocale.js";
|
|
9
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic,
|
|
9
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./intlayerToken.js";
|
|
1
2
|
import * as _angular_core0 from "@angular/core";
|
|
2
|
-
import { InjectionToken, Signal } from "@angular/core";
|
|
3
3
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
4
|
|
|
5
5
|
//#region src/client/installIntlayer.d.ts
|
|
6
|
-
declare const INTLAYER_TOKEN: InjectionToken<IntlayerProvider>;
|
|
7
|
-
declare class IntlayerProvider {
|
|
8
|
-
isCookieEnabled: _angular_core0.WritableSignal<boolean>;
|
|
9
|
-
private _locale;
|
|
10
|
-
readonly locale: Signal<LocalesValues>;
|
|
11
|
-
setLocale: (locale: LocalesValues) => void;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Create and return a single IntlayerProvider instance
|
|
15
|
-
*/
|
|
16
|
-
declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerProvider;
|
|
17
6
|
/**
|
|
18
7
|
* Provides Intlayer to your Angular application.
|
|
19
8
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
9
|
+
* Registers the Intlayer locale token **and** automatically starts the Intlayer
|
|
10
|
+
* editor client (when the editor is enabled) via `provideAppInitializer`.
|
|
11
|
+
*
|
|
12
|
+
* This is the recommended way to set up Intlayer in `app.config.ts`.
|
|
22
13
|
*
|
|
23
14
|
* @param locale - Initial locale to use.
|
|
24
15
|
* @param isCookieEnabled - Whether to store the locale in cookies.
|
|
25
|
-
* @returns
|
|
16
|
+
* @returns An array of Angular providers for Intlayer.
|
|
26
17
|
*
|
|
27
18
|
* @example
|
|
28
19
|
* ```ts
|
|
@@ -31,16 +22,14 @@ declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: b
|
|
|
31
22
|
* import { provideIntlayer } from 'angular-intlayer';
|
|
32
23
|
*
|
|
33
24
|
* export const appConfig: ApplicationConfig = {
|
|
34
|
-
* providers: [
|
|
35
|
-
* provideIntlayer({ locale: 'en' }),
|
|
36
|
-
* ],
|
|
25
|
+
* providers: [provideIntlayer()],
|
|
37
26
|
* };
|
|
38
27
|
* ```
|
|
39
28
|
*/
|
|
40
|
-
declare const provideIntlayer: (locale?: LocalesValues, isCookieEnabled?: boolean) => {
|
|
41
|
-
provide: InjectionToken<IntlayerProvider>;
|
|
29
|
+
declare const provideIntlayer: (locale?: LocalesValues, isCookieEnabled?: boolean) => (_angular_core0.EnvironmentProviders | {
|
|
30
|
+
provide: _angular_core0.InjectionToken<IntlayerProvider>;
|
|
42
31
|
useValue: IntlayerProvider;
|
|
43
|
-
};
|
|
32
|
+
})[];
|
|
44
33
|
/**
|
|
45
34
|
* Helper to install the Intlayer provider.
|
|
46
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.d.ts","names":[],"sources":["../../../src/client/installIntlayer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayer.d.ts","names":[],"sources":["../../../src/client/installIntlayer.ts"],"mappings":";;;;;;;AAiCA;;;;;;;;;;;;;;;;;;;;;cAAa,eAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,gBADsB,cAAA,CACA,oBAAA;;;;;;;cAaX,eAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,eAAsB,gBAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as _angular_core0 from "@angular/core";
|
|
2
|
+
import { InjectionToken, Signal } from "@angular/core";
|
|
3
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
+
|
|
5
|
+
//#region src/client/intlayerToken.d.ts
|
|
6
|
+
declare class IntlayerProvider {
|
|
7
|
+
isCookieEnabled: _angular_core0.WritableSignal<boolean>;
|
|
8
|
+
private _locale;
|
|
9
|
+
readonly locale: Signal<LocalesValues>;
|
|
10
|
+
setLocale: (locale: LocalesValues) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const INTLAYER_TOKEN: InjectionToken<IntlayerProvider>;
|
|
13
|
+
/**
|
|
14
|
+
* Create and return a single IntlayerProvider instance
|
|
15
|
+
*/
|
|
16
|
+
declare const createIntlayerClient: (locale?: LocalesValues, isCookieEnabled?: boolean) => IntlayerProvider;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient };
|
|
19
|
+
//# sourceMappingURL=intlayerToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerToken.d.ts","names":[],"sources":["../../../src/client/intlayerToken.ts"],"mappings":";;;;;cAIa,gBAAA;EACX,eAAA,EAD2B,cAAA,CACZ,cAAA;EAAA,QACP,OAAA;EAAA,SAIC,MAAA,EAAQ,MAAA,CAAO,aAAA;EAExB,SAAA,GAAa,MAAA,EAAQ,aAAA;AAAA;AAAA,cAKV,cAAA,EAAc,cAAA,CAAA,gBAAA;;;;cAUd,oBAAA,GACX,MAAA,GAAS,aAAA,EACT,eAAA,eACC,gBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"mappings":";;;;;;;;AAiBA;;cAAa,kBAAA,aAAsC,UAAA,EACjD,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,MAAA,GAAS,aAAA,KAAa,OAAA,CAAA,cAAA,CAAA,MAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
|
|
2
|
+
import { Locale } from "../intlayer/dist/types/index.js";
|
|
2
3
|
import * as _angular_core0 from "@angular/core";
|
|
3
4
|
import { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
4
5
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
5
6
|
import * as _intlayer_core_interpreter0 from "@intlayer/core/interpreter";
|
|
6
|
-
import * as _intlayer_types_allLocales0 from "@intlayer/types/allLocales";
|
|
7
7
|
|
|
8
8
|
//#region src/client/useDictionaryDynamic.d.ts
|
|
9
9
|
/**
|
|
@@ -11,7 +11,7 @@ import * as _intlayer_types_allLocales0 from "@intlayer/types/allLocales";
|
|
|
11
11
|
*
|
|
12
12
|
* If the locale is not provided, it will use the locale from the client context
|
|
13
13
|
*/
|
|
14
|
-
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _angular_core0.Signal<_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1,
|
|
14
|
+
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _angular_core0.Signal<_intlayer_core_interpreter0.DeepTransformContent<T["content"], IInterpreterPluginState$1, Locale>>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { useDictionaryDynamic };
|
|
17
17
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;;;;cAmBa,oBAAA,aACD,UAAA,YACA,cAAA,EAEV,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KAAa,cAAA,CAAA,MAAA,CAAA,2BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;cAWa,eAAA,GACX,GAAA,cACC,GAAA;EAAS,QAAA,GAAW,CAAA;AAAA;;;;;;;;;AA8BvB;;;;;;;;;;;;;;;;;cAAa,WAAA,aAAyB,cAAA,YAA0B,aAAA,EAC9D,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KACR,MAAA,CAAO,oBAAA,CAAqB,yBAAA,CAA0B,CAAA"}
|