turbogui-angular 19.0.0 → 19.1.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Output, Directive, HostListener, NgModule, inject, Injectable, Component, Inject, HostBinding, Input } from '@angular/core';
2
+ import { EventEmitter, HostListener, Output, Directive, NgModule, inject, Injectable, Component, Inject, HostBinding, Input } from '@angular/core';
3
3
  import { Subject, BehaviorSubject } from 'rxjs';
4
4
  import { ArrayUtils, NumericUtils, HTTPManager, StringUtils, HTTPManagerGetRequest, HTTPManagerPostRequest, BrowserManager, ConversionUtils } from 'turbocommons-ts';
5
5
  import * as i1 from '@angular/material/dialog';
@@ -24,6 +24,47 @@ import { MatInputModule } from '@angular/material/input';
24
24
  import * as i5 from '@angular/forms';
25
25
  import { FormsModule, Validators } from '@angular/forms';
26
26
 
27
+ /**
28
+ * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
29
+ *
30
+ * Website : -> http://www.turbogui.org
31
+ * License : -> Licensed under the Apache License, Version 2.0. You may not use this file except in compliance with the License.
32
+ * License Url : -> http://www.apache.org/licenses/LICENSE-2.0
33
+ * CopyRight : -> Copyright 2018 Edertone Advanded Solutions. https://www.edertone.com
34
+ */
35
+ /** This directive is used to trigger an event when the user clicks outside of an element */
36
+ /**
37
+ * This directive is used to execute an action when the user clicks outside of an element.
38
+ * If we set the elementClickOutside tag to the html element and set the onClickOutside event to a function: <element elementClickOutside (onClickOutside)="onClickedOutside()" ...,
39
+ * this function will be executed when the user clicks outside of the element.
40
+ */
41
+ class ElementClickOutsideDirective {
42
+ constructor(elementRef) {
43
+ this.elementRef = elementRef;
44
+ this.onClickOutside = new EventEmitter();
45
+ }
46
+ onClick(targetElement) {
47
+ const clickedInside = this.elementRef.nativeElement.contains(targetElement);
48
+ if (!clickedInside) {
49
+ this.onClickOutside.emit();
50
+ }
51
+ }
52
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: ElementClickOutsideDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
53
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.5", type: ElementClickOutsideDirective, isStandalone: false, selector: "[elementClickOutside]", outputs: { onClickOutside: "onClickOutside" }, host: { listeners: { "document:click": "onClick($event.target)" } }, ngImport: i0 }); }
54
+ }
55
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: ElementClickOutsideDirective, decorators: [{
56
+ type: Directive,
57
+ args: [{
58
+ selector: '[elementClickOutside]',
59
+ standalone: false
60
+ }]
61
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { onClickOutside: [{
62
+ type: Output
63
+ }], onClick: [{
64
+ type: HostListener,
65
+ args: ['document:click', ['$event.target']]
66
+ }] } });
67
+
27
68
  /**
28
69
  * TurboGUI is A library that helps with the most common and generic UI elements and functionalities
29
70
  *
@@ -195,10 +236,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
195
236
  */
196
237
  class TurboGuiAngularModule {
197
238
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: TurboGuiAngularModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
198
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.5", ngImport: i0, type: TurboGuiAngularModule, declarations: [ElementCreatedDirective,
239
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.5", ngImport: i0, type: TurboGuiAngularModule, declarations: [ElementClickOutsideDirective,
240
+ ElementCreatedDirective,
199
241
  ElementDestroyedDirective,
200
242
  AutoFocusOnDisplayDirective,
201
- AutoSelectTextOnFocusDirective], exports: [ElementCreatedDirective,
243
+ AutoSelectTextOnFocusDirective], exports: [ElementClickOutsideDirective,
244
+ ElementCreatedDirective,
202
245
  ElementDestroyedDirective,
203
246
  AutoFocusOnDisplayDirective,
204
247
  AutoSelectTextOnFocusDirective] }); }
@@ -209,6 +252,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
209
252
  args: [{
210
253
  imports: [],
211
254
  declarations: [
255
+ ElementClickOutsideDirective,
212
256
  ElementCreatedDirective,
213
257
  ElementDestroyedDirective,
214
258
  AutoFocusOnDisplayDirective,
@@ -216,6 +260,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImpor
216
260
  ],
217
261
  providers: [],
218
262
  exports: [
263
+ ElementClickOutsideDirective,
219
264
  ElementCreatedDirective,
220
265
  ElementDestroyedDirective,
221
266
  AutoFocusOnDisplayDirective,
@@ -1777,18 +1822,19 @@ class LocalesBaseService {
1777
1822
  return this._missingKeyFormat;
1778
1823
  }
1779
1824
  /**
1780
- * Initializes the translation system by loading and parsing bundle files from the specified JSON object.
1781
- * After the method finishes, the class will contain all the translation data and will be ready to translate any provided key.
1825
+ * Adds translations to the class by loading and parsing bundles from the provided JSON object.
1826
+ * After the method finishes, the class will contain all the translation data and will be ready to translate
1827
+ * any provided key to any of the specified locales.
1782
1828
  *
1783
- * @param translations A JSON object containing the translation data. The structure must be as follows:
1784
- * { library_name: { bundle_name: { locale_code: { key1: "translation1", key2: "translation2" } } } ... }
1829
+ * @param locales An array of locale codes (e.g., ['en_US', 'es_ES', 'fr_FR']) to load from the json data into this class.
1830
+ * The order of this array will determine the priority when looking for translations.
1785
1831
  *
1786
- * @param locales An array of locale codes (e.g., ['en_US', 'es_ES', 'fr_FR']) to load into this class. The order of this array
1787
- * will determine the translation priority
1832
+ * @param json A JSON object containing the translation data. The structure must be as follows:
1833
+ * { library_name: { bundle_name: { locale_code: { key1: "translation1", key2: "translation2" } } } ... }
1788
1834
  *
1789
1835
  * @return True if the translations get correctly loaded. Any unsuccessful initialization will throw an exception
1790
1836
  */
1791
- initializeFromJson(translations, locales) {
1837
+ loadLocalesFromJson(locales, json) {
1792
1838
  this._isInitialized = false;
1793
1839
  // Validate received locales are correct
1794
1840
  for (const locale of locales) {
@@ -1796,9 +1842,9 @@ class LocalesBaseService {
1796
1842
  }
1797
1843
  // Validate the translations object follows the right structure
1798
1844
  let isTranslationsValid = false;
1799
- for (const library in translations) {
1800
- for (const bundle in translations[library]) {
1801
- for (const locale in translations[library][bundle]) {
1845
+ for (const library in json) {
1846
+ for (const bundle in json[library]) {
1847
+ for (const locale in json[library][bundle]) {
1802
1848
  this._validateLocaleString(locale);
1803
1849
  isTranslationsValid = true;
1804
1850
  }
@@ -1807,39 +1853,38 @@ class LocalesBaseService {
1807
1853
  if (!isTranslationsValid) {
1808
1854
  throw new Error('translations must be a non empty object with the structure: { library: { bundle: { xx_XX: { key: translation } } } }');
1809
1855
  }
1810
- this._loadedTranslations = translations;
1856
+ this._loadedTranslations = json;
1811
1857
  this._locales = locales;
1812
1858
  this._languages = locales.map((l) => l.substring(0, 2));
1813
1859
  this._cacheHashBaseString = this._wildCardsFormat + this._missingKeyFormat + this._locales[0];
1814
- return this._isInitialized = true;
1860
+ this._isInitialized = true;
1861
+ return true;
1815
1862
  }
1816
1863
  /**
1817
1864
  * Initializes the translation system by loading and parsing bundle files from the specified translations path.
1818
1865
  * After the promise finishes, the class will contain all the translation data and will be ready to translate any
1819
1866
  * provided key.
1820
1867
  *
1821
- * @param translationsPath - Url where the translations Json structure of libraries/bundles/locales/keys is available.
1822
- * @param locales An array of locale codes (e.g., ['en_US', 'es_ES', 'fr_FR']) to load. These will be added to the translation
1823
- * path using the following format: translationsPath/en_US-es_ES-fr_FR. The order of this array will determine the
1824
- * translation priority
1825
- * @param parameters Any extra parameters to be attached to the translationsPath after the locales like /param1/param2/ etc
1868
+ * @param locales An array of locale codes (['en_US', 'es_ES', 'fr_FR', ...]) to load from the url response.
1869
+ * The order of this array will determine the translation priority
1870
+ * @param url - Url where the translations are found. The response must be a Json with the expected structure:
1871
+ * { library_name: { bundle_name: { locale_code: { key1: "translation1", key2: "translation2" } } } ... }
1826
1872
  *
1827
1873
  * @return A promise that will resolve if the translations get correctly loaded, or reject with an error if load fails
1828
1874
  */
1829
- initializeFromUrl(translationsPath, locales, parameters) {
1875
+ loadLocalesFromUrl(locales, url) {
1830
1876
  this._isInitialized = false;
1831
- const translationsFullPath = translationsPath + '/' + locales.join('-') + '/' + parameters.join('/');
1832
1877
  return new Promise((resolve, reject) => {
1833
- fetch(translationsFullPath).then(response => {
1878
+ fetch(url).then(response => {
1834
1879
  if (!response.ok) {
1835
1880
  throw new Error(`HTTP error! status: ${response.status}`);
1836
1881
  }
1837
1882
  return response.json();
1838
1883
  }).then(data => {
1839
- this.initializeFromJson(data, locales);
1884
+ this.loadLocalesFromJson(locales, data);
1840
1885
  resolve(undefined);
1841
1886
  }).catch(error => {
1842
- reject(new Error(`ERROR LOADING LOCALES FROM: ${translationsFullPath}\n` + error));
1887
+ reject(new Error(`ERROR LOADING LOCALES FROM: ${url}\n` + error));
1843
1888
  });
1844
1889
  });
1845
1890
  }
@@ -2940,5 +2985,5 @@ class ValidatorsPlus extends Validators {
2940
2985
  * Generated bundle index. Do not edit.
2941
2986
  */
2942
2987
 
2943
- export { AutoFocusOnDisplayDirective, AutoSelectTextOnFocusDirective, BrowserService, BusyStateBaseComponent, ButtonContainerComponent, ButtonImageComponent, DelayedMethodCallManager, DialogBaseComponent, DialogDateSelectionComponent, DialogErrorComponent, DialogMultipleOptionComponent, DialogService, DialogSingleInputComponent, DialogSingleOptionComponent, DialogSingleSelectionListComponent, DialogTwoOptionComponent, ElementCreatedDirective, ElementDestroyedDirective, FadeAnimationClass, GUINotification, GlobalErrorService, HTTPService, HTTPServiceGetRequest, HTTPServicePostRequest, LocalesBaseService, NotificationService, RouterBaseService, SingletoneStrictClass, TurboApiCallerService, TurboGuiAngularModule, ValidatorsPlus, View, ViewService };
2988
+ export { AutoFocusOnDisplayDirective, AutoSelectTextOnFocusDirective, BrowserService, BusyStateBaseComponent, ButtonContainerComponent, ButtonImageComponent, DelayedMethodCallManager, DialogBaseComponent, DialogDateSelectionComponent, DialogErrorComponent, DialogMultipleOptionComponent, DialogService, DialogSingleInputComponent, DialogSingleOptionComponent, DialogSingleSelectionListComponent, DialogTwoOptionComponent, ElementClickOutsideDirective, ElementCreatedDirective, ElementDestroyedDirective, FadeAnimationClass, GUINotification, GlobalErrorService, HTTPService, HTTPServiceGetRequest, HTTPServicePostRequest, LocalesBaseService, NotificationService, RouterBaseService, SingletoneStrictClass, TurboApiCallerService, TurboGuiAngularModule, ValidatorsPlus, View, ViewService };
2944
2989
  //# sourceMappingURL=turbogui-angular.mjs.map