@bravobit/bb-foundation 0.42.0 → 0.42.2

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.
Files changed (194) hide show
  1. package/auth/lib/auth.interceptor.d.ts +3 -6
  2. package/auth/lib/auth.service.d.ts +11 -16
  3. package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +2 -5
  4. package/dialog/lib/dialog-container/dialog-container.component.d.ts +4 -6
  5. package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +5 -7
  6. package/esm2022/auth/lib/auth.interceptor.mjs +36 -42
  7. package/esm2022/auth/lib/auth.module.mjs +4 -4
  8. package/esm2022/auth/lib/auth.service.mjs +25 -41
  9. package/esm2022/auth/lib/auth.session.mjs +26 -22
  10. package/esm2022/auth/lib/directives/authenticated.directive.mjs +16 -12
  11. package/esm2022/auth/lib/helpers/jwt.helper.mjs +29 -31
  12. package/esm2022/auth/lib/providers/email.provider.mjs +4 -1
  13. package/esm2022/auth/lib/providers/verify.provider.mjs +4 -1
  14. package/esm2022/collections/lib/collection.mjs +17 -7
  15. package/esm2022/collections/lib/collections.module.mjs +6 -6
  16. package/esm2022/collections/lib/components/collections-actions/collections-actions.component.mjs +7 -9
  17. package/esm2022/collections/lib/components/collections-grid/collections-grid.component.mjs +11 -11
  18. package/esm2022/collections/lib/components/collections-pager/collections-pager.component.mjs +10 -10
  19. package/esm2022/collections/lib/components/collections-table/collections-table.component.mjs +16 -16
  20. package/esm2022/collections/lib/components/collections-table-label/collections-table-label.component.mjs +9 -11
  21. package/esm2022/collections/lib/components/collections-table-sorting/collections-table-sorting.component.mjs +12 -9
  22. package/esm2022/collections/lib/components/collections-viewer/collections-viewer.component.mjs +10 -7
  23. package/esm2022/collections/lib/directives/collections-data-row.directive.mjs +6 -3
  24. package/esm2022/collections/lib/directives/collections-data.directive.mjs +6 -3
  25. package/esm2022/collections/lib/directives/collections-empty.directive.mjs +6 -3
  26. package/esm2022/collections/lib/directives/collections-error.directive.mjs +6 -3
  27. package/esm2022/collections/lib/directives/collections-initial.directive.mjs +4 -3
  28. package/esm2022/collections/lib/directives/collections-item.directive.mjs +6 -3
  29. package/esm2022/collections/lib/providers/api-collection.provider.mjs +6 -4
  30. package/esm2022/collections/lib/providers/local-collection.provider.mjs +2 -2
  31. package/esm2022/combobox/combobox/combobox-container.directive.mjs +12 -7
  32. package/esm2022/combobox/combobox/combobox.component.mjs +23 -20
  33. package/esm2022/combobox/combobox-label.directive.mjs +3 -3
  34. package/esm2022/combobox/combobox-option.directive.mjs +3 -3
  35. package/esm2022/combobox/combobox-panel/combobox-panel.component.mjs +10 -6
  36. package/esm2022/dashboard/lib/dashboard/dashboard.component.mjs +13 -13
  37. package/esm2022/dashboard/lib/dashboard-header/dashboard-header.component.mjs +5 -7
  38. package/esm2022/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +8 -10
  39. package/esm2022/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +5 -7
  40. package/esm2022/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +12 -13
  41. package/esm2022/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +13 -12
  42. package/esm2022/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +7 -5
  43. package/esm2022/dashboard/lib/dashboard.module.mjs +5 -5
  44. package/esm2022/dialog/lib/dialog-actions/dialog-actions.component.mjs +3 -3
  45. package/esm2022/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +21 -20
  46. package/esm2022/dialog/lib/dialog-container/dialog-container.component.mjs +19 -24
  47. package/esm2022/dialog/lib/dialog-header/dialog-header.component.mjs +5 -7
  48. package/esm2022/dialog/lib/dialog-link/dialog-link.component.mjs +3 -3
  49. package/esm2022/dialog/lib/dialog-modal/dialog-modal.component.mjs +9 -6
  50. package/esm2022/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +19 -26
  51. package/esm2022/dialog/lib/dialog.insertion.mjs +4 -3
  52. package/esm2022/dialog/lib/dialog.interfaces.mjs +4 -1
  53. package/esm2022/dialog/lib/dialog.module.mjs +6 -6
  54. package/esm2022/dialog/lib/dialog.ref.mjs +4 -6
  55. package/esm2022/dialog/lib/dialog.service.mjs +5 -3
  56. package/esm2022/dialog/lib/directives/confirm.directive.mjs +12 -14
  57. package/esm2022/elements/lib/avatar/avatar.component.mjs +75 -77
  58. package/esm2022/elements/lib/button/button.component.mjs +12 -10
  59. package/esm2022/elements/lib/checkbox/checkbox.component.mjs +21 -17
  60. package/esm2022/elements/lib/checkbox-group/checkbox-group.component.mjs +8 -10
  61. package/esm2022/elements/lib/date-picker/date-picker.component.mjs +82 -76
  62. package/esm2022/elements/lib/directives/addon.directive.mjs +5 -5
  63. package/esm2022/elements/lib/directives/extra-error-controls.directive.mjs +7 -9
  64. package/esm2022/elements/lib/directives/form-submit.directive.mjs +6 -3
  65. package/esm2022/elements/lib/directives/form-submitter.directive.mjs +5 -7
  66. package/esm2022/elements/lib/directives/image-upload.directive.mjs +14 -11
  67. package/esm2022/elements/lib/directives/input.directive.mjs +6 -4
  68. package/esm2022/elements/lib/elements.module.mjs +6 -6
  69. package/esm2022/elements/lib/file-picker/file-picker.component.mjs +52 -51
  70. package/esm2022/elements/lib/form-control/form-control.component.mjs +14 -14
  71. package/esm2022/elements/lib/form-error/form-error.component.mjs +16 -8
  72. package/esm2022/elements/lib/form-group/form-group.component.mjs +5 -7
  73. package/esm2022/elements/lib/icon/icon.component.mjs +14 -13
  74. package/esm2022/elements/lib/image-picker/image-picker.component.mjs +20 -17
  75. package/esm2022/elements/lib/multi-file-control/multi-file-control.component.mjs +28 -24
  76. package/esm2022/elements/lib/pipes/date.pipe.mjs +6 -8
  77. package/esm2022/elements/lib/pipes/file-image.pipe.mjs +6 -3
  78. package/esm2022/elements/lib/pipes/file-size.pipe.mjs +13 -15
  79. package/esm2022/elements/lib/pipes/relative-time.pipe.mjs +37 -35
  80. package/esm2022/elements/lib/radio-button/radio-button.component.mjs +8 -7
  81. package/esm2022/elements/lib/radio-group/radio-group.component.mjs +21 -20
  82. package/esm2022/elements/lib/spinner/spinner.component.mjs +7 -9
  83. package/esm2022/http/lib/classes/http.config.mjs +19 -15
  84. package/esm2022/http/lib/http.interfaces.mjs +1 -1
  85. package/esm2022/http/lib/http.module.mjs +5 -4
  86. package/esm2022/http/lib/interceptors/base-url.interceptor.mjs +12 -20
  87. package/esm2022/http/lib/interceptors/error.interceptor.mjs +9 -14
  88. package/esm2022/lib/core/services/exif.service.mjs +102 -100
  89. package/esm2022/lib/core/services/file-loader.service.mjs +15 -17
  90. package/esm2022/lib/core/services/files.service.mjs +9 -17
  91. package/esm2022/lib/core/services/image-converter.service.mjs +33 -30
  92. package/esm2022/lib/core/services/languages.service.mjs +25 -24
  93. package/esm2022/lib/core/services/network.service.mjs +8 -5
  94. package/esm2022/lib/core/services/patch.service.mjs +9 -6
  95. package/esm2022/localize/lib/dictionary/dictionary.class.mjs +7 -1
  96. package/esm2022/localize/lib/dictionary/dictionary.context.mjs +2 -4
  97. package/esm2022/localize/lib/dictionary/dictionary.data.mjs +2 -1
  98. package/esm2022/localize/lib/handlers/missing.handler.mjs +2 -4
  99. package/esm2022/localize/lib/localize.module.mjs +5 -5
  100. package/esm2022/localize/lib/localize.pipe.mjs +4 -3
  101. package/esm2022/localize/lib/localize.service.mjs +36 -62
  102. package/esm2022/localize/lib/transforms/interpolate.transform.mjs +12 -22
  103. package/esm2022/localize/lib/transforms/plural.transform.mjs +9 -18
  104. package/esm2022/localize/lib/transforms/reference.transform.mjs +7 -15
  105. package/esm2022/localize/lib/views/localize-string/localize-string.component.mjs +14 -11
  106. package/esm2022/localize/lib/views/localize-template.directive.mjs +6 -5
  107. package/esm2022/masking/lib/directives/currency-mask.directive.mjs +11 -6
  108. package/esm2022/masking/lib/directives/date-mask.directive.mjs +11 -6
  109. package/esm2022/masking/lib/directives/input-mask.directive.mjs +21 -14
  110. package/esm2022/masking/lib/masking.module.mjs +5 -5
  111. package/esm2022/masking/lib/masking.service.mjs +4 -3
  112. package/esm2022/notifications/lib/notifications-item/notifications-item.component.mjs +50 -36
  113. package/esm2022/notifications/lib/notifications-list/notifications-list.component.mjs +8 -7
  114. package/esm2022/notifications/lib/notifications.interfaces.mjs +10 -1
  115. package/esm2022/notifications/lib/notifications.module.mjs +4 -4
  116. package/esm2022/notifications/lib/notifications.service.mjs +24 -10
  117. package/esm2022/permissions/lib/directives/permission.directive.mjs +20 -14
  118. package/esm2022/permissions/lib/handlers/local.handler.mjs +3 -1
  119. package/esm2022/permissions/lib/permissions.interface.mjs +4 -1
  120. package/esm2022/permissions/lib/permissions.module.mjs +4 -4
  121. package/esm2022/permissions/lib/permissions.service.mjs +8 -7
  122. package/esm2022/recaptcha/lib/recaptcha/recaptcha.component.mjs +35 -28
  123. package/esm2022/recaptcha/lib/recaptcha-loader.service.mjs +15 -15
  124. package/esm2022/recaptcha/lib/recaptcha.module.mjs +4 -4
  125. package/esm2022/select/lib/select/select.component.mjs +52 -47
  126. package/esm2022/select/lib/select-label.directive.mjs +4 -3
  127. package/esm2022/select/lib/select-multi-label.directive.mjs +4 -3
  128. package/esm2022/select/lib/select-option-group.directive.mjs +4 -3
  129. package/esm2022/select/lib/select-option.directive.mjs +4 -3
  130. package/esm2022/select/lib/select.module.mjs +5 -5
  131. package/esm2022/storage/lib/storage.service.mjs +25 -21
  132. package/esm2022/storage/lib/strategies/cookie-storage.strategy.mjs +66 -64
  133. package/esm2022/storage/lib/strategies/memory-storage.strategy.mjs +16 -18
  134. package/esm2022/storage/lib/strategies/polyfill-storage.strategy.mjs +31 -30
  135. package/esm2022/table/lib/components/table/table.component.mjs +30 -20
  136. package/esm2022/table/lib/components/table-cell/table-cell.component.mjs +3 -3
  137. package/esm2022/table/lib/components/table-header-cell/table-header-cell.component.mjs +15 -11
  138. package/esm2022/table/lib/components/table-pager/table-pager.component.mjs +18 -16
  139. package/esm2022/table/lib/data/datasource.data.mjs +4 -6
  140. package/esm2022/table/lib/data/generic.data.mjs +38 -36
  141. package/esm2022/table/lib/table.module.mjs +6 -6
  142. package/esm2022/tooltip/lib/tooltip-container/tooltip-container.component.mjs +5 -7
  143. package/esm2022/tooltip/lib/tooltip.directive.mjs +15 -15
  144. package/esm2022/tooltip/lib/tooltip.module.mjs +4 -4
  145. package/esm2022/utils/lib/directives/autosize.directive.mjs +9 -7
  146. package/esm2022/utils/lib/directives/focus-trap.directive.mjs +24 -22
  147. package/esm2022/utils/lib/directives/focus.directive.mjs +8 -5
  148. package/esm2022/utils/lib/directives/template.directive.mjs +7 -3
  149. package/esm2022/utils/lib/utils.module.mjs +5 -5
  150. package/fesm2022/bravobit-bb-foundation-auth.mjs +134 -144
  151. package/fesm2022/bravobit-bb-foundation-auth.mjs.map +1 -1
  152. package/fesm2022/bravobit-bb-foundation-collections.mjs +123 -93
  153. package/fesm2022/bravobit-bb-foundation-collections.mjs.map +1 -1
  154. package/fesm2022/bravobit-bb-foundation-combobox.mjs +46 -34
  155. package/fesm2022/bravobit-bb-foundation-combobox.mjs.map +1 -1
  156. package/fesm2022/bravobit-bb-foundation-dashboard.mjs +60 -64
  157. package/fesm2022/bravobit-bb-foundation-dashboard.mjs.map +1 -1
  158. package/fesm2022/bravobit-bb-foundation-dialog.mjs +97 -103
  159. package/fesm2022/bravobit-bb-foundation-dialog.mjs.map +1 -1
  160. package/fesm2022/bravobit-bb-foundation-elements.mjs +468 -440
  161. package/fesm2022/bravobit-bb-foundation-elements.mjs.map +1 -1
  162. package/fesm2022/bravobit-bb-foundation-http.mjs +40 -46
  163. package/fesm2022/bravobit-bb-foundation-http.mjs.map +1 -1
  164. package/fesm2022/bravobit-bb-foundation-localize.mjs +91 -130
  165. package/fesm2022/bravobit-bb-foundation-localize.mjs.map +1 -1
  166. package/fesm2022/bravobit-bb-foundation-masking.mjs +47 -29
  167. package/fesm2022/bravobit-bb-foundation-masking.mjs.map +1 -1
  168. package/fesm2022/bravobit-bb-foundation-notifications.mjs +91 -53
  169. package/fesm2022/bravobit-bb-foundation-notifications.mjs.map +1 -1
  170. package/fesm2022/bravobit-bb-foundation-permissions.mjs +34 -22
  171. package/fesm2022/bravobit-bb-foundation-permissions.mjs.map +1 -1
  172. package/fesm2022/bravobit-bb-foundation-recaptcha.mjs +51 -44
  173. package/fesm2022/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
  174. package/fesm2022/bravobit-bb-foundation-select.mjs +67 -58
  175. package/fesm2022/bravobit-bb-foundation-select.mjs.map +1 -1
  176. package/fesm2022/bravobit-bb-foundation-storage.mjs +134 -129
  177. package/fesm2022/bravobit-bb-foundation-storage.mjs.map +1 -1
  178. package/fesm2022/bravobit-bb-foundation-table.mjs +107 -91
  179. package/fesm2022/bravobit-bb-foundation-table.mjs.map +1 -1
  180. package/fesm2022/bravobit-bb-foundation-tooltip.mjs +21 -23
  181. package/fesm2022/bravobit-bb-foundation-tooltip.mjs.map +1 -1
  182. package/fesm2022/bravobit-bb-foundation-utils.mjs +48 -37
  183. package/fesm2022/bravobit-bb-foundation-utils.mjs.map +1 -1
  184. package/fesm2022/bravobit-bb-foundation.mjs +194 -191
  185. package/fesm2022/bravobit-bb-foundation.mjs.map +1 -1
  186. package/http/lib/http.interfaces.d.ts +2 -1
  187. package/http/lib/interceptors/base-url.interceptor.d.ts +2 -4
  188. package/http/lib/interceptors/error.interceptor.d.ts +1 -3
  189. package/lib/core/services/files.service.d.ts +3 -7
  190. package/localize/lib/localize.service.d.ts +10 -14
  191. package/localize/lib/transforms/interpolate.transform.d.ts +4 -5
  192. package/localize/lib/transforms/plural.transform.d.ts +5 -6
  193. package/localize/lib/transforms/reference.transform.d.ts +2 -3
  194. package/package.json +39 -39
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, PLATFORM_ID, Injectable, Inject, makeEnvironmentProviders, NgModule, Optional, SkipSelf } from '@angular/core';
2
+ import { InjectionToken, inject, PLATFORM_ID, Injectable, makeEnvironmentProviders, NgModule, Optional, SkipSelf } from '@angular/core';
3
3
  import { HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
4
4
  import { isPlatformServer } from '@angular/common';
5
5
  import { catchError } from 'rxjs/operators';
@@ -9,21 +9,11 @@ const HTTP_CONFIG = new InjectionToken('http config');
9
9
  const HTTP_CONFIG_DATA = new InjectionToken('http config data');
10
10
 
11
11
  class HttpConfig {
12
+ aliases;
13
+ prefix;
14
+ defaultAlias;
15
+ disableErrorParsing;
12
16
  constructor(data) {
13
- this.parseAliases = (value, standardAlias) => {
14
- if (!Array.isArray(value)) {
15
- value = [{ alias: standardAlias, url: value }];
16
- }
17
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
18
- const stringRegex = /^[a-zA-Z]+$/;
19
- for (const item of value) {
20
- if (!!item?.alias && !stringRegex.test(item?.alias)) {
21
- console?.warn?.(`[HttpModule]: Invalid HTTP-alias in HttpConfig named "${item?.alias}"; only latin characters should be used.`);
22
- }
23
- }
24
- }
25
- return value;
26
- };
27
17
  // Get the data from the config.
28
18
  this.prefix = data?.alias?.prefix ?? '$';
29
19
  this.disableErrorParsing = data?.disableErrorParsing ?? false;
@@ -34,6 +24,20 @@ class HttpConfig {
34
24
  const firstAvailableAlias = this.aliases?.[0]?.alias ?? null;
35
25
  this.defaultAlias = `${this.prefix}${firstAvailableAlias}`;
36
26
  }
27
+ parseAliases = (value, standardAlias) => {
28
+ if (!Array.isArray(value)) {
29
+ value = [{ alias: standardAlias, url: value }];
30
+ }
31
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
32
+ const stringRegex = /^[a-zA-Z]+$/;
33
+ for (const item of value) {
34
+ if (!!item?.alias && !stringRegex.test(item?.alias)) {
35
+ console?.warn?.(`[HttpModule]: Invalid HTTP-alias in HttpConfig named "${item?.alias}"; only latin characters should be used.`);
36
+ }
37
+ }
38
+ }
39
+ return value;
40
+ };
37
41
  }
38
42
 
39
43
  class HttpError extends HttpErrorResponse {
@@ -56,14 +60,13 @@ class HttpError extends HttpErrorResponse {
56
60
  }
57
61
 
58
62
  class BaseUrlInterceptor {
59
- constructor(_config, _platformId) {
60
- this._config = _config;
61
- this._platformId = _platformId;
62
- // Aliases.
63
- this._aliases = this._config?.aliases;
64
- this._prefix = this._config?.prefix;
65
- this._extractRegex = new RegExp(`\\${this._prefix}[a-zA-Z]+`);
66
- }
63
+ // Dependencies.
64
+ _config = inject(HTTP_CONFIG);
65
+ _platformId = inject(PLATFORM_ID);
66
+ // Aliases.
67
+ _aliases = this._config?.aliases;
68
+ _prefix = this._config?.prefix;
69
+ _extractRegex = new RegExp(`\\${this._prefix}[a-zA-Z]+`);
67
70
  intercept(request, next) {
68
71
  const url = this.getUrlBasedOnAlias(request.url);
69
72
  const modified = request.clone({ url });
@@ -105,25 +108,18 @@ class BaseUrlInterceptor {
105
108
  }
106
109
  return null;
107
110
  }
108
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BaseUrlInterceptor, deps: [{ token: HTTP_CONFIG }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
109
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BaseUrlInterceptor }); }
111
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BaseUrlInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
112
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BaseUrlInterceptor });
110
113
  }
111
114
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BaseUrlInterceptor, decorators: [{
112
115
  type: Injectable
113
- }], ctorParameters: () => [{ type: HttpConfig, decorators: [{
114
- type: Inject,
115
- args: [HTTP_CONFIG]
116
- }] }, { type: Object, decorators: [{
117
- type: Inject,
118
- args: [PLATFORM_ID]
119
- }] }] });
116
+ }] });
120
117
 
121
118
  class ErrorInterceptor {
122
- constructor(_config) {
123
- this._config = _config;
124
- // State.
125
- this._disabled = this._config?.disableErrorParsing ?? false;
126
- }
119
+ // Dependencies.
120
+ _config = inject(HTTP_CONFIG);
121
+ // State.
122
+ _disabled = this._config?.disableErrorParsing ?? false;
127
123
  intercept(request, next) {
128
124
  return next.handle(request).pipe(catchError(error => {
129
125
  // If we have a matching http error response
@@ -136,15 +132,12 @@ class ErrorInterceptor {
136
132
  return throwError(() => error);
137
133
  }));
138
134
  }
139
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: ErrorInterceptor, deps: [{ token: HTTP_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
140
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: ErrorInterceptor }); }
135
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: ErrorInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
136
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: ErrorInterceptor });
141
137
  }
142
138
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: ErrorInterceptor, decorators: [{
143
139
  type: Injectable
144
- }], ctorParameters: () => [{ type: HttpConfig, decorators: [{
145
- type: Inject,
146
- args: [HTTP_CONFIG]
147
- }] }] });
140
+ }] });
148
141
 
149
142
  function provideHttpConfig(config) {
150
143
  return makeEnvironmentProviders([
@@ -159,6 +152,7 @@ function createHttpConfig(data) {
159
152
  }
160
153
 
161
154
  class HttpModule {
155
+ _parent;
162
156
  constructor(_parent) {
163
157
  this._parent = _parent;
164
158
  if (this._parent) {
@@ -173,9 +167,9 @@ class HttpModule {
173
167
  ]
174
168
  };
175
169
  }
176
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: HttpModule, deps: [{ token: HttpModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
177
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: HttpModule }); }
178
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: HttpModule }); }
170
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: HttpModule, deps: [{ token: HttpModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule });
171
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: HttpModule });
172
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: HttpModule });
179
173
  }
180
174
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: HttpModule, decorators: [{
181
175
  type: NgModule
@@ -1 +1 @@
1
- {"version":3,"file":"bravobit-bb-foundation-http.mjs","sources":["../../../projects/bb-foundation/http/src/lib/http.interfaces.ts","../../../projects/bb-foundation/http/src/lib/classes/http.config.ts","../../../projects/bb-foundation/http/src/lib/classes/http.error.ts","../../../projects/bb-foundation/http/src/lib/interceptors/base-url.interceptor.ts","../../../projects/bb-foundation/http/src/lib/interceptors/error.interceptor.ts","../../../projects/bb-foundation/http/src/lib/http.config.ts","../../../projects/bb-foundation/http/src/lib/http.module.ts","../../../projects/bb-foundation/http/src/bravobit-bb-foundation-http.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\n\nexport interface HttpConfigData {\n url: HttpConfigUrl;\n alias?: {\n prefix?: string;\n standard?: string;\n };\n disableErrorParsing?: boolean;\n}\n\nexport type HttpConfigPlatformUrl = string | { browser: string, server: string };\nexport type HttpConfigAlias = { alias: string, url: HttpConfigPlatformUrl };\nexport type HttpConfigUrl = HttpConfigPlatformUrl | HttpConfigAlias[];\n\nexport const HTTP_CONFIG = new InjectionToken<HttpConfigData>('http config');\nexport const HTTP_CONFIG_DATA = new InjectionToken<HttpConfigData>('http config data');\n","import {HttpConfigAlias, HttpConfigData, HttpConfigUrl} from '../http.interfaces';\n\ndeclare let ngDevMode;\n\nexport class HttpConfig {\n\n readonly aliases: HttpConfigAlias[];\n readonly prefix: string;\n readonly defaultAlias: string;\n readonly disableErrorParsing: boolean;\n\n constructor(data: HttpConfigData) {\n // Get the data from the config.\n this.prefix = data?.alias?.prefix ?? '$';\n this.disableErrorParsing = data?.disableErrorParsing ?? false;\n\n // Parse the aliases.\n const standardAlias = data?.alias?.standard ?? 'api';\n this.aliases = this.parseAliases(data?.url, standardAlias);\n\n // Get the default alias.\n const firstAvailableAlias = this.aliases?.[0]?.alias ?? null;\n this.defaultAlias = `${this.prefix}${firstAvailableAlias}`;\n }\n\n private parseAliases = (value: HttpConfigUrl, standardAlias: string) => {\n if (!Array.isArray(value)) {\n value = [{alias: standardAlias, url: value}];\n }\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const stringRegex = /^[a-zA-Z]+$/;\n for (const item of value) {\n if (!!item?.alias && !stringRegex.test(item?.alias)) {\n console?.warn?.(`[HttpModule]: Invalid HTTP-alias in HttpConfig named \"${item?.alias}\"; only latin characters should be used.`);\n }\n }\n }\n\n return value;\n };\n\n}\n","import {HttpErrorResponse} from '@angular/common/http';\n\nexport class HttpError extends HttpErrorResponse {\n\n constructor(error: HttpErrorResponse) {\n super(error);\n }\n\n get<T = any>(token: string, delimiter: string = '.') {\n const error = this.error ?? {};\n return (token ?? '')\n .split(delimiter)\n .reduce((previous, current) => previous?.[current] ? previous?.[current] : null, error) as T;\n }\n\n has(token: string, delimiter: string = '.') {\n return !!this.get(token, delimiter);\n }\n\n includes<T = any>(token: string, value: T) {\n const array = this.get<T[]>(token);\n return (array ?? []).includes(value);\n }\n\n}\n","import {HTTP_CONFIG, HttpConfigAlias, HttpConfigPlatformUrl} from '../http.interfaces';\nimport {HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {Inject, Injectable, PLATFORM_ID} from '@angular/core';\nimport {HttpConfig} from '../classes/http.config';\nimport {isPlatformServer} from '@angular/common';\n\ndeclare let ngDevMode;\n\n@Injectable()\nexport class BaseUrlInterceptor implements HttpInterceptor {\n\n // Aliases.\n private readonly _aliases: HttpConfigAlias[] = this._config?.aliases;\n private readonly _prefix: string = this._config?.prefix;\n private readonly _extractRegex: RegExp = new RegExp(`\\\\${this._prefix}[a-zA-Z]+`);\n\n constructor(@Inject(HTTP_CONFIG) private _config: HttpConfig,\n @Inject(PLATFORM_ID) private _platformId: Object) {\n }\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler) {\n const url = this.getUrlBasedOnAlias(request.url);\n const modified = request.clone({url});\n\n return next.handle(modified);\n }\n\n private getUrlBasedOnAlias(url: string) {\n const matches = this._extractRegex.exec(url);\n if (!matches) {\n return url;\n }\n\n return matches.reduce((previous, current) => {\n const alias = this.getAlias(current);\n const stringAlias = this.convertUrlToString(alias?.url);\n if (!stringAlias) {\n return previous;\n }\n\n return previous.replace(current, stringAlias);\n }, url);\n }\n\n private convertUrlToString(url: HttpConfigPlatformUrl) {\n if (typeof url === 'string') {\n return url;\n }\n\n return isPlatformServer(this._platformId)\n ? url?.server ?? url?.browser ?? null\n : url?.browser ?? null;\n }\n\n private getAlias(value: string) {\n const alias = value.replace(this._prefix, '');\n const fetched = this._aliases?.find(item => item.alias === alias) ?? null;\n if (fetched) {\n return fetched;\n }\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const available = this._aliases\n .map(item => `\\$${item?.alias}`)\n .join(', ');\n console?.warn?.(`[HttpModule]: Used an invalid HTTP-alias named \"${value}\", skipped parsing; Available aliases is one of (${available}).`);\n }\n\n return null;\n }\n\n}\n","import {HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {HttpConfig} from '../classes/http.config';\nimport {Inject, Injectable} from '@angular/core';\nimport {HttpError} from '../classes/http.error';\nimport {HTTP_CONFIG} from '../http.interfaces';\nimport {catchError} from 'rxjs/operators';\nimport {throwError} from 'rxjs';\n\n@Injectable()\nexport class ErrorInterceptor implements HttpInterceptor {\n\n // State.\n private readonly _disabled = this._config?.disableErrorParsing ?? false;\n\n constructor(@Inject(HTTP_CONFIG) private _config: HttpConfig) {\n }\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler) {\n return next.handle(request).pipe(\n catchError(error => {\n // If we have a matching http error response\n // re-map it with our custom class (if not disabled).\n if (!this._disabled && error instanceof HttpErrorResponse) {\n const parsed = new HttpError(error);\n return throwError(() => parsed);\n }\n\n // We did not match anything, just re-trow the error.\n return throwError(() => error);\n })\n );\n }\n\n}\n","import {HTTP_CONFIG, HTTP_CONFIG_DATA, HttpConfigData} from './http.interfaces';\nimport {EnvironmentProviders, makeEnvironmentProviders} from '@angular/core';\nimport {BaseUrlInterceptor} from './interceptors/base-url.interceptor';\nimport {ErrorInterceptor} from './interceptors/error.interceptor';\nimport {HTTP_INTERCEPTORS} from '@angular/common/http';\nimport {HttpConfig} from './classes/http.config';\n\nexport function provideHttpConfig(config: HttpConfigData): EnvironmentProviders {\n return makeEnvironmentProviders([\n {provide: HTTP_CONFIG_DATA, useValue: config},\n {provide: HTTP_CONFIG, useFactory: createHttpConfig, deps: [HTTP_CONFIG_DATA]},\n {provide: HTTP_INTERCEPTORS, useClass: BaseUrlInterceptor, multi: true},\n {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}\n ]);\n}\n\nexport function createHttpConfig(data: HttpConfigData) {\n return new HttpConfig(data);\n}\n","import {ModuleWithProviders, NgModule, Optional, SkipSelf} from '@angular/core';\nimport {HttpConfigData} from './http.interfaces';\nimport {provideHttpConfig} from './http.config';\n\n@NgModule()\nexport class HttpModule {\n\n constructor(@Optional() @SkipSelf() private _parent?: HttpModule) {\n if (this._parent) {\n throw new Error('HttpModule is already loaded; Import it in the core module only.');\n }\n }\n\n static forRoot(config: HttpConfigData): ModuleWithProviders<HttpModule> {\n return {\n ngModule: HttpModule,\n providers: [\n provideHttpConfig(config)\n ]\n };\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;MAea,WAAW,GAAG,IAAI,cAAc,CAAiB,aAAa,EAAE;MAChE,gBAAgB,GAAG,IAAI,cAAc,CAAiB,kBAAkB;;MCZxE,UAAU,CAAA;AAOnB,IAAA,WAAA,CAAY,IAAoB,EAAA;AAcxB,QAAA,IAAA,CAAA,YAAY,GAAG,CAAC,KAAoB,EAAE,aAAqB,KAAI;YACnE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,gBAAA,KAAK,GAAG,CAAC,EAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;aAC/C;AAED,YAAA,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,EAAE;gBAC/C,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,gBAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACtB,oBAAA,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;wBACjD,OAAO,EAAE,IAAI,GAAG,CAAA,sDAAA,EAAyD,IAAI,EAAE,KAAK,CAA0C,wCAAA,CAAA,CAAC,CAAC;qBACnI;iBACJ;aACJ;AAED,YAAA,OAAO,KAAK,CAAC;AACjB,SAAC,CAAC;;QA3BE,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,EAAE,mBAAmB,I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;;AAEG;;;;"}
1
+ {"version":3,"file":"bravobit-bb-foundation-http.mjs","sources":["../../../projects/bb-foundation/http/src/lib/http.interfaces.ts","../../../projects/bb-foundation/http/src/lib/classes/http.config.ts","../../../projects/bb-foundation/http/src/lib/classes/http.error.ts","../../../projects/bb-foundation/http/src/lib/interceptors/base-url.interceptor.ts","../../../projects/bb-foundation/http/src/lib/interceptors/error.interceptor.ts","../../../projects/bb-foundation/http/src/lib/http.config.ts","../../../projects/bb-foundation/http/src/lib/http.module.ts","../../../projects/bb-foundation/http/src/bravobit-bb-foundation-http.ts"],"sourcesContent":["import {HttpConfig} from './classes/http.config';\nimport {InjectionToken} from '@angular/core';\n\nexport interface HttpConfigData {\n url: HttpConfigUrl;\n alias?: {\n prefix?: string;\n standard?: string;\n };\n disableErrorParsing?: boolean;\n}\n\nexport type HttpConfigPlatformUrl = string | { browser: string, server: string };\nexport type HttpConfigAlias = { alias: string, url: HttpConfigPlatformUrl };\nexport type HttpConfigUrl = HttpConfigPlatformUrl | HttpConfigAlias[];\n\nexport const HTTP_CONFIG = new InjectionToken<HttpConfig>('http config');\nexport const HTTP_CONFIG_DATA = new InjectionToken<HttpConfigData>('http config data');\n","import {HttpConfigAlias, HttpConfigData, HttpConfigUrl} from '../http.interfaces';\n\ndeclare let ngDevMode;\n\nexport class HttpConfig {\n\n readonly aliases: HttpConfigAlias[];\n readonly prefix: string;\n readonly defaultAlias: string;\n readonly disableErrorParsing: boolean;\n\n constructor(data: HttpConfigData) {\n // Get the data from the config.\n this.prefix = data?.alias?.prefix ?? '$';\n this.disableErrorParsing = data?.disableErrorParsing ?? false;\n\n // Parse the aliases.\n const standardAlias = data?.alias?.standard ?? 'api';\n this.aliases = this.parseAliases(data?.url, standardAlias);\n\n // Get the default alias.\n const firstAvailableAlias = this.aliases?.[0]?.alias ?? null;\n this.defaultAlias = `${this.prefix}${firstAvailableAlias}`;\n }\n\n private parseAliases = (value: HttpConfigUrl, standardAlias: string) => {\n if (!Array.isArray(value)) {\n value = [{alias: standardAlias, url: value}];\n }\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const stringRegex = /^[a-zA-Z]+$/;\n for (const item of value) {\n if (!!item?.alias && !stringRegex.test(item?.alias)) {\n console?.warn?.(`[HttpModule]: Invalid HTTP-alias in HttpConfig named \"${item?.alias}\"; only latin characters should be used.`);\n }\n }\n }\n\n return value;\n };\n\n}\n","import {HttpErrorResponse} from '@angular/common/http';\n\nexport class HttpError extends HttpErrorResponse {\n\n constructor(error: HttpErrorResponse) {\n super(error);\n }\n\n get<T = any>(token: string, delimiter: string = '.') {\n const error = this.error ?? {};\n return (token ?? '')\n .split(delimiter)\n .reduce((previous, current) => previous?.[current] ? previous?.[current] : null, error) as T;\n }\n\n has(token: string, delimiter: string = '.') {\n return !!this.get(token, delimiter);\n }\n\n includes<T = any>(token: string, value: T) {\n const array = this.get<T[]>(token);\n return (array ?? []).includes(value);\n }\n\n}\n","import {HTTP_CONFIG, HttpConfigAlias, HttpConfigPlatformUrl} from '../http.interfaces';\nimport {HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {inject, Injectable, PLATFORM_ID} from '@angular/core';\nimport {HttpConfig} from '../classes/http.config';\nimport {isPlatformServer} from '@angular/common';\n\ndeclare let ngDevMode;\n\n@Injectable()\nexport class BaseUrlInterceptor implements HttpInterceptor {\n\n // Dependencies.\n private readonly _config: HttpConfig = inject(HTTP_CONFIG);\n private readonly _platformId: Object = inject(PLATFORM_ID);\n\n // Aliases.\n private readonly _aliases: HttpConfigAlias[] = this._config?.aliases;\n private readonly _prefix: string = this._config?.prefix;\n private readonly _extractRegex: RegExp = new RegExp(`\\\\${this._prefix}[a-zA-Z]+`);\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler) {\n const url = this.getUrlBasedOnAlias(request.url);\n const modified = request.clone({url});\n\n return next.handle(modified);\n }\n\n private getUrlBasedOnAlias(url: string) {\n const matches = this._extractRegex.exec(url);\n if (!matches) {\n return url;\n }\n\n return matches.reduce((previous, current) => {\n const alias = this.getAlias(current);\n const stringAlias = this.convertUrlToString(alias?.url);\n if (!stringAlias) {\n return previous;\n }\n\n return previous.replace(current, stringAlias);\n }, url);\n }\n\n private convertUrlToString(url: HttpConfigPlatformUrl) {\n if (typeof url === 'string') {\n return url;\n }\n\n return isPlatformServer(this._platformId)\n ? url?.server ?? url?.browser ?? null\n : url?.browser ?? null;\n }\n\n private getAlias(value: string) {\n const alias = value.replace(this._prefix, '');\n const fetched = this._aliases?.find(item => item.alias === alias) ?? null;\n if (fetched) {\n return fetched;\n }\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const available = this._aliases\n .map(item => `\\$${item?.alias}`)\n .join(', ');\n console?.warn?.(`[HttpModule]: Used an invalid HTTP-alias named \"${value}\", skipped parsing; Available aliases is one of (${available}).`);\n }\n\n return null;\n }\n\n}\n","import {HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {HttpConfig} from '../classes/http.config';\nimport {inject, Injectable} from '@angular/core';\nimport {HttpError} from '../classes/http.error';\nimport {HTTP_CONFIG} from '../http.interfaces';\nimport {catchError} from 'rxjs/operators';\nimport {throwError} from 'rxjs';\n\n@Injectable()\nexport class ErrorInterceptor implements HttpInterceptor {\n\n // Dependencies.\n private readonly _config: HttpConfig = inject(HTTP_CONFIG);\n\n // State.\n private readonly _disabled = this._config?.disableErrorParsing ?? false;\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler) {\n return next.handle(request).pipe(\n catchError(error => {\n // If we have a matching http error response\n // re-map it with our custom class (if not disabled).\n if (!this._disabled && error instanceof HttpErrorResponse) {\n const parsed = new HttpError(error);\n return throwError(() => parsed);\n }\n\n // We did not match anything, just re-trow the error.\n return throwError(() => error);\n })\n );\n }\n\n}\n","import {HTTP_CONFIG, HTTP_CONFIG_DATA, HttpConfigData} from './http.interfaces';\nimport {EnvironmentProviders, makeEnvironmentProviders} from '@angular/core';\nimport {BaseUrlInterceptor} from './interceptors/base-url.interceptor';\nimport {ErrorInterceptor} from './interceptors/error.interceptor';\nimport {HTTP_INTERCEPTORS} from '@angular/common/http';\nimport {HttpConfig} from './classes/http.config';\n\nexport function provideHttpConfig(config: HttpConfigData): EnvironmentProviders {\n return makeEnvironmentProviders([\n {provide: HTTP_CONFIG_DATA, useValue: config},\n {provide: HTTP_CONFIG, useFactory: createHttpConfig, deps: [HTTP_CONFIG_DATA]},\n {provide: HTTP_INTERCEPTORS, useClass: BaseUrlInterceptor, multi: true},\n {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}\n ]);\n}\n\nexport function createHttpConfig(data: HttpConfigData) {\n return new HttpConfig(data);\n}\n","import {ModuleWithProviders, NgModule, Optional, SkipSelf} from '@angular/core';\nimport {HttpConfigData} from './http.interfaces';\nimport {provideHttpConfig} from './http.config';\n\n@NgModule()\nexport class HttpModule {\n\n constructor(@Optional() @SkipSelf() private _parent?: HttpModule) {\n if (this._parent) {\n throw new Error('HttpModule is already loaded; Import it in the core module only.');\n }\n }\n\n static forRoot(config: HttpConfigData): ModuleWithProviders<HttpModule> {\n return {\n ngModule: HttpModule,\n providers: [\n provideHttpConfig(config)\n ]\n };\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;MAgBa,WAAW,GAAG,IAAI,cAAc,CAAa,aAAa,EAAE;MAC5D,gBAAgB,GAAG,IAAI,cAAc,CAAiB,kBAAkB;;MCbxE,UAAU,CAAA;AAEV,IAAA,OAAO,CAAoB;AAC3B,IAAA,MAAM,CAAS;AACf,IAAA,YAAY,CAAS;AACrB,IAAA,mBAAmB,CAAU;AAEtC,IAAA,WAAA,CAAY,IAAoB,EAAA;;QAE5B,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,EAAE,mBAAmB,IAAI,KAAK,CAAC;;QAG9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AAA,CAAA,CAAA;wGAAV,UAAU,EAAA,CAAA,CAAA;wGAAV,UAAU,EAAA,CAAA,CAAA;;2FAAV,UAAU,EAAA,UAAA,EAAA,CAAA;kBADtB,QAAQ;;0BAGQ,QAAQ;;0BAAI,QAAQ;;;ACPrC;;AAEG;;;;"}
@@ -1,12 +1,10 @@
1
1
  import { formatDate, DOCUMENT } from '@angular/common';
2
- import { __decorate, __param } from 'tslib';
3
2
  import { map, distinctUntilChanged, startWith } from 'rxjs/operators';
4
3
  import * as i0 from '@angular/core';
5
- import { Injectable, Optional, Inject, InjectionToken, inject, LOCALE_ID, Directive, Input, Component, ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, Pipe, APP_INITIALIZER, makeEnvironmentProviders, NgModule } from '@angular/core';
6
- import * as i2 from '@bravobit/bb-foundation';
7
- import { WINDOW } from '@bravobit/bb-foundation';
4
+ import { inject, Injectable, InjectionToken, LOCALE_ID, Directive, Input, Component, ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, Pipe, Optional, APP_INITIALIZER, makeEnvironmentProviders, NgModule } from '@angular/core';
5
+ import { Languages, WINDOW } from '@bravobit/bb-foundation';
6
+ import { Storage } from '@bravobit/bb-foundation/storage';
8
7
  import { BehaviorSubject, of, Subscription } from 'rxjs';
9
- import * as i1 from '@bravobit/bb-foundation/storage';
10
8
  import { BbTemplate } from '@bravobit/bb-foundation/utils';
11
9
 
12
10
  //
@@ -254,9 +252,6 @@ const extraPapiamentoDictionary = {
254
252
  };
255
253
 
256
254
  class LocalizeMissingHandler {
257
- constructor() {
258
- this.log = (message) => console?.warn?.(message);
259
- }
260
255
  handle(params) {
261
256
  // Log to the console when the token was not found
262
257
  // if the user did not mark it as optional.
@@ -266,18 +261,18 @@ class LocalizeMissingHandler {
266
261
  // Return the default token back.
267
262
  return params?.token ?? null;
268
263
  }
264
+ log = (message) => console?.warn?.(message);
269
265
  }
270
266
 
271
267
  class LocalizeDictionaryData {
268
+ data;
272
269
  constructor(data) {
273
270
  this.data = data;
274
271
  }
275
272
  }
276
273
 
277
274
  class LocalizeDictionaryContext {
278
- constructor() {
279
- this.regexp = /^.*$/;
280
- }
275
+ regexp = /^.*$/;
281
276
  pattern(regexp) {
282
277
  this.regexp = regexp;
283
278
  return this;
@@ -301,6 +296,12 @@ class LocalizeDictionaryContext {
301
296
  }
302
297
 
303
298
  class LocalizeDictionary {
299
+ _id;
300
+ _locale;
301
+ _supported;
302
+ _dataValues;
303
+ _localize;
304
+ _data;
304
305
  constructor(_id, _locale, _supported, _dataValues, _localize) {
305
306
  this._id = _id;
306
307
  this._locale = _locale;
@@ -420,34 +421,24 @@ class LocalizeTransform {
420
421
  }
421
422
 
422
423
  class Localize {
423
- constructor(_storage, _languages, _window, _document, _config, _transforms, _missingHandler) {
424
- this._storage = _storage;
425
- this._languages = _languages;
426
- this._window = _window;
427
- this._document = _document;
428
- this._config = _config;
429
- this._transforms = _transforms;
430
- this._missingHandler = _missingHandler;
431
- // Readonly data.
432
- this._storageToken = this._config?.storageToken ?? 'bb-language-dictionary-id';
433
- this._availableLanguages = this?._config?.languages ?? [];
434
- this._bestMatchingLanguage = this.retrieveBestMatchingLanguage();
435
- this._loadedDictionaries = new Map();
436
- // Current dictionary.
437
- this._current$ = new BehaviorSubject(null);
438
- // State changes.
439
- this.dictionaryChanges$ = this._current$.asObservable();
440
- this.convertToParams = (tokenOrParams) => {
441
- if (typeof tokenOrParams !== 'string') {
442
- // Destruct the params from the object.
443
- const { token, optional, dictionary, data } = tokenOrParams;
444
- // Make sure all parameters are valid
445
- // by type safe adding them.
446
- return { token: token, optional: optional ?? false, dictionary: dictionary ?? null, data: data ?? {} };
447
- }
448
- // If the parameter is a string fill in the blanks.
449
- return { token: tokenOrParams, optional: false, dictionary: null, data: {} };
450
- };
424
+ // Dependencies.
425
+ _storage = inject(Storage);
426
+ _languages = inject(Languages);
427
+ _window = inject(WINDOW, { optional: true });
428
+ _document = inject(DOCUMENT, { optional: true });
429
+ _config = inject(LOCALIZE_CONFIG, { optional: true });
430
+ _transforms = inject(LOCALIZE_TRANSFORM, { optional: true });
431
+ _missingHandler = inject(LOCALIZE_MISSING_HANDLER, { optional: true });
432
+ // Readonly data.
433
+ _storageToken = this._config?.storageToken ?? 'bb-language-dictionary-id';
434
+ _availableLanguages = this?._config?.languages ?? [];
435
+ _bestMatchingLanguage = this.retrieveBestMatchingLanguage();
436
+ _loadedDictionaries = new Map();
437
+ // Current dictionary.
438
+ _current$ = new BehaviorSubject(null);
439
+ // State changes.
440
+ dictionaryChanges$ = this._current$.asObservable();
441
+ constructor() {
451
442
  this.renderDocumentLanguage();
452
443
  }
453
444
  get languages() {
@@ -572,40 +563,26 @@ class Localize {
572
563
  ?.map(language => language?.id);
573
564
  return await this.current.compare(languageIds);
574
565
  }
575
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Localize, deps: [{ token: i1.Storage }, { token: i2.Languages }, { token: WINDOW, optional: true }, { token: DOCUMENT, optional: true }, { token: LOCALIZE_CONFIG, optional: true }, { token: LOCALIZE_TRANSFORM, optional: true }, { token: LOCALIZE_MISSING_HANDLER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
576
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Localize, providedIn: 'root' }); }
566
+ convertToParams = (tokenOrParams) => {
567
+ if (typeof tokenOrParams !== 'string') {
568
+ // Destruct the params from the object.
569
+ const { token, optional, dictionary, data } = tokenOrParams;
570
+ // Make sure all parameters are valid
571
+ // by type safe adding them.
572
+ return { token: token, optional: optional ?? false, dictionary: dictionary ?? null, data: data ?? {} };
573
+ }
574
+ // If the parameter is a string fill in the blanks.
575
+ return { token: tokenOrParams, optional: false, dictionary: null, data: {} };
576
+ };
577
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Localize, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
578
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Localize, providedIn: 'root' });
577
579
  }
578
580
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: Localize, decorators: [{
579
581
  type: Injectable,
580
582
  args: [{
581
583
  providedIn: 'root'
582
584
  }]
583
- }], ctorParameters: () => [{ type: i1.Storage }, { type: i2.Languages }, { type: Window, decorators: [{
584
- type: Optional
585
- }, {
586
- type: Inject,
587
- args: [WINDOW]
588
- }] }, { type: Document, decorators: [{
589
- type: Optional
590
- }, {
591
- type: Inject,
592
- args: [DOCUMENT]
593
- }] }, { type: undefined, decorators: [{
594
- type: Optional
595
- }, {
596
- type: Inject,
597
- args: [LOCALIZE_CONFIG]
598
- }] }, { type: undefined, decorators: [{
599
- type: Optional
600
- }, {
601
- type: Inject,
602
- args: [LOCALIZE_TRANSFORM]
603
- }] }, { type: LocalizeMissingHandler, decorators: [{
604
- type: Optional
605
- }, {
606
- type: Inject,
607
- args: [LOCALIZE_MISSING_HANDLER]
608
- }] }] });
585
+ }], ctorParameters: () => [] });
609
586
 
610
587
  const LOCALIZE_FUNCTION = new InjectionToken('localize function');
611
588
  const LOCALIZE_CONFIG = new InjectionToken('localize config');
@@ -621,15 +598,12 @@ const LOCALIZE_ID = new InjectionToken('An abstraction over locale changes', {
621
598
  }
622
599
  });
623
600
 
624
- let LocalizePluralTransform = class LocalizePluralTransform extends LocalizeTransform {
625
- constructor(config) {
626
- super();
627
- this.config = config;
628
- this.substitutions = this.config?.substitutions?.plural ?? ['@plural(', ')'];
629
- this.defaultAmount = 'default';
630
- this.multiItemRegex = new RegExp(`(?<value>=([0-9]+|${this.defaultAmount}): *[^,]+)`, 'g');
631
- this.singleItemRegex = new RegExp(`(=(?<amount>[0-9]+|${this.defaultAmount}): *(?<sentence>.+))`);
632
- }
601
+ class LocalizePluralTransform extends LocalizeTransform {
602
+ config = inject(LOCALIZE_CONFIG, { optional: true });
603
+ substitutions = this.config?.substitutions?.plural ?? ['@plural(', ')'];
604
+ defaultAmount = 'default';
605
+ multiItemRegex = new RegExp(`(?<value>=([0-9]+|${this.defaultAmount}): *[^,]+)`, 'g');
606
+ singleItemRegex = new RegExp(`(=(?<amount>[0-9]+|${this.defaultAmount}): *(?<sentence>.+))`);
633
607
  execute(value, data, _) {
634
608
  const matches = this.getMatches(value, this.substitutions);
635
609
  return matches.reduce((previous, current) => {
@@ -668,23 +642,17 @@ let LocalizePluralTransform = class LocalizePluralTransform extends LocalizeTran
668
642
  return { ...previous, [amount]: sentence };
669
643
  }, {});
670
644
  }
671
- };
672
- LocalizePluralTransform = __decorate([
673
- __param(0, Optional()),
674
- __param(0, Inject(LOCALIZE_CONFIG))
675
- ], LocalizePluralTransform);
645
+ }
676
646
 
677
- let LocalizeInterpolateTransform = class LocalizeInterpolateTransform extends LocalizeTransform {
678
- constructor(config, functions) {
679
- super();
680
- this.config = config;
681
- this.functions = functions;
682
- this.substitutions = this.config?.substitutions?.references ?? ['{{', '}}'];
683
- this.functionsMap = (this.functions ?? []).reduce((previous, current) => {
684
- previous[current?.keyword()] = current;
685
- return previous;
686
- }, {});
687
- }
647
+ class LocalizeInterpolateTransform extends LocalizeTransform {
648
+ // Dependencies.
649
+ config = inject(LOCALIZE_CONFIG, { optional: true });
650
+ functions = inject(LOCALIZE_FUNCTION, { optional: true });
651
+ substitutions = this.config?.substitutions?.references ?? ['{{', '}}'];
652
+ functionsMap = (this.functions ?? []).reduce((previous, current) => {
653
+ previous[current?.keyword()] = current;
654
+ return previous;
655
+ }, {});
688
656
  execute(value, data, localize) {
689
657
  const matches = this.getMatches(value, this.substitutions);
690
658
  // Replace all matches with the translated value.
@@ -716,20 +684,12 @@ let LocalizeInterpolateTransform = class LocalizeInterpolateTransform extends Lo
716
684
  return middleware.transform(string, localize?.current?.locale);
717
685
  }, `${interpolationValue}`);
718
686
  }
719
- };
720
- LocalizeInterpolateTransform = __decorate([
721
- __param(0, Optional()),
722
- __param(0, Inject(LOCALIZE_CONFIG)),
723
- __param(1, Optional()),
724
- __param(1, Inject(LOCALIZE_FUNCTION))
725
- ], LocalizeInterpolateTransform);
687
+ }
726
688
 
727
- let LocalizeReferenceTransform = class LocalizeReferenceTransform extends LocalizeTransform {
728
- constructor(config) {
729
- super();
730
- this.config = config;
731
- this.substitutions = this.config?.substitutions?.references ?? ['#(', ')'];
732
- }
689
+ class LocalizeReferenceTransform extends LocalizeTransform {
690
+ // Dependencies.
691
+ config = inject(LOCALIZE_CONFIG, { optional: true });
692
+ substitutions = this.config?.substitutions?.references ?? ['#(', ')'];
733
693
  execute(value, _, localize) {
734
694
  const matches = this.getMatches(value, this.substitutions);
735
695
  // Replace all matches with the translated value.
@@ -740,20 +700,17 @@ let LocalizeReferenceTransform = class LocalizeReferenceTransform extends Locali
740
700
  return previous.replace(current?.match, translatedToken);
741
701
  }, value);
742
702
  }
743
- };
744
- LocalizeReferenceTransform = __decorate([
745
- __param(0, Optional()),
746
- __param(0, Inject(LOCALIZE_CONFIG))
747
- ], LocalizeReferenceTransform);
703
+ }
748
704
 
749
705
  class BbLocalizeTemplate {
706
+ templateRef;
707
+ // Inputs.
708
+ name = null;
750
709
  constructor(templateRef) {
751
710
  this.templateRef = templateRef;
752
- // Inputs.
753
- this.name = null;
754
711
  }
755
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalizeTemplate, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
756
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.0", type: BbLocalizeTemplate, isStandalone: true, selector: "[bbLocalizeTemplate]", inputs: { name: ["bbLocalizeTemplate", "name"] }, ngImport: i0 }); }
712
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalizeTemplate, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
713
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.0", type: BbLocalizeTemplate, isStandalone: true, selector: "[bbLocalizeTemplate]", inputs: { name: ["bbLocalizeTemplate", "name"] }, ngImport: i0 });
757
714
  }
758
715
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalizeTemplate, decorators: [{
759
716
  type: Directive,
@@ -767,6 +724,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImpor
767
724
  }] } });
768
725
 
769
726
  class BbLocalizeString {
727
+ _changeDetection;
728
+ // Content children.
729
+ items;
730
+ // Inputs.
731
+ substitutions = ['@element(', ')'];
732
+ // Data.
733
+ components = [];
734
+ // Subscriptions.
735
+ _subscription = new Subscription();
736
+ // State.
737
+ _value = null;
770
738
  set value(value) {
771
739
  this._value = value;
772
740
  this.revalidate();
@@ -776,14 +744,6 @@ class BbLocalizeString {
776
744
  }
777
745
  constructor(_changeDetection) {
778
746
  this._changeDetection = _changeDetection;
779
- // Inputs.
780
- this.substitutions = ['@element(', ')'];
781
- // Data.
782
- this.components = [];
783
- // Subscriptions.
784
- this._subscription = new Subscription();
785
- // State.
786
- this._value = null;
787
747
  }
788
748
  ngAfterViewInit() {
789
749
  this.observeItemChanges();
@@ -830,8 +790,8 @@ class BbLocalizeString {
830
790
  end.replace(escape, '\\$&')
831
791
  ];
832
792
  }
833
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalizeString, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
834
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.1.0", type: BbLocalizeString, isStandalone: true, selector: "[bb-localize-string]", inputs: { substitutions: "substitutions", value: ["bb-localize-string", "value"] }, host: { classAttribute: "bb-localize-string" }, queries: [{ propertyName: "items", predicate: BbLocalizeTemplate }], ngImport: i0, template: "@for (component of components; track component) {\n <ng-template [bbTemplate]=\"component\">{{ component }}</ng-template>\n}\n", styles: [""], dependencies: [{ kind: "directive", type: BbTemplate, selector: "[bbTemplate]", inputs: ["bbTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
793
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalizeString, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
794
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.1.0", type: BbLocalizeString, isStandalone: true, selector: "[bb-localize-string]", inputs: { substitutions: "substitutions", value: ["bb-localize-string", "value"] }, host: { classAttribute: "bb-localize-string" }, queries: [{ propertyName: "items", predicate: BbLocalizeTemplate }], ngImport: i0, template: "@for (component of components; track component) {\n <ng-template [bbTemplate]=\"component\">{{ component }}</ng-template>\n}\n", styles: [""], dependencies: [{ kind: "directive", type: BbTemplate, selector: "[bbTemplate]", inputs: ["bbTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
835
795
  }
836
796
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalizeString, decorators: [{
837
797
  type: Component,
@@ -847,6 +807,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImpor
847
807
  }] } });
848
808
 
849
809
  class BbLocalize {
810
+ _localize;
850
811
  constructor(_localize) {
851
812
  this._localize = _localize;
852
813
  }
@@ -877,8 +838,8 @@ class BbLocalize {
877
838
  // Return the combined params and options.
878
839
  return { ...params, ...options };
879
840
  }
880
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalize, deps: [{ token: Localize, optional: true }], target: i0.ɵɵFactoryTarget.Pipe }); }
881
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: BbLocalize, isStandalone: true, name: "bbLocalize" }); }
841
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalize, deps: [{ token: Localize, optional: true }], target: i0.ɵɵFactoryTarget.Pipe });
842
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: BbLocalize, isStandalone: true, name: "bbLocalize" });
882
843
  }
883
844
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: BbLocalize, decorators: [{
884
845
  type: Pipe,
@@ -932,13 +893,13 @@ class LocalizeModule {
932
893
  ]
933
894
  };
934
895
  }
935
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
936
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule, imports: [BbLocalize,
896
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
897
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule, imports: [BbLocalize,
937
898
  BbLocalizeString,
938
899
  BbLocalizeTemplate], exports: [BbLocalize,
939
900
  BbLocalizeString,
940
- BbLocalizeTemplate] }); }
941
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule }); }
901
+ BbLocalizeTemplate] });
902
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule });
942
903
  }
943
904
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImport: i0, type: LocalizeModule, decorators: [{
944
905
  type: NgModule,