angular-intlayer 8.5.0 → 8.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.map +1 -1
- package/dist/types/client/useIntlayer.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/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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_format_useUnit = require('./useUnit.cjs');
|
|
3
|
+
const require_format_useDate = require('./useDate.cjs');
|
|
4
|
+
const require_format_useNumber = require('./useNumber.cjs');
|
|
5
|
+
const require_format_useRelativeTime = require('./useRelativeTime.cjs');
|
|
6
|
+
const require_format_useCompact = require('./useCompact.cjs');
|
|
7
|
+
const require_format_useIntl = require('./useIntl.cjs');
|
|
8
|
+
const require_format_useList = require('./useList.cjs');
|
|
9
|
+
const require_format_usePercentage = require('./usePercentage.cjs');
|
|
10
|
+
const require_format_useCurrency = require('./useCurrency.cjs');
|
|
11
|
+
|
|
12
|
+
exports.useCompact = require_format_useCompact.useCompact;
|
|
13
|
+
exports.useCurrency = require_format_useCurrency.useCurrency;
|
|
14
|
+
exports.useDate = require_format_useDate.useDate;
|
|
15
|
+
exports.useIntl = require_format_useIntl.useIntl;
|
|
16
|
+
exports.useList = require_format_useList.useList;
|
|
17
|
+
exports.useNumber = require_format_useNumber.useNumber;
|
|
18
|
+
exports.usePercentage = require_format_usePercentage.usePercentage;
|
|
19
|
+
exports.useRelativeTime = require_format_useRelativeTime.useRelativeTime;
|
|
20
|
+
exports.useUnit = require_format_useUnit.useUnit;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useCompact.ts
|
|
8
|
+
const useCompact = () => {
|
|
9
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.compact)(args[0], {
|
|
11
|
+
...args[1],
|
|
12
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useCompact = useCompact;
|
|
18
|
+
//# sourceMappingURL=useCompact.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCompact.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,gDACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useCurrency.ts
|
|
8
|
+
const useCurrency = () => {
|
|
9
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.currency)(args[0], {
|
|
11
|
+
...args[1],
|
|
12
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useCurrency = useCurrency;
|
|
18
|
+
//# sourceMappingURL=useCurrency.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrency.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,iDACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useDate.ts
|
|
8
|
+
/**
|
|
9
|
+
* Angular client hook that provides a localized date/time formatter.
|
|
10
|
+
*/
|
|
11
|
+
const useDate = () => {
|
|
12
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
13
|
+
return (0, _angular_core.computed)(() => (...args) => {
|
|
14
|
+
const locale = intlayer.locale();
|
|
15
|
+
const options = typeof args[1] === "string" ? {
|
|
16
|
+
..._intlayer_core_formatters.presets[args[1]],
|
|
17
|
+
locale
|
|
18
|
+
} : {
|
|
19
|
+
...args[1],
|
|
20
|
+
locale: args[1]?.locale ?? locale
|
|
21
|
+
};
|
|
22
|
+
return (0, _intlayer_core_formatters.date)(args[0], options);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.useDate = useDate;
|
|
28
|
+
//# sourceMappingURL=useDate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDate.cjs","names":["INTLAYER_TOKEN","presets"],"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,qCAAkBA,4CAAe;AAEvC,2CAAuB,GAAG,SAAkC;EAC1D,MAAM,SAAS,SAAS,QAAQ;EAChC,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAK;GAAQ,GAC/B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,IAAI,UAAU;GAAQ;AAEvD,6CAAY,KAAK,IAAI,QAAsC;GAC3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useIntl.ts
|
|
8
|
+
/**
|
|
9
|
+
* Angular composable that provides a locale-bound `Intl` object as a Signal.
|
|
10
|
+
*/
|
|
11
|
+
const useIntl = (locale) => {
|
|
12
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
13
|
+
return (0, _angular_core.computed)(() => {
|
|
14
|
+
return (0, _intlayer_core_formatters.bindIntl)(locale ?? intlayer.locale());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.useIntl = useIntl;
|
|
20
|
+
//# sourceMappingURL=useIntl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,0CAAmC;AAGjC,iDAFsB,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useList.ts
|
|
8
|
+
const useList = () => {
|
|
9
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.list)(args[0], {
|
|
11
|
+
...args[1],
|
|
12
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useList = useList;
|
|
18
|
+
//# sourceMappingURL=useList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useList.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,6CACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useNumber.ts
|
|
8
|
+
/**
|
|
9
|
+
* Angular client hook that provides a localized number formatter.
|
|
10
|
+
*/
|
|
11
|
+
const useNumber = () => {
|
|
12
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
13
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.number)(args[0], {
|
|
14
|
+
...args[1],
|
|
15
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.useNumber = useNumber;
|
|
21
|
+
//# sourceMappingURL=useNumber.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumber.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,+CACK,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/usePercentage.ts
|
|
8
|
+
const usePercentage = () => {
|
|
9
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.percentage)(args[0], {
|
|
11
|
+
...args[1],
|
|
12
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.usePercentage = usePercentage;
|
|
18
|
+
//# sourceMappingURL=usePercentage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePercentage.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,mDACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useRelativeTime.ts
|
|
8
|
+
const useRelativeTime = () => {
|
|
9
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.relativeTime)(args[0], args[1], {
|
|
11
|
+
...args[2],
|
|
12
|
+
locale: args[2]?.locale ?? intlayer.locale()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useRelativeTime = useRelativeTime;
|
|
18
|
+
//# sourceMappingURL=useRelativeTime.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRelativeTime.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,qDACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_intlayerToken = require('../client/intlayerToken.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
6
|
+
|
|
7
|
+
//#region src/format/useUnit.ts
|
|
8
|
+
const useUnit = () => {
|
|
9
|
+
const intlayer = (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN);
|
|
10
|
+
return (0, _angular_core.computed)(() => (...args) => (0, _intlayer_core_formatters.units)(args[0], {
|
|
11
|
+
...args[1],
|
|
12
|
+
locale: args[1]?.locale ?? intlayer.locale()
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useUnit = useUnit;
|
|
18
|
+
//# sourceMappingURL=useUnit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUnit.cjs","names":["INTLAYER_TOKEN"],"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,qCAAkBA,4CAAe;AAEvC,2CAEK,GAAG,8CACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,SAAS,QAAQ;EAC7C,CAAC,CACP"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,23 +2,25 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_plugins = require('./plugins.cjs');
|
|
3
3
|
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
4
4
|
const require_getDictionary = require('./getDictionary.cjs');
|
|
5
|
+
const require_client_intlayerToken = require('./client/intlayerToken.cjs');
|
|
5
6
|
const require_client_installIntlayer = require('./client/installIntlayer.cjs');
|
|
6
7
|
const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
7
8
|
const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
|
|
8
9
|
const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
|
|
9
10
|
const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
|
|
10
|
-
const require_client_useIntl = require('./client/useIntl.cjs');
|
|
11
11
|
const require_client_useIntlayer = require('./client/useIntlayer.cjs');
|
|
12
12
|
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
13
|
+
const require_UI_IntlayerNode_component = require('./UI/IntlayerNode.component.cjs');
|
|
13
14
|
|
|
14
|
-
exports.INTLAYER_TOKEN =
|
|
15
|
-
Object.defineProperty(exports, '
|
|
15
|
+
exports.INTLAYER_TOKEN = require_client_intlayerToken.INTLAYER_TOKEN;
|
|
16
|
+
Object.defineProperty(exports, 'IntlayerNodeComponent', {
|
|
16
17
|
enumerable: true,
|
|
17
18
|
get: function () {
|
|
18
|
-
return
|
|
19
|
+
return require_UI_IntlayerNode_component.IntlayerNodeComponent;
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
|
-
exports.
|
|
22
|
+
exports.IntlayerProvider = require_client_intlayerToken.IntlayerProvider;
|
|
23
|
+
exports.createIntlayerClient = require_client_intlayerToken.createIntlayerClient;
|
|
22
24
|
exports.getDictionary = require_getDictionary.getDictionary;
|
|
23
25
|
exports.getIntlayer = require_getIntlayer.getIntlayer;
|
|
24
26
|
exports.getPlugins = require_plugins.getPlugins;
|
|
@@ -33,7 +35,6 @@ exports.provideIntlayer = require_client_installIntlayer.provideIntlayer;
|
|
|
33
35
|
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
34
36
|
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
35
37
|
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
36
|
-
exports.useIntl = require_client_useIntl.useIntl;
|
|
37
38
|
exports.useIntlayer = require_client_useIntlayer.useIntlayer;
|
|
38
39
|
exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
|
|
39
40
|
exports.useLocale = require_client_useLocale.useLocale;
|
|
@@ -7,7 +7,8 @@ const renderIntlayerNode = ({ children, value, additionalProps = {} }) => {
|
|
|
7
7
|
if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
|
|
8
8
|
return Reflect.get(target, prop, receiver);
|
|
9
9
|
} });
|
|
10
|
-
|
|
10
|
+
const target = typeof children === "object" || typeof children === "function" ? children : {};
|
|
11
|
+
return new Proxy(target, {
|
|
11
12
|
apply(target, thisArg, argumentsList) {
|
|
12
13
|
if (typeof value === "function") return Reflect.apply(value, thisArg, argumentsList);
|
|
13
14
|
return Reflect.apply(target, thisArg, argumentsList);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderIntlayerNode.cjs","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.cjs","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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import configuration from "@intlayer/config/built";
|
|
2
2
|
|
|
3
3
|
//#region ../@intlayer/editor/src/isEnabled.ts
|
|
4
|
-
const isEnabled = process.env
|
|
4
|
+
const isEnabled = process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && configuration.editor?.enabled && typeof window !== "undefined" && window.self !== window.top;
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { isEnabled };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEnabled.mjs","names":[],"sources":["../../../../../../@intlayer/editor/src/isEnabled.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nexport const isEnabled =\n process.env
|
|
1
|
+
{"version":3,"file":"isEnabled.mjs","names":[],"sources":["../../../../../../@intlayer/editor/src/isEnabled.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nexport const isEnabled =\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && // Allow purging a build time using bundler + env var // Keep env['INTLAYER_EDITOR_ENABLED'] syntax for angular to treat it as\n configuration.editor?.enabled && // Editor enabled in config\n typeof window !== 'undefined' && // Client side\n window.self !== window.top; // Is in iframe\n"],"mappings":";;;AAEA,MAAa,YACX,QAAQ,IAAI,+BAA+B,WAC3C,cAAc,QAAQ,WACtB,OAAO,WAAW,eAClB,OAAO,SAAS,OAAO"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { ChangeDetectorRef, Component, ElementRef, Input, ViewContainerRef, inject } from "@angular/core";
|
|
4
|
+
|
|
5
|
+
//#region src/UI/IntlayerNode.component.ts
|
|
6
|
+
let IntlayerNodeComponent = class IntlayerNodeComponent {
|
|
7
|
+
node;
|
|
8
|
+
vcr = inject(ViewContainerRef);
|
|
9
|
+
elRef = inject(ElementRef);
|
|
10
|
+
cdr = inject(ChangeDetectorRef);
|
|
11
|
+
ngOnChanges(changes) {
|
|
12
|
+
if (changes["node"]) this.render();
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
this.vcr.clear();
|
|
16
|
+
const host = this.elRef.nativeElement;
|
|
17
|
+
host.childNodes.forEach((n) => {
|
|
18
|
+
if (n.nodeType === Node.TEXT_NODE) n.parentNode?.removeChild(n);
|
|
19
|
+
});
|
|
20
|
+
if (!this.node) return;
|
|
21
|
+
const nodeInfo = typeof this.node?.children === "function" ? this.node.children() : this.node;
|
|
22
|
+
if (nodeInfo?.component && typeof nodeInfo.component !== "string") {
|
|
23
|
+
const componentRef = this.vcr.createComponent(nodeInfo.component);
|
|
24
|
+
if (nodeInfo.props) for (const [key, value] of Object.entries(nodeInfo.props)) componentRef.instance[key] = value;
|
|
25
|
+
if (nodeInfo.children) {
|
|
26
|
+
const content = nodeInfo.children;
|
|
27
|
+
if (typeof content === "string" || typeof content === "number") componentRef.location.nativeElement.appendChild(document.createTextNode(String(content)));
|
|
28
|
+
}
|
|
29
|
+
this.cdr.markForCheck();
|
|
30
|
+
} else {
|
|
31
|
+
const text = this.node?.value ?? this.node?.toString?.() ?? String(this.node);
|
|
32
|
+
host.appendChild(document.createTextNode(text));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
__decorate([Input(), __decorateMetadata("design:type", Object)], IntlayerNodeComponent.prototype, "node", void 0);
|
|
37
|
+
IntlayerNodeComponent = __decorate([Component({
|
|
38
|
+
selector: "intlayer-node",
|
|
39
|
+
standalone: true,
|
|
40
|
+
template: `<ng-container #anchor></ng-container>`,
|
|
41
|
+
styles: [`:host { display: contents; }`]
|
|
42
|
+
})], IntlayerNodeComponent);
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { IntlayerNodeComponent };
|
|
46
|
+
//# sourceMappingURL=IntlayerNode.component.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerNode.component.mjs","names":[],"sources":["../../../src/UI/IntlayerNode.component.ts"],"sourcesContent":["import {\n ChangeDetectorRef,\n Component,\n ElementRef,\n Input,\n inject,\n type OnChanges,\n type SimpleChanges,\n type Type,\n ViewContainerRef,\n} from '@angular/core';\n\n/**\n * A transparent host element that renders Intlayer content nodes.\n *\n * `display: contents` makes the `<intlayer-node>` element invisible in the\n * layout — its children appear as if they were direct children of the parent,\n * so placing this component inside `<h1>`, `<p>`, etc. does not break the\n * document structure.\n *\n * ### Usage\n * ```html\n * <h1><intlayer-node [node]=\"content().title\"></intlayer-node></h1>\n * ```\n */\n@Component({\n selector: 'intlayer-node',\n standalone: true,\n // The ng-content slot is the anchor point for ViewContainerRef.\n // Wrapping text renders directly inside this host thanks to display:contents.\n template: `<ng-container #anchor></ng-container>`,\n // display:contents collapses the host box so it is layout-transparent.\n styles: [`:host { display: contents; }`],\n})\nexport class IntlayerNodeComponent implements OnChanges {\n @Input() node: any;\n\n private vcr = inject(ViewContainerRef);\n private elRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private cdr = inject(ChangeDetectorRef);\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['node']) {\n this.render();\n }\n }\n\n private render() {\n // Clear previously created views / text nodes\n this.vcr.clear();\n const host = this.elRef.nativeElement;\n // Remove any raw text nodes we injected directly on previous renders\n host.childNodes.forEach((n) => {\n if (n.nodeType === Node.TEXT_NODE) n.parentNode?.removeChild(n);\n });\n\n if (!this.node) return;\n\n // The node returned by the Angular plugin is a Proxy whose `.children`\n // property is a function returning component info (editor on) or the raw\n // value (editor off).\n const nodeInfo =\n typeof this.node?.children === 'function'\n ? this.node.children()\n : this.node;\n\n if (nodeInfo?.component && typeof nodeInfo.component !== 'string') {\n // ── Editor enabled path: create the ContentSelectorWrapper component ──\n const componentRef = this.vcr.createComponent(\n nodeInfo.component as Type<any>\n );\n\n if (nodeInfo.props) {\n for (const [key, value] of Object.entries(nodeInfo.props)) {\n (componentRef.instance as any)[key] = value;\n }\n }\n\n if (nodeInfo.children) {\n const content = nodeInfo.children;\n if (typeof content === 'string' || typeof content === 'number') {\n componentRef.location.nativeElement.appendChild(\n document.createTextNode(String(content))\n );\n }\n }\n\n this.cdr.markForCheck();\n } else {\n // ── Editor disabled path: render plain text inside the host ──────────\n const text =\n this.node?.value ?? this.node?.toString?.() ?? String(this.node);\n // Append a text node directly inside the host element.\n // Because the host has `display: contents`, this text is layout-wise a\n // direct child of the surrounding element (e.g. <h1>).\n host.appendChild(document.createTextNode(text));\n }\n }\n}\n"],"mappings":";;;;;AAkCO,kCAAM,sBAA2C;CACtD,AAAS;CAET,AAAQ,MAAM,OAAO,iBAAiB;CACtC,AAAQ,QAAQ,OAAgC,WAAW;CAC3D,AAAQ,MAAM,OAAO,kBAAkB;CAEvC,YAAY,SAA8B;AACxC,MAAI,QAAQ,QACV,MAAK,QAAQ;;CAIjB,AAAQ,SAAS;AAEf,OAAK,IAAI,OAAO;EAChB,MAAM,OAAO,KAAK,MAAM;AAExB,OAAK,WAAW,SAAS,MAAM;AAC7B,OAAI,EAAE,aAAa,KAAK,UAAW,GAAE,YAAY,YAAY,EAAE;IAC/D;AAEF,MAAI,CAAC,KAAK,KAAM;EAKhB,MAAM,WACJ,OAAO,KAAK,MAAM,aAAa,aAC3B,KAAK,KAAK,UAAU,GACpB,KAAK;AAEX,MAAI,UAAU,aAAa,OAAO,SAAS,cAAc,UAAU;GAEjE,MAAM,eAAe,KAAK,IAAI,gBAC5B,SAAS,UACV;AAED,OAAI,SAAS,MACX,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,MAAM,CACvD,CAAC,aAAa,SAAiB,OAAO;AAI1C,OAAI,SAAS,UAAU;IACrB,MAAM,UAAU,SAAS;AACzB,QAAI,OAAO,YAAY,YAAY,OAAO,YAAY,SACpD,cAAa,SAAS,cAAc,YAClC,SAAS,eAAe,OAAO,QAAQ,CAAC,CACzC;;AAIL,QAAK,IAAI,cAAc;SAClB;GAEL,MAAM,OACJ,KAAK,MAAM,SAAS,KAAK,MAAM,YAAY,IAAI,OAAO,KAAK,KAAK;AAIlE,QAAK,YAAY,SAAS,eAAe,KAAK,CAAC;;;;YA5DlD,OAAO;oCAVT,UAAU;CACT,UAAU;CACV,YAAY;CAGZ,UAAU;CAEV,QAAQ,CAAC,+BAA+B;CACzC,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./intlayerToken.mjs";
|
|
2
|
+
import { installIntlayer, provideIntlayer } from "./installIntlayer.mjs";
|
|
2
3
|
import { useDictionary } from "./useDictionary.mjs";
|
|
3
4
|
import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
|
|
4
5
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
5
6
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
6
|
-
import { useIntl } from "./useIntl.mjs";
|
|
7
7
|
import { isUpdatableNode, useIntlayer } from "./useIntlayer.mjs";
|
|
8
8
|
import { useLocale } from "./useLocale.mjs";
|
|
9
9
|
|
|
10
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic,
|
|
10
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -1,41 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { Injectable, InjectionToken, signal } from "@angular/core";
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient } from "./intlayerToken.mjs";
|
|
2
|
+
import { provideIntlayerEditor } from "../editor/useEditor.mjs";
|
|
4
3
|
|
|
5
4
|
//#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
5
|
/**
|
|
31
6
|
* Provides Intlayer to your Angular application.
|
|
32
7
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
8
|
+
* Registers the Intlayer locale token **and** automatically starts the Intlayer
|
|
9
|
+
* editor client (when the editor is enabled) via `provideAppInitializer`.
|
|
10
|
+
*
|
|
11
|
+
* This is the recommended way to set up Intlayer in `app.config.ts`.
|
|
35
12
|
*
|
|
36
13
|
* @param locale - Initial locale to use.
|
|
37
14
|
* @param isCookieEnabled - Whether to store the locale in cookies.
|
|
38
|
-
* @returns
|
|
15
|
+
* @returns An array of Angular providers for Intlayer.
|
|
39
16
|
*
|
|
40
17
|
* @example
|
|
41
18
|
* ```ts
|
|
@@ -44,16 +21,17 @@ const createIntlayerClient = (locale, isCookieEnabled = true) => {
|
|
|
44
21
|
* import { provideIntlayer } from 'angular-intlayer';
|
|
45
22
|
*
|
|
46
23
|
* export const appConfig: ApplicationConfig = {
|
|
47
|
-
* providers: [
|
|
48
|
-
* provideIntlayer({ locale: 'en' }),
|
|
49
|
-
* ],
|
|
24
|
+
* providers: [provideIntlayer()],
|
|
50
25
|
* };
|
|
51
26
|
* ```
|
|
52
27
|
*/
|
|
53
|
-
const provideIntlayer = (locale, isCookieEnabled = true) =>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
28
|
+
const provideIntlayer = (locale, isCookieEnabled = true) => {
|
|
29
|
+
const client = installIntlayer(locale, isCookieEnabled);
|
|
30
|
+
return [{
|
|
31
|
+
provide: INTLAYER_TOKEN,
|
|
32
|
+
useValue: client
|
|
33
|
+
}, provideIntlayerEditor(client)];
|
|
34
|
+
};
|
|
57
35
|
/**
|
|
58
36
|
* Helper to install the Intlayer provider.
|
|
59
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { provideIntlayerEditor } from '../editor/useEditor';\nimport {\n createIntlayerClient,\n INTLAYER_TOKEN,\n IntlayerProvider,\n} from './intlayerToken';\n\nexport { createIntlayerClient, INTLAYER_TOKEN, IntlayerProvider };\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * Registers the Intlayer locale token **and** automatically starts the Intlayer\n * editor client (when the editor is enabled) via `provideAppInitializer`.\n *\n * This is the recommended way to set up Intlayer in `app.config.ts`.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns An array of Angular providers 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: [provideIntlayer()],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = installIntlayer(locale, isCookieEnabled);\n\n return [\n { provide: INTLAYER_TOKEN, useValue: client },\n provideIntlayerEditor(client),\n ];\n};\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n return createIntlayerClient(locale, isCookieEnabled);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,mBACX,QACA,kBAAkB,SACf;CACH,MAAM,SAAS,gBAAgB,QAAQ,gBAAgB;AAEvD,QAAO,CACL;EAAE,SAAS;EAAgB,UAAU;EAAQ,EAC7C,sBAAsB,OAAO,CAC9B;;;;;AAMH,MAAa,mBACX,QACA,kBAAkB,SACf;AACH,QAAO,qBAAqB,QAAQ,gBAAgB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import configuration from "@intlayer/config/built";
|
|
2
|
+
import { InjectionToken, signal } from "@angular/core";
|
|
3
|
+
|
|
4
|
+
//#region src/client/intlayerToken.ts
|
|
5
|
+
var IntlayerProvider = class {
|
|
6
|
+
isCookieEnabled = signal(true);
|
|
7
|
+
_locale = signal(configuration.internationalization?.defaultLocale);
|
|
8
|
+
locale = this._locale.asReadonly();
|
|
9
|
+
setLocale = (locale) => {
|
|
10
|
+
this._locale.set(locale);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const INTLAYER_TOKEN = new InjectionToken("intlayer");
|
|
14
|
+
/**
|
|
15
|
+
* Singleton instance
|
|
16
|
+
*/
|
|
17
|
+
let instance = null;
|
|
18
|
+
/**
|
|
19
|
+
* Create and return a single IntlayerProvider instance
|
|
20
|
+
*/
|
|
21
|
+
const createIntlayerClient = (locale, isCookieEnabled = true) => {
|
|
22
|
+
if (instance) return instance;
|
|
23
|
+
instance = new IntlayerProvider();
|
|
24
|
+
if (locale) instance.setLocale(locale);
|
|
25
|
+
instance.isCookieEnabled.set(isCookieEnabled);
|
|
26
|
+
return instance;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient };
|
|
31
|
+
//# sourceMappingURL=intlayerToken.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerToken.mjs","names":[],"sources":["../../../src/client/intlayerToken.ts"],"sourcesContent":["import { InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\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"],"mappings":";;;;AAIA,IAAa,mBAAb,MAA8B;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;;;AAI5B,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;;;;AAKxC,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"}
|
|
@@ -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 } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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(()
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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()) as any\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;AAOA,MAAa,iBACX,YACA,WAC+C;CAC/C,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAAe,UAAU,UAAU,QAAQ,CAAC;AAOjE,QAJgB,eACR,cAAgC,YAAY,cAAc,CAAC,CAClE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { INTLAYER_TOKEN } from "./
|
|
3
|
+
import { INTLAYER_TOKEN } from "./intlayerToken.mjs";
|
|
4
4
|
import { useDictionary } from "./useDictionary.mjs";
|
|
5
5
|
import configuration from "@intlayer/config/built";
|
|
6
6
|
import { computed, inject } from "@angular/core";
|
|
@@ -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 { Dictionary } from '@intlayer/types/dictionary';\nimport type {
|
|
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 { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\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 as any)[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,MAAO,kBAA0B,cAAc,KAAK,EAEtC,cAAc,CAAQ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { INTLAYER_TOKEN } from "./
|
|
3
|
+
import { INTLAYER_TOKEN } from "./intlayerToken.mjs";
|
|
4
4
|
import { useDictionary } from "./useDictionary.mjs";
|
|
5
5
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
6
6
|
import configuration from "@intlayer/config/built";
|
|
@@ -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 { Dictionary } from '@intlayer/types/dictionary';\nimport type {
|
|
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 { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\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 as any)[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,IAC/B,kBAA0B,cAAc,KAAK,CAC/C,EAEgC,cAAc,CAAQ"}
|