angular-intlayer 6.1.6 → 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,18 +1,11 @@
|
|
|
1
1
|
import { CommonModule } from "@angular/common";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
EventEmitter,
|
|
6
|
-
HostListener,
|
|
7
|
-
Input,
|
|
8
|
-
Output,
|
|
9
|
-
signal,
|
|
10
|
-
ViewChild
|
|
11
|
-
} from "@angular/core";
|
|
2
|
+
import { Component, EventEmitter, HostListener, Input, Output, ViewChild, computed, signal } from "@angular/core";
|
|
3
|
+
|
|
4
|
+
//#region src/UI/ContentSelector.component.ts
|
|
12
5
|
const DEFAULT_PRESS_DETECT_DURATION = 250;
|
|
13
|
-
@Component({
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
var ContentSelectorComponent = @Component({
|
|
7
|
+
selector: "app-content-selector",
|
|
8
|
+
template: `
|
|
16
9
|
<span
|
|
17
10
|
#containerRef
|
|
18
11
|
role="button"
|
|
@@ -31,96 +24,88 @@ const DEFAULT_PRESS_DETECT_DURATION = 250;
|
|
|
31
24
|
<ng-content></ng-content>
|
|
32
25
|
</span>
|
|
33
26
|
`,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
borderRadius: "0.375rem",
|
|
115
|
-
outlineWidth: "2px",
|
|
116
|
-
outlineOffset: "4px",
|
|
117
|
-
outlineStyle: "solid",
|
|
118
|
-
outlineColor: this.isSelectingComputed() || this.isHovered() ? "inherit" : "transparent",
|
|
119
|
-
transition: "all 100ms 50ms ease-in-out"
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
export {
|
|
124
|
-
ContentSelectorComponent
|
|
27
|
+
standalone: true,
|
|
28
|
+
imports: [CommonModule]
|
|
29
|
+
}) class {
|
|
30
|
+
@Input() onClickOutside;
|
|
31
|
+
@Input() pressDuration;
|
|
32
|
+
@Input() isSelecting;
|
|
33
|
+
@Output() click = new EventEmitter();
|
|
34
|
+
@Output() press = new EventEmitter();
|
|
35
|
+
@ViewChild("containerRef", { static: true }) containerRef;
|
|
36
|
+
isHovered = signal(false);
|
|
37
|
+
isSelectingState = signal(false);
|
|
38
|
+
pressTimerRef = null;
|
|
39
|
+
isSelectingComputed = computed(() => this.isSelecting ?? this.isSelectingState());
|
|
40
|
+
isStringSlot = computed(() => {
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
43
|
+
ngOnInit() {
|
|
44
|
+
this.isSelectingState.set(this.isSelecting ?? false);
|
|
45
|
+
}
|
|
46
|
+
ngOnDestroy() {
|
|
47
|
+
this.clearPressTimer();
|
|
48
|
+
}
|
|
49
|
+
@HostListener("document:mousedown", ["$event"]) onDocumentMouseDown(event) {
|
|
50
|
+
this.handleClickOutside(event);
|
|
51
|
+
}
|
|
52
|
+
handleOnLongPress() {
|
|
53
|
+
this.isSelectingState.set(true);
|
|
54
|
+
this.press.emit();
|
|
55
|
+
}
|
|
56
|
+
startPressTimer() {
|
|
57
|
+
this.pressTimerRef = setTimeout(() => {
|
|
58
|
+
this.handleOnLongPress();
|
|
59
|
+
}, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);
|
|
60
|
+
}
|
|
61
|
+
clearPressTimer() {
|
|
62
|
+
if (this.pressTimerRef) {
|
|
63
|
+
clearTimeout(this.pressTimerRef);
|
|
64
|
+
this.pressTimerRef = null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
handleMouseDown() {
|
|
68
|
+
this.clearPressTimer();
|
|
69
|
+
this.startPressTimer();
|
|
70
|
+
}
|
|
71
|
+
handleMouseUp() {
|
|
72
|
+
this.isHovered.set(false);
|
|
73
|
+
this.clearPressTimer();
|
|
74
|
+
}
|
|
75
|
+
handleClickOutside(event) {
|
|
76
|
+
if (this.containerRef?.nativeElement && !this.containerRef.nativeElement.contains(event.target)) {
|
|
77
|
+
this.isSelectingState.set(false);
|
|
78
|
+
this.onClickOutside?.();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
handleClick(e) {
|
|
82
|
+
if (this.isSelectingComputed()) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
}
|
|
86
|
+
this.click.emit(e);
|
|
87
|
+
}
|
|
88
|
+
handleBlur() {
|
|
89
|
+
this.isSelectingState.set(false);
|
|
90
|
+
}
|
|
91
|
+
onMouseEnter() {
|
|
92
|
+
this.isHovered.set(true);
|
|
93
|
+
}
|
|
94
|
+
getContainerStyle() {
|
|
95
|
+
return {
|
|
96
|
+
display: this.isStringSlot() ? "inline" : "inline-block",
|
|
97
|
+
cursor: "pointer",
|
|
98
|
+
userSelect: "none",
|
|
99
|
+
borderRadius: "0.375rem",
|
|
100
|
+
outlineWidth: "2px",
|
|
101
|
+
outlineOffset: "4px",
|
|
102
|
+
outlineStyle: "solid",
|
|
103
|
+
outlineColor: this.isSelectingComputed() || this.isHovered() ? "inherit" : "transparent",
|
|
104
|
+
transition: "all 100ms 50ms ease-in-out"
|
|
105
|
+
};
|
|
106
|
+
}
|
|
125
107
|
};
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { ContentSelectorComponent };
|
|
126
111
|
//# sourceMappingURL=ContentSelector.component.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n
|
|
1
|
+
{"version":3,"file":"ContentSelector.component.mjs","names":[],"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n computed,\n type ElementRef,\n EventEmitter,\n HostListener,\n Input,\n type OnDestroy,\n type OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":";;;;AAeA,MAAM,gCAAgC;AA0BtC,IAAa,2BAxBb,CAAC,UAAU;CACT,UAAU;CACV,UAAU;;;;;;;;;;;;;;;;;;;CAmBV,YAAY;CACZ,SAAS,CAAC,aAAa;CACxB,CAAC,CACF,MAAmE;CACjE,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CAET,CAAC,QAAQ,CAAC,QAAQ,IAAI,cAA0B;CAChD,CAAC,QAAQ,CAAC,QAAQ,IAAI,cAAoB;CAE1C,CAAC,UAAU,gBAAgB,EAAE,QAAQ,MAAM,CAAC,CAC5C;CAEA,AAAQ,YAAY,OAAO,MAAM;CACjC,AAAQ,mBAAmB,OAAO,MAAM;CACxC,AAAQ,gBAAsD;CAE9D,AAAiB,sBAAsB,eAC/B,KAAK,eAAe,KAAK,kBAAkB,CAClD;CAED,AAAiB,eAAe,eAAe;AAG7C,SAAO;GACP;CAEF,WAAiB;AACf,OAAK,iBAAiB,IAAI,KAAK,eAAe,MAAM;;CAGtD,cAAoB;AAClB,OAAK,iBAAiB;;CAGxB,CAAC,aAAa,sBAAsB,CAAC,SAAS,CAAC,CAC/C,oBAAoB,OAAyB;AAC3C,OAAK,mBAAmB,MAAM;;CAGhC,AAAQ,oBAA0B;AAChC,OAAK,iBAAiB,IAAI,KAAK;AAC/B,OAAK,MAAM,MAAM;;CAGnB,AAAQ,kBAAwB;AAC9B,OAAK,gBAAgB,iBAAiB;AACpC,QAAK,mBAAmB;KACvB,KAAK,iBAAiB,8BAA8B;;CAGzD,AAAQ,kBAAwB;AAC9B,MAAI,KAAK,eAAe;AACtB,gBAAa,KAAK,cAAc;AAChC,QAAK,gBAAgB;;;CAIzB,kBAAwB;AACtB,OAAK,iBAAiB;AACtB,OAAK,iBAAiB;;CAGxB,gBAAsB;AACpB,OAAK,UAAU,IAAI,MAAM;AACzB,OAAK,iBAAiB;;CAGxB,AAAQ,mBAAmB,OAAyB;AAClD,MACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,OAAe,EAC/D;AACA,QAAK,iBAAiB,IAAI,MAAM;AAChC,QAAK,kBAAkB;;;CAI3B,YAAY,GAAqB;AAC/B,MAAI,KAAK,qBAAqB,EAAE;AAC9B,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;AAErB,OAAK,MAAM,KAAK,EAAE;;CAGpB,aAAmB;AACjB,OAAK,iBAAiB,IAAI,MAAM;;CAGlC,eAAqB;AACnB,OAAK,UAAU,IAAI,KAAK;;CAG1B,oBAA4C;AAC1C,SAAO;GACL,SAAS,KAAK,cAAc,GAAG,WAAW;GAC1C,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,KAAK,qBAAqB,IAAI,KAAK,WAAW,GAC1C,YACA;GACN,YAAY;GACb"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer } from "./installIntlayer.mjs";
|
|
2
|
+
import { useDictionary } from "./useDictionary.mjs";
|
|
3
|
+
import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
|
|
4
|
+
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
5
|
+
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
6
|
+
import { isUpdatableNode, useIntlayer } from "./useIntlayer.mjs";
|
|
7
|
+
import { useLocale } from "./useLocale.mjs";
|
|
8
|
+
|
|
9
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { Injectable, InjectionToken, signal } from "@angular/core";
|
|
2
2
|
import configuration from "@intlayer/config/built";
|
|
3
|
+
|
|
4
|
+
//#region src/client/installIntlayer.ts
|
|
3
5
|
const INTLAYER_TOKEN = new InjectionToken("intlayer");
|
|
6
|
+
/**
|
|
7
|
+
* Singleton instance
|
|
8
|
+
*/
|
|
4
9
|
let instance = null;
|
|
5
|
-
@Injectable({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
locale = this._locale.asReadonly();
|
|
13
|
-
setLocale = (locale) => {
|
|
14
|
-
this._locale.set(locale);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const createIntlayerClient = (locale) => {
|
|
18
|
-
if (instance) return instance;
|
|
19
|
-
instance = new IntlayerProvider();
|
|
20
|
-
if (locale) {
|
|
21
|
-
instance.setLocale(locale);
|
|
22
|
-
}
|
|
23
|
-
return instance;
|
|
10
|
+
var IntlayerProvider = @Injectable({ providedIn: "root" }) class {
|
|
11
|
+
isCookieEnabled = signal(true);
|
|
12
|
+
_locale = signal(configuration.internationalization?.defaultLocale);
|
|
13
|
+
locale = this._locale.asReadonly();
|
|
14
|
+
setLocale = (locale) => {
|
|
15
|
+
this._locale.set(locale);
|
|
16
|
+
};
|
|
24
17
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Helper to install the Intlayer provider
|
|
30
|
+
*/
|
|
31
|
+
const installIntlayer = (locale, isCookieEnabled = true) => {
|
|
32
|
+
return createIntlayerClient(locale, isCookieEnabled);
|
|
34
33
|
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer };
|
|
35
37
|
//# sourceMappingURL=installIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken,
|
|
1
|
+
{"version":3,"file":"installIntlayer.mjs","names":["instance: IntlayerProvider | null"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;AAIA,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAIA,WAAoC;AAKxC,IAAa,mBAHb,CAAC,WAAW,EACV,YAAY,QACb,CAAC,CACF,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;;;;;;AAO5B,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;;;;;AAMT,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { computed, inject } from "@angular/core";
|
|
2
|
-
import { getDictionary } from "../getDictionary.mjs";
|
|
3
1
|
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
2
|
+
import { getDictionary } from "../getDictionary.mjs";
|
|
3
|
+
import { computed, inject } from "@angular/core";
|
|
4
|
+
|
|
5
|
+
//#region src/client/useDictionary.ts
|
|
4
6
|
const useDictionary = (dictionary, locale) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
() => getDictionary(dictionary, localeTarget())
|
|
9
|
-
);
|
|
10
|
-
return content();
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
useDictionary
|
|
7
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
8
|
+
const localeTarget = computed(() => locale ?? intlayer?.locale());
|
|
9
|
+
return computed(() => getDictionary(dictionary, localeTarget()))();
|
|
14
10
|
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useDictionary };
|
|
15
14
|
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { Dictionary, LocalesValues } from '@intlayer/types';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): DeepTransformContent<T['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content() as DeepTransformContent<T['content']>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,YACA,WACuC;CACvC,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAAe,UAAU,UAAU,QAAQ,CAAC;AAOjE,QAJgB,eACd,cAAgC,YAAY,cAAc,CAAC,CAC5D,EAEe"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
4
|
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
5
5
|
import { useDictionary } from "./useDictionary.mjs";
|
|
6
|
+
import { computed, inject } from "@angular/core";
|
|
7
|
+
import configuration from "@intlayer/config/built";
|
|
8
|
+
|
|
9
|
+
//#region src/client/useDictionaryAsync.ts
|
|
10
|
+
/**
|
|
11
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
12
|
+
*
|
|
13
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
14
|
+
*/
|
|
6
15
|
const useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
const dictionary = await dictionaryPromise[localeTarget()]();
|
|
12
|
-
return useDictionary(dictionary, localeTarget());
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
useDictionaryAsync
|
|
16
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
17
|
+
const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
|
|
18
|
+
return useDictionary(await dictionaryPromise[localeTarget()]?.(), localeTarget());
|
|
16
19
|
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useDictionaryAsync };
|
|
17
23
|
//# sourceMappingURL=useDictionaryAsync.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\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 {\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAID,QAAO,cAFY,MAAM,kBAAkB,cAAc,KAAK,EAE7B,cAAc,CAAQ"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
4
|
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
5
5
|
import { useDictionary } from "./useDictionary.mjs";
|
|
6
6
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
7
|
+
import { computed, inject } from "@angular/core";
|
|
8
|
+
import configuration from "@intlayer/config/built";
|
|
9
|
+
|
|
10
|
+
//#region src/client/useDictionaryDynamic.ts
|
|
11
|
+
/**
|
|
12
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
13
|
+
*
|
|
14
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
15
|
+
*/
|
|
7
16
|
const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
-
const dictionary = useLoadDynamic(
|
|
13
|
-
`${String(key)}.${localeTarget()}`,
|
|
14
|
-
dictionaryPromise[localeTarget()]()
|
|
15
|
-
);
|
|
16
|
-
return useDictionary(dictionary, localeTarget());
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
useDictionaryDynamic
|
|
17
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
18
|
+
const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
|
|
19
|
+
return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useDictionaryDynamic };
|
|
21
24
|
//# sourceMappingURL=useDictionaryDynamic.mjs.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.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { computed, inject } from "@angular/core";
|
|
2
|
-
import { getIntlayer } from "../getIntlayer.mjs";
|
|
3
1
|
import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
|
|
2
|
+
import { getIntlayer } from "../getIntlayer.mjs";
|
|
3
|
+
import { computed, inject } from "@angular/core";
|
|
4
|
+
|
|
5
|
+
//#region src/client/useIntlayer.ts
|
|
6
|
+
/** guard utility - true only for objects generated by `renderIntlayerNode()` */
|
|
4
7
|
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
5
8
|
const useIntlayer = (key, locale) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
isUpdatableNode,
|
|
13
|
-
useIntlayer
|
|
9
|
+
const intlayer = inject(INTLAYER_TOKEN);
|
|
10
|
+
/** which locale should we use right now? */
|
|
11
|
+
const localeTarget = computed(() => locale ?? intlayer.locale());
|
|
12
|
+
return computed(() => getIntlayer(key, localeTarget()))();
|
|
14
13
|
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { isUpdatableNode, useIntlayer };
|
|
15
17
|
//# sourceMappingURL=useIntlayer.mjs.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.mjs","names":[],"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,WAAW,OAAyB,eAAe;;CAGzD,MAAM,eAAe,eAAe,UAAU,SAAS,QAAQ,CAAC;AAMhE,QAFgB,eAAe,YAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { signal } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/client/useLoadDynamic.ts
|
|
4
|
+
/**
|
|
5
|
+
* A "synchronous" loader for a dynamically‐imported JSON (or anything).
|
|
6
|
+
*
|
|
7
|
+
* - Immediately returns a reactive signal so that Angular can properly track changes.
|
|
8
|
+
* - When the Promise resolves, it replaces the signal's value with the real data.
|
|
9
|
+
*/
|
|
2
10
|
const useLoadDynamic = (key, promise) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return container();
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
useLoadDynamic
|
|
11
|
+
const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
|
|
12
|
+
const container = signal({});
|
|
13
|
+
if (!cache.has(key)) {
|
|
14
|
+
const p = promise.then((real) => {
|
|
15
|
+
container.set(real);
|
|
16
|
+
return real;
|
|
17
|
+
});
|
|
18
|
+
cache.set(key, p);
|
|
19
|
+
} else cache.get(key)?.then((real) => {
|
|
20
|
+
container.set(real);
|
|
21
|
+
});
|
|
22
|
+
return container();
|
|
20
23
|
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { useLoadDynamic };
|
|
21
27
|
//# sourceMappingURL=useLoadDynamic.mjs.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.mjs","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,YAAY,OAAO,EAAE,CAAM;AAEjC,KAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;AAE/B,aAAU,IAAI,KAAK;AACnB,UAAO;IACP;AACF,QAAM,IAAI,KAAK,EAAE;OAGjB,OAAM,IAAI,IAAI,EAAE,MAAM,SAAS;AAC7B,YAAU,IAAI,KAAK;GACnB;AAIJ,QAAO,WAAW"}
|