angular-intlayer 6.1.6-canary.0 → 7.0.0-canary.0
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/UI/ContentSelector.component.cjs +94 -121
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/client/index.cjs +19 -35
- package/dist/cjs/client/installIntlayer.cjs +39 -68
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +13 -36
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +23 -48
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +24 -52
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +16 -36
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +26 -42
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +35 -67
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +61 -0
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +41 -63
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +44 -75
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +25 -45
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/communicator.cjs +55 -73
- package/dist/cjs/editor/communicator.cjs.map +1 -1
- package/dist/cjs/editor/configuration.cjs +21 -54
- package/dist/cjs/editor/configuration.cjs.map +1 -1
- package/dist/cjs/editor/createSharedComposable.cjs +46 -63
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
- package/dist/cjs/editor/dictionariesRecord.cjs +47 -77
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
- package/dist/cjs/editor/editedContent.cjs +58 -71
- package/dist/cjs/editor/editedContent.cjs.map +1 -1
- package/dist/cjs/editor/editorEnabled.cjs +45 -70
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
- package/dist/cjs/editor/editorLocale.cjs +21 -45
- package/dist/cjs/editor/editorLocale.cjs.map +1 -1
- package/dist/cjs/editor/focusDictionary.cjs +58 -74
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +9 -38
- package/dist/cjs/editor/installIntlayerEditor.cjs +46 -64
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +63 -72
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +108 -88
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +64 -69
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +25 -54
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +22 -44
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +38 -59
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +14 -39
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +14 -35
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +32 -31
- package/dist/cjs/markdown/index.cjs +6 -23
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +33 -60
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +77 -108
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +16 -56
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +3 -23
- package/dist/cjs/webpack/mergeConfig.cjs +33 -68
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.component.mjs +89 -104
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
- package/dist/esm/client/index.mjs +9 -8
- package/dist/esm/client/installIntlayer.mjs +29 -27
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +10 -11
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +18 -12
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +18 -15
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +12 -10
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +23 -17
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +30 -31
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +54 -0
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +32 -34
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
- package/dist/esm/editor/EditedContentRenderer.component.mjs +38 -49
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +19 -18
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/communicator.mjs +48 -35
- package/dist/esm/editor/communicator.mjs.map +1 -1
- package/dist/esm/editor/configuration.mjs +15 -18
- package/dist/esm/editor/configuration.mjs.map +1 -1
- package/dist/esm/editor/createSharedComposable.mjs +42 -37
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
- package/dist/esm/editor/dictionariesRecord.mjs +38 -38
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
- package/dist/esm/editor/editedContent.mjs +49 -42
- package/dist/esm/editor/editedContent.mjs.map +1 -1
- package/dist/esm/editor/editorEnabled.mjs +37 -41
- package/dist/esm/editor/editorEnabled.mjs.map +1 -1
- package/dist/esm/editor/editorLocale.mjs +15 -18
- package/dist/esm/editor/editorLocale.mjs.map +1 -1
- package/dist/esm/editor/focusDictionary.mjs +50 -45
- package/dist/esm/editor/focusDictionary.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +3 -7
- package/dist/esm/editor/installIntlayerEditor.mjs +40 -26
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +58 -46
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameState.mjs +104 -62
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/editor/useCrossURLPathState.mjs +57 -41
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +21 -33
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +16 -14
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/editor/useIframeClickInterceptor.mjs +30 -30
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +12 -20
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +12 -16
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +13 -6
- package/dist/esm/markdown/index.mjs +3 -2
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +27 -32
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +70 -83
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +15 -32
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/esm/webpack/index.mjs +3 -2
- package/dist/esm/webpack/mergeConfig.mjs +25 -31
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/UI/ContentSelector.component.d.ts +32 -30
- package/dist/types/UI/ContentSelector.component.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +8 -8
- package/dist/types/client/installIntlayer.d.ts +15 -9
- package/dist/types/client/installIntlayer.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +7 -4
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +7 -3
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +9 -7
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +4 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +17 -8
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +49 -0
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +18 -12
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
- package/dist/types/editor/EditedContentRenderer.component.d.ts +20 -16
- package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -1
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +11 -6
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -1
- package/dist/types/editor/communicator.d.ts +14 -9
- package/dist/types/editor/communicator.d.ts.map +1 -1
- package/dist/types/editor/configuration.d.ts +4 -1
- package/dist/types/editor/configuration.d.ts.map +1 -1
- package/dist/types/editor/createSharedComposable.d.ts +6 -4
- package/dist/types/editor/createSharedComposable.d.ts.map +1 -1
- package/dist/types/editor/dictionariesRecord.d.ts +13 -10
- package/dist/types/editor/dictionariesRecord.d.ts.map +1 -1
- package/dist/types/editor/editedContent.d.ts +13 -10
- package/dist/types/editor/editedContent.d.ts.map +1 -1
- package/dist/types/editor/editorEnabled.d.ts +12 -8
- package/dist/types/editor/editorEnabled.d.ts.map +1 -1
- package/dist/types/editor/editorLocale.d.ts +6 -2
- package/dist/types/editor/editorLocale.d.ts.map +1 -1
- package/dist/types/editor/focusDictionary.d.ts +16 -13
- package/dist/types/editor/focusDictionary.d.ts.map +1 -1
- package/dist/types/editor/index.d.ts +5 -5
- package/dist/types/editor/installIntlayerEditor.d.ts +7 -2
- package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -1
- package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
- package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
- package/dist/types/editor/useCrossFrameState.d.ts +12 -8
- package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
- package/dist/types/editor/useCrossURLPathState.d.ts +9 -3
- package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts +15 -11
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
- package/dist/types/editor/useEditor.d.ts +4 -1
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
- package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +8 -4
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +8 -4
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +2 -2
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +15 -12
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +29 -23
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/renderIntlayerNode.d.ts +16 -10
- package/dist/types/renderIntlayerNode.d.ts.map +1 -1
- package/dist/types/webpack/index.d.ts +2 -2
- package/dist/types/webpack/mergeConfig.d.ts +5 -2
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
- package/package.json +43 -49
- package/LICENSE +0 -202
- package/dist/cjs/client/index.cjs.map +0 -1
- package/dist/cjs/client/useLocaleCookie.cjs +0 -60
- package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
- package/dist/cjs/editor/index.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/markdown/index.cjs.map +0 -1
- package/dist/cjs/webpack/index.cjs.map +0 -1
- package/dist/esm/client/index.mjs.map +0 -1
- package/dist/esm/client/useLocaleCookie.mjs +0 -24
- package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
- package/dist/esm/editor/index.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/markdown/index.mjs.map +0 -1
- package/dist/esm/webpack/index.mjs.map +0 -1
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/useLocaleCookie.d.ts +0 -17
- package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
- package/dist/types/editor/index.d.ts.map +0 -1
- package/dist/types/markdown/index.d.ts.map +0 -1
- package/dist/types/webpack/index.d.ts.map +0 -1
|
@@ -1,55 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var useDictionaryDynamic_exports = {};
|
|
31
|
-
__export(useDictionaryDynamic_exports, {
|
|
32
|
-
useDictionaryDynamic: () => useDictionaryDynamic
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(useDictionaryDynamic_exports);
|
|
35
|
-
var import_core = require("@angular/core");
|
|
36
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
37
|
-
var import_installIntlayer = require('./installIntlayer.cjs');
|
|
38
|
-
var import_useDictionary = require('./useDictionary.cjs');
|
|
39
|
-
var import_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
6
|
+
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
7
|
+
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
8
|
+
let __angular_core = require("@angular/core");
|
|
9
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
10
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
11
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
12
|
+
|
|
13
|
+
//#region src/client/useDictionaryDynamic.ts
|
|
14
|
+
/**
|
|
15
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
16
|
+
*
|
|
17
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
18
|
+
*/
|
|
40
19
|
const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
const dictionary = (0, import_useLoadDynamic.useLoadDynamic)(
|
|
46
|
-
`${String(key)}.${localeTarget()}`,
|
|
47
|
-
dictionaryPromise[localeTarget()]()
|
|
48
|
-
);
|
|
49
|
-
return (0, import_useDictionary.useDictionary)(dictionary, localeTarget());
|
|
20
|
+
const intlayer = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
21
|
+
const localeTarget = (0, __angular_core.computed)(() => locale ?? intlayer?.locale() ?? __intlayer_config_built.default?.internationalization.defaultLocale);
|
|
22
|
+
return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
|
|
50
23
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.useDictionaryDynamic = useDictionaryDynamic;
|
|
55
27
|
//# sourceMappingURL=useDictionaryDynamic.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,sCAAoCA,8CAAe;CAEzD,MAAM,kDAEF,UACA,UAAU,QAAQ,IAClBC,iCAAe,qBAAqB,cACvC;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
|
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useIntlayer_exports = {};
|
|
20
|
-
__export(useIntlayer_exports, {
|
|
21
|
-
isUpdatableNode: () => isUpdatableNode,
|
|
22
|
-
useIntlayer: () => useIntlayer
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useIntlayer_exports);
|
|
25
|
-
var import_core = require("@angular/core");
|
|
26
|
-
var import_getIntlayer = require('../getIntlayer.cjs');
|
|
27
|
-
var import_installIntlayer = require('./installIntlayer.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
3
|
+
const require_getIntlayer = require('../getIntlayer.cjs');
|
|
4
|
+
let __angular_core = require("@angular/core");
|
|
5
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
6
|
+
|
|
7
|
+
//#region src/client/useIntlayer.ts
|
|
8
|
+
/** guard utility - true only for objects generated by `renderIntlayerNode()` */
|
|
28
9
|
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
29
10
|
const useIntlayer = (key, locale) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
const intlayer = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
12
|
+
/** which locale should we use right now? */
|
|
13
|
+
const localeTarget = (0, __angular_core.computed)(() => locale ?? intlayer.locale());
|
|
14
|
+
return (0, __angular_core.computed)(() => require_getIntlayer.getIntlayer(key, localeTarget()))();
|
|
34
15
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.isUpdatableNode = isUpdatableNode;
|
|
19
|
+
exports.useIntlayer = useIntlayer;
|
|
40
20
|
//# sourceMappingURL=useIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAEnC,MAAa,eACX,KACA,WACuD;CACvD,MAAM,sCAAoCA,8CAAe;;CAGzD,MAAM,kDAA8B,UAAU,SAAS,QAAQ,CAAC;AAMhE,2CAF+BC,gCAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
|
|
@@ -1,45 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useLoadDynamic_exports = {};
|
|
20
|
-
__export(useLoadDynamic_exports, {
|
|
21
|
-
useLoadDynamic: () => useLoadDynamic
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useLoadDynamic_exports);
|
|
24
|
-
var import_core = require("@angular/core");
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __angular_core = require("@angular/core");
|
|
3
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
4
|
+
|
|
5
|
+
//#region src/client/useLoadDynamic.ts
|
|
6
|
+
/**
|
|
7
|
+
* A "synchronous" loader for a dynamically‐imported JSON (or anything).
|
|
8
|
+
*
|
|
9
|
+
* - Immediately returns a reactive signal so that Angular can properly track changes.
|
|
10
|
+
* - When the Promise resolves, it replaces the signal's value with the real data.
|
|
11
|
+
*/
|
|
25
12
|
const useLoadDynamic = (key, promise) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
return container();
|
|
13
|
+
const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
|
|
14
|
+
const container = (0, __angular_core.signal)({});
|
|
15
|
+
if (!cache.has(key)) {
|
|
16
|
+
const p = promise.then((real) => {
|
|
17
|
+
container.set(real);
|
|
18
|
+
return real;
|
|
19
|
+
});
|
|
20
|
+
cache.set(key, p);
|
|
21
|
+
} else cache.get(key)?.then((real) => {
|
|
22
|
+
container.set(real);
|
|
23
|
+
});
|
|
24
|
+
return container();
|
|
40
25
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.useLoadDynamic = useLoadDynamic;
|
|
45
29
|
//# sourceMappingURL=useLoadDynamic.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)
|
|
1
|
+
{"version":3,"file":"useLoadDynamic.cjs","names":["cache: Map<string, Promise<T>>"],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBACX,KACA,YACM;CAEN,MAAMA,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,KAAK;CAI3C,MAAM,uCAAmB,EAAE,CAAM;AAEjC,KAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;AAE/B,aAAU,IAAI,KAAK;AACnB,UAAO;IACP;AACF,QAAM,IAAI,KAAK,EAAE;OAGjB,OAAM,IAAI,IAAI,EAAE,MAAM,SAAS;AAC7B,YAAU,IAAI,KAAK;GACnB;AAIJ,QAAO,WAAW"}
|
|
@@ -1,69 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
3
|
+
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
4
|
+
let __angular_core = require("@angular/core");
|
|
5
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
6
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
8
|
+
|
|
9
|
+
//#region src/client/useLocale.ts
|
|
10
|
+
/**
|
|
11
|
+
* On the client side, composable to get the current locale and all related fields
|
|
12
|
+
*/
|
|
13
|
+
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
14
|
+
const { defaultLocale, locales: availableLocales } = __intlayer_config_built.default?.internationalization ?? {};
|
|
15
|
+
const intlayer = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
16
|
+
const locale = (0, __angular_core.computed)(() => intlayer?.locale() ?? defaultLocale);
|
|
17
|
+
const isCookieEnabledContext = (0, __angular_core.computed)(() => intlayer?.isCookieEnabled() ?? true);
|
|
18
|
+
const setLocale = (newLocale) => {
|
|
19
|
+
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
20
|
+
console.error(`Locale ${newLocale} is not available`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (intlayer) intlayer.setLocale(newLocale);
|
|
24
|
+
require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled ?? isCookieEnabledContext() ?? true);
|
|
25
|
+
onLocaleChange?.(newLocale);
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
locale,
|
|
29
|
+
defaultLocale,
|
|
30
|
+
availableLocales,
|
|
31
|
+
setLocale
|
|
32
|
+
};
|
|
11
33
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var useLocale_exports = {};
|
|
30
|
-
__export(useLocale_exports, {
|
|
31
|
-
useLocale: () => useLocale
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(useLocale_exports);
|
|
34
|
-
var import_core = require("@angular/core");
|
|
35
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
36
|
-
var import_installIntlayer = require('./installIntlayer.cjs');
|
|
37
|
-
var import_useLocaleCookie = require('./useLocaleCookie.cjs');
|
|
38
|
-
const useLocale = ({ onLocaleChange } = {}) => {
|
|
39
|
-
const { defaultLocale, locales: availableLocales } = import_built.default?.internationalization ?? {};
|
|
40
|
-
const intlayer = (0, import_core.inject)(import_installIntlayer.INTLAYER_TOKEN);
|
|
41
|
-
const { setLocaleCookie } = (0, import_useLocaleCookie.useLocaleCookie)();
|
|
42
|
-
const locale = (0, import_core.computed)(() => intlayer?.locale() ?? defaultLocale);
|
|
43
|
-
const setLocale = (newLocale) => {
|
|
44
|
-
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
45
|
-
console.error(`Locale ${newLocale} is not available`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (intlayer) {
|
|
49
|
-
intlayer.setLocale(newLocale);
|
|
50
|
-
}
|
|
51
|
-
setLocaleCookie(newLocale);
|
|
52
|
-
onLocaleChange?.(newLocale);
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
locale,
|
|
56
|
-
// Current locale
|
|
57
|
-
defaultLocale,
|
|
58
|
-
// Principal locale defined in config
|
|
59
|
-
availableLocales,
|
|
60
|
-
// List of the available locales defined in config
|
|
61
|
-
setLocale
|
|
62
|
-
// Function to set the locale
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
useLocale
|
|
68
|
-
});
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.useLocale = useLocale;
|
|
69
37
|
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, composable to get the current locale and all related fields\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9BA,iCAAe,wBAAwB,EAAE;CAC3C,MAAM,sCAAoCC,8CAAe;CAGzD,MAAM,4CAAwB,UAAU,QAAQ,IAAI,cAAc;CAClE,MAAM,4DACE,UAAU,iBAAiB,IAAI,KACtC;CAED,MAAM,aAAa,cAA6B;AAC9C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,MAAI,SACF,UAAS,UAAU,UAAU;AAE/B,qDACE,WACA,mBAAmB,wBAAwB,IAAI,KAChD;AACD,mBAAiB,UAAU;;AAG7B,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __intlayer_core = require("@intlayer/core");
|
|
3
|
+
__intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
|
|
4
|
+
|
|
5
|
+
//#region src/client/useLocaleStorage.ts
|
|
6
|
+
/**
|
|
7
|
+
* Get the locale cookie
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Get the locale cookie
|
|
11
|
+
*/
|
|
12
|
+
const localeInStorage = (0, __intlayer_core.getLocaleFromStorage)(__intlayer_core.localeStorageOptions);
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use localeInStorage instead
|
|
15
|
+
*
|
|
16
|
+
* Get the locale cookie
|
|
17
|
+
*/
|
|
18
|
+
const localeCookie = localeInStorage;
|
|
19
|
+
/**
|
|
20
|
+
* Set the locale cookie
|
|
21
|
+
*/
|
|
22
|
+
const setLocaleInStorage = (locale, isCookieEnabled) => (0, __intlayer_core.setLocaleInStorage)(locale, {
|
|
23
|
+
...__intlayer_core.localeStorageOptions,
|
|
24
|
+
isCookieEnabled
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use setLocaleInStorage instead
|
|
28
|
+
*
|
|
29
|
+
* Set the locale cookie
|
|
30
|
+
*/
|
|
31
|
+
const setLocaleCookie = setLocaleInStorage;
|
|
32
|
+
/**
|
|
33
|
+
* Hook that provides the locale storage and a function to set it
|
|
34
|
+
*/
|
|
35
|
+
const useLocaleStorage = (isCookieEnabled) => (0, __intlayer_core.LocaleStorage)({
|
|
36
|
+
...__intlayer_core.localeStorageOptions,
|
|
37
|
+
isCookieEnabled
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use useLocaleStorage instead
|
|
41
|
+
*
|
|
42
|
+
* For GDPR compliance, use useLocaleStorage instead
|
|
43
|
+
*
|
|
44
|
+
* Hook that provides the locale cookie and a function to set it
|
|
45
|
+
*/
|
|
46
|
+
const useLocaleCookie = (isCookieEnabled) => {
|
|
47
|
+
const storage = useLocaleStorage(isCookieEnabled);
|
|
48
|
+
return {
|
|
49
|
+
localeCookie: storage.getLocale(),
|
|
50
|
+
setLocaleCookie: storage.setLocale
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
exports.localeCookie = localeCookie;
|
|
56
|
+
exports.localeInStorage = localeInStorage;
|
|
57
|
+
exports.setLocaleCookie = setLocaleCookie;
|
|
58
|
+
exports.setLocaleInStorage = setLocaleInStorage;
|
|
59
|
+
exports.useLocaleCookie = useLocaleCookie;
|
|
60
|
+
exports.useLocaleStorage = useLocaleStorage;
|
|
61
|
+
//# sourceMappingURL=useLocaleStorage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorage,\n LocaleStorage,\n localeStorageOptions,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,4DAAuCA,qCAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,4DAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,uDACjB;CACZ,GAAGA;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
|
|
@@ -1,38 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var ContentSelectorWrapper_component_exports = {};
|
|
20
|
-
__export(ContentSelectorWrapper_component_exports, {
|
|
21
|
-
ContentSelectorWrapperComponent: () => ContentSelectorWrapperComponent
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(ContentSelectorWrapper_component_exports);
|
|
24
|
-
var import_common = require("@angular/common");
|
|
25
|
-
var import_core = require("@angular/core");
|
|
26
|
-
var import_core2 = require("@intlayer/core");
|
|
27
|
-
var import_ContentSelector = require('../UI/ContentSelector.component.cjs');
|
|
28
|
-
var import_editorEnabled = require('./editorEnabled.cjs');
|
|
29
|
-
var import_focusDictionary = require('./focusDictionary.cjs');
|
|
30
|
-
var import_useEditor = require('./useEditor.cjs');
|
|
31
|
-
@((0, import_core.Component)({
|
|
32
|
-
selector: "app-content-selector-wrapper",
|
|
33
|
-
standalone: true,
|
|
34
|
-
imports: [import_common.CommonModule, import_ContentSelector.ContentSelectorComponent],
|
|
35
|
-
template: `
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_UI_ContentSelector_component = require('../UI/ContentSelector.component.cjs');
|
|
3
|
+
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
4
|
+
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
5
|
+
const require_editor_useEditor = require('./useEditor.cjs');
|
|
6
|
+
let __intlayer_core = require("@intlayer/core");
|
|
7
|
+
__intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
|
|
8
|
+
let __angular_common = require("@angular/common");
|
|
9
|
+
__angular_common = require_rolldown_runtime.__toESM(__angular_common);
|
|
10
|
+
let __angular_core = require("@angular/core");
|
|
11
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
12
|
+
|
|
13
|
+
//#region src/editor/ContentSelectorWrapper.component.ts
|
|
14
|
+
var ContentSelectorWrapperComponent = @((0, __angular_core.Component)({
|
|
15
|
+
selector: "app-content-selector-wrapper",
|
|
16
|
+
standalone: true,
|
|
17
|
+
imports: [__angular_common.CommonModule, require_UI_ContentSelector_component.ContentSelectorComponent],
|
|
18
|
+
template: `
|
|
36
19
|
<app-content-selector
|
|
37
20
|
*ngIf="enabled()"
|
|
38
21
|
(press)="handleSelect()"
|
|
@@ -42,32 +25,27 @@ var import_useEditor = require('./useEditor.cjs');
|
|
|
42
25
|
</app-content-selector>
|
|
43
26
|
<ng-content *ngIf="!enabled()"></ng-content>
|
|
44
27
|
`
|
|
45
|
-
}))
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
-
0 && (module.exports = {
|
|
71
|
-
ContentSelectorWrapperComponent
|
|
72
|
-
});
|
|
28
|
+
})) class {
|
|
29
|
+
@((0, __angular_core.Input)()) dictionaryKey;
|
|
30
|
+
@((0, __angular_core.Input)()) keyPath;
|
|
31
|
+
focusDictionary = require_editor_focusDictionary.useFocusDictionary();
|
|
32
|
+
editorEnabled = require_editor_editorEnabled.useEditorEnabled();
|
|
33
|
+
constructor() {
|
|
34
|
+
require_editor_useEditor.useEditor();
|
|
35
|
+
}
|
|
36
|
+
isSelected = (0, __angular_core.computed)(() => {
|
|
37
|
+
const focusedContent = this.focusDictionary.focusedContent();
|
|
38
|
+
return focusedContent?.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && (0, __intlayer_core.isSameKeyPath)(focusedContent.keyPath ?? [], this.keyPath);
|
|
39
|
+
});
|
|
40
|
+
enabled = (0, __angular_core.computed)(() => this.editorEnabled.enabled());
|
|
41
|
+
handleSelect() {
|
|
42
|
+
this.focusDictionary.setFocusedContent({
|
|
43
|
+
dictionaryKey: this.dictionaryKey,
|
|
44
|
+
keyPath: this.keyPath
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.ContentSelectorWrapperComponent = ContentSelectorWrapperComponent;
|
|
73
51
|
//# sourceMappingURL=ContentSelectorWrapper.component.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component,
|
|
1
|
+
{"version":3,"file":"ContentSelectorWrapper.component.cjs","names":["CommonModule","ContentSelectorComponent","useFocusDictionary","useEditorEnabled"],"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input } from '@angular/core';\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,IAAa,kCAfb,gCAAW;CACT,UAAU;CACV,YAAY;CACZ,SAAS,CAACA,+BAAcC,8DAAyB;CACjD,UAAU;;;;;;;;;;CAUX,CAAC,EACF,MAA6C;CAC3C,6BAAQ,EAAC;CACT,6BAAQ,EAAC;CAGT,AAAQ,kBAAkBC,mDAAoB;CAC9C,AAAQ,gBAAgBC,+CAAkB;CAE1C,cAAc;AACZ,sCAAW;;CAIb,gDAA4B;EAC1B,MAAM,iBAAiB,KAAK,gBAAgB,gBAAgB;AAC5D,SACE,gBAAgB,kBAAkB,KAAK,kBACtC,eAAe,SAAS,UAAU,KAAK,wCAC1B,eAAe,WAAW,EAAE,EAAE,KAAK,QAAQ;GAE3D;CAEF,6CAAyB,KAAK,cAAc,SAAS,CAAC;CAGtD,eAAe;AACb,OAAK,gBAAgB,kBAAkB;GACrC,eAAe,KAAK;GACpB,SAAS,KAAK;GACf,CAAC"}
|