@mintplayer/ng-spark 0.0.6 → 0.0.7
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { signal, InjectionToken, Injectable, inject, Pipe, input, computed, ChangeDetectionStrategy, Component, model, output, effect } from '@angular/core';
|
|
3
3
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
4
4
|
import { firstValueFrom } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/common';
|
|
@@ -27,10 +27,12 @@ import { BsAlertComponent } from '@mintplayer/ng-bootstrap/alert';
|
|
|
27
27
|
import { BsContainerComponent } from '@mintplayer/ng-bootstrap/container';
|
|
28
28
|
import { BsButtonGroupComponent } from '@mintplayer/ng-bootstrap/button-group';
|
|
29
29
|
|
|
30
|
+
/** Global reactive language state — shared across library boundaries via globalThis */
|
|
31
|
+
const currentLanguage = (globalThis.__sparkCurrentLanguage ??= signal('en'));
|
|
30
32
|
function resolveTranslation(ts, lang) {
|
|
31
33
|
if (!ts)
|
|
32
34
|
return '';
|
|
33
|
-
const language = lang ??
|
|
35
|
+
const language = lang ?? currentLanguage();
|
|
34
36
|
return ts[language] ?? ts['en'] ?? Object.values(ts)[0] ?? '';
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -246,7 +248,9 @@ class SparkLanguageService {
|
|
|
246
248
|
const config = await firstValueFrom(this.http.get(`${this.baseUrl}/culture`));
|
|
247
249
|
this.languages.set(config.languages);
|
|
248
250
|
const saved = localStorage.getItem('spark-lang');
|
|
249
|
-
|
|
251
|
+
const lang = saved ?? config.defaultLanguage;
|
|
252
|
+
this.currentLang.set(lang);
|
|
253
|
+
currentLanguage.set(lang);
|
|
250
254
|
}
|
|
251
255
|
async loadTranslations() {
|
|
252
256
|
const t = await firstValueFrom(this.http.get(`${this.baseUrl}/translations`));
|
|
@@ -254,6 +258,7 @@ class SparkLanguageService {
|
|
|
254
258
|
}
|
|
255
259
|
setLanguage(lang) {
|
|
256
260
|
this.currentLang.set(lang);
|
|
261
|
+
currentLanguage.set(lang);
|
|
257
262
|
localStorage.setItem('spark-lang', lang);
|
|
258
263
|
}
|
|
259
264
|
resolve(ts) {
|
|
@@ -292,11 +297,11 @@ class ResolveTranslationPipe {
|
|
|
292
297
|
return resolveTranslation(value) || fallback || '';
|
|
293
298
|
}
|
|
294
299
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ResolveTranslationPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
295
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.6", ngImport: i0, type: ResolveTranslationPipe, isStandalone: true, name: "resolveTranslation" });
|
|
300
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.0.6", ngImport: i0, type: ResolveTranslationPipe, isStandalone: true, name: "resolveTranslation", pure: false });
|
|
296
301
|
}
|
|
297
302
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ResolveTranslationPipe, decorators: [{
|
|
298
303
|
type: Pipe,
|
|
299
|
-
args: [{ name: 'resolveTranslation', standalone: true, pure:
|
|
304
|
+
args: [{ name: 'resolveTranslation', standalone: true, pure: false }]
|
|
300
305
|
}] });
|
|
301
306
|
|
|
302
307
|
class InputTypePipe {
|
|
@@ -1986,5 +1991,5 @@ function provideSpark(config) {
|
|
|
1986
1991
|
* Generated bundle index. Do not edit.
|
|
1987
1992
|
*/
|
|
1988
1993
|
|
|
1989
|
-
export { ArrayValuePipe, AsDetailCellValuePipe, AsDetailColumnsPipe, AsDetailDisplayValuePipe, AsDetailTypePipe, AttributeValuePipe, CanCreateDetailRowPipe, CanDeleteDetailRowPipe, ELookupDisplayType, ErrorForAttributePipe, IconNamePipe, InlineRefOptionsPipe, InputTypePipe, LookupDisplayTypePipe, LookupDisplayValuePipe, LookupOptionsPipe, RawAttributeValuePipe, ReferenceAttrValuePipe, ReferenceDisplayValuePipe, ReferenceLinkRoutePipe, ResolveTranslationPipe, RetryActionService, RouterLinkPipe, SPARK_ATTRIBUTE_RENDERERS, SPARK_CONFIG, ShowedOn, SparkIconComponent, SparkIconRegistry, SparkLanguageService, SparkPoCreateComponent, SparkPoDetailComponent, SparkPoEditComponent, SparkPoFormComponent, SparkQueryListComponent, SparkRetryActionModalComponent, SparkService, SparkSubQueryComponent, TranslateKeyPipe, defaultSparkConfig, hasShowedOnFlag, provideSpark, provideSparkAttributeRenderers, resolveTranslation, sparkRoutes };
|
|
1994
|
+
export { ArrayValuePipe, AsDetailCellValuePipe, AsDetailColumnsPipe, AsDetailDisplayValuePipe, AsDetailTypePipe, AttributeValuePipe, CanCreateDetailRowPipe, CanDeleteDetailRowPipe, ELookupDisplayType, ErrorForAttributePipe, IconNamePipe, InlineRefOptionsPipe, InputTypePipe, LookupDisplayTypePipe, LookupDisplayValuePipe, LookupOptionsPipe, RawAttributeValuePipe, ReferenceAttrValuePipe, ReferenceDisplayValuePipe, ReferenceLinkRoutePipe, ResolveTranslationPipe, RetryActionService, RouterLinkPipe, SPARK_ATTRIBUTE_RENDERERS, SPARK_CONFIG, ShowedOn, SparkIconComponent, SparkIconRegistry, SparkLanguageService, SparkPoCreateComponent, SparkPoDetailComponent, SparkPoEditComponent, SparkPoFormComponent, SparkQueryListComponent, SparkRetryActionModalComponent, SparkService, SparkSubQueryComponent, TranslateKeyPipe, currentLanguage, defaultSparkConfig, hasShowedOnFlag, provideSpark, provideSparkAttributeRenderers, resolveTranslation, sparkRoutes };
|
|
1990
1995
|
//# sourceMappingURL=mintplayer-ng-spark.mjs.map
|