@tilde-nlp/ngx-common 8.1.61 → 8.1.63

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.
@@ -1848,7 +1848,7 @@ class LanguageTranslateService {
1848
1848
  return languageTranslate.transform(code, hideRegion);
1849
1849
  }
1850
1850
  removeRegionFromLanguageCode(code) {
1851
- return code.split('-')[0];
1851
+ return code?.split('-')[0];
1852
1852
  }
1853
1853
  static { this.ɵfac = function LanguageTranslateService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || LanguageTranslateService)(i0.ɵɵinject(i1.TranslateService)); }; }
1854
1854
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LanguageTranslateService, factory: LanguageTranslateService.ɵfac, providedIn: 'root' }); }
@@ -8715,12 +8715,12 @@ class AccessibilityService {
8715
8715
  this.#screenMask = inject(AccessibilityScreenMaskService);
8716
8716
  this.#storage = inject(USER_CONFIG_STORAGE, { optional: true });
8717
8717
  this.preferences = signal(DEFAULT_ACCESSIBILITY_PREFERENCES, ...(ngDevMode ? [{ debugName: "preferences" }] : []));
8718
- this.#readStorage();
8718
+ this.#updateValuesFromStorage();
8719
8719
  }
8720
8720
  toggleScreenMask() {
8721
8721
  const updatedStatus = !this.preferences().screenMaskEnabled;
8722
8722
  this.#screenMask.toggleScreenMask(updatedStatus);
8723
- this.#updateConfig({ screenMaskEnabled: updatedStatus });
8723
+ this.#updatePreferencesAndStorage({ screenMaskEnabled: updatedStatus });
8724
8724
  }
8725
8725
  closeFocusBar() {
8726
8726
  this.#screenMask.closeFocusBar();
@@ -8728,17 +8728,43 @@ class AccessibilityService {
8728
8728
  toggleTextMagnifier() {
8729
8729
  const updatedStatus = !this.preferences().textMagnifierEnabled;
8730
8730
  this.#textMagnifier.toggleTextMagnifier(updatedStatus);
8731
- this.#updateConfig({ textMagnifierEnabled: updatedStatus });
8731
+ this.#updatePreferencesAndStorage({ textMagnifierEnabled: updatedStatus });
8732
8732
  }
8733
8733
  setSavedTextMagnifierStatus() {
8734
- const currnetStatus = this.preferences().textMagnifierEnabled;
8735
- this.#textMagnifier.toggleTextMagnifier(currnetStatus);
8734
+ this.#updateMagnifierFromPreferences();
8736
8735
  }
8737
8736
  setSavedScreenMaskStatus() {
8738
- const currnetStatus = this.preferences().screenMaskEnabled;
8739
- this.#screenMask.toggleScreenMask(currnetStatus);
8737
+ this.#updateScreenMaskFromPreferences();
8740
8738
  }
8741
8739
  setFontSize(fontSizeIx) {
8740
+ this.#updatePreferencesAndStorage({ fontSizeIndex: fontSizeIx });
8741
+ }
8742
+ setContrast(contrast) {
8743
+ this.#updatePreferencesAndStorage({ contrast: contrast });
8744
+ }
8745
+ reset() {
8746
+ this.#updatePreferencesAndStorage({ ...DEFAULT_ACCESSIBILITY_PREFERENCES });
8747
+ }
8748
+ #updatePreferencesAndStorage(updates) {
8749
+ this.#updatePreferences(updates);
8750
+ this.#storage?.write({ accessibility: this.preferences() }).subscribe();
8751
+ }
8752
+ #updatePreferences(updates) {
8753
+ this.preferences.set({ ...this.preferences(), ...updates });
8754
+ this.#updateContrastFromPreferences();
8755
+ this.#updateFontSizeFromPreferences();
8756
+ this.#updateScreenMaskFromPreferences();
8757
+ this.#updateMagnifierFromPreferences();
8758
+ }
8759
+ #updateValuesFromStorage() {
8760
+ this.#storage?.read().subscribe(config => {
8761
+ if (config?.accessibility) {
8762
+ this.#updatePreferences({ ...config.accessibility });
8763
+ }
8764
+ });
8765
+ }
8766
+ #updateFontSizeFromPreferences() {
8767
+ const fontSizeIx = this.preferences().fontSizeIndex;
8742
8768
  const sizes = Object.values(AccessibilityFontSizes);
8743
8769
  if (fontSizeIx > 0) {
8744
8770
  this.sizeIncreaseSubject.next(true);
@@ -8747,26 +8773,18 @@ class AccessibilityService {
8747
8773
  this.sizeIncreaseSubject.next(false);
8748
8774
  }
8749
8775
  document.querySelector('html').style.fontSize = sizes[fontSizeIx];
8750
- this.#updateConfig({ fontSizeIndex: fontSizeIx });
8751
8776
  }
8752
- setContrast(contrast) {
8753
- this.contrastSubject.next(contrast);
8777
+ #updateContrastFromPreferences() {
8778
+ const contrast = this.preferences().contrast;
8754
8779
  document.querySelector('html').className = contrast;
8755
- this.#updateConfig({ contrast: contrast });
8756
8780
  }
8757
- reset() {
8758
- this.#updateConfig({ ...DEFAULT_ACCESSIBILITY_PREFERENCES });
8781
+ #updateMagnifierFromPreferences() {
8782
+ const isEnabled = this.preferences().textMagnifierEnabled;
8783
+ this.#textMagnifier.toggleTextMagnifier(isEnabled);
8759
8784
  }
8760
- #updateConfig(updates) {
8761
- this.preferences.set({ ...this.preferences(), ...updates });
8762
- this.#storage?.write({ accessibility: this.preferences() }).subscribe();
8763
- }
8764
- #readStorage() {
8765
- this.#storage?.read().subscribe(config => {
8766
- if (config?.accessibility) {
8767
- this.preferences.set({ ...config.accessibility });
8768
- }
8769
- });
8785
+ #updateScreenMaskFromPreferences() {
8786
+ const isEnabled = this.preferences().screenMaskEnabled;
8787
+ this.#screenMask.toggleScreenMask(isEnabled);
8770
8788
  }
8771
8789
  static { this.ɵfac = function AccessibilityService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AccessibilityService)(); }; }
8772
8790
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AccessibilityService, factory: AccessibilityService.ɵfac, providedIn: 'root' }); }