@bootkit/ng0 0.0.0-alpha.1 → 0.0.0-alpha.3

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 (169) hide show
  1. package/common/index.d.ts +12 -5
  2. package/components/accordion/index.d.ts +32 -0
  3. package/components/collapse/index.d.ts +59 -0
  4. package/components/form-field/index.d.ts +72 -0
  5. package/components/modal/index.d.ts +29 -0
  6. package/components/nav/index.d.ts +64 -0
  7. package/{offcanvas/offcanvas.directive.d.ts → components/offcanvas/index.d.ts} +14 -5
  8. package/components/overlay/index.d.ts +40 -0
  9. package/components/pagination/index.d.ts +30 -0
  10. package/components/popover/index.d.ts +36 -0
  11. package/components/toast/index.d.ts +101 -0
  12. package/components/tooltip/index.d.ts +30 -0
  13. package/data/index.d.ts +74 -0
  14. package/fesm2022/bootkit-ng0-common.mjs +11 -4
  15. package/fesm2022/bootkit-ng0-common.mjs.map +1 -1
  16. package/fesm2022/{bootkit-ng0-accordion.mjs → bootkit-ng0-components-accordion.mjs} +13 -13
  17. package/fesm2022/bootkit-ng0-components-accordion.mjs.map +1 -0
  18. package/fesm2022/{bootkit-ng0-collapse.mjs → bootkit-ng0-components-collapse.mjs} +12 -12
  19. package/fesm2022/bootkit-ng0-components-collapse.mjs.map +1 -0
  20. package/fesm2022/bootkit-ng0-components-form-field.mjs +147 -0
  21. package/fesm2022/bootkit-ng0-components-form-field.mjs.map +1 -0
  22. package/fesm2022/{bootkit-ng0-modal.mjs → bootkit-ng0-components-modal.mjs} +9 -9
  23. package/fesm2022/bootkit-ng0-components-modal.mjs.map +1 -0
  24. package/fesm2022/{bootkit-ng0-nav.mjs → bootkit-ng0-components-nav.mjs} +21 -21
  25. package/fesm2022/bootkit-ng0-components-nav.mjs.map +1 -0
  26. package/fesm2022/{bootkit-ng0-offcanvas.mjs → bootkit-ng0-components-offcanvas.mjs} +9 -9
  27. package/fesm2022/bootkit-ng0-components-offcanvas.mjs.map +1 -0
  28. package/fesm2022/bootkit-ng0-components-overlay.mjs +99 -0
  29. package/fesm2022/bootkit-ng0-components-overlay.mjs.map +1 -0
  30. package/fesm2022/bootkit-ng0-components-pagination.mjs +85 -0
  31. package/fesm2022/bootkit-ng0-components-pagination.mjs.map +1 -0
  32. package/fesm2022/{bootkit-ng0-popover.mjs → bootkit-ng0-components-popover.mjs} +8 -8
  33. package/fesm2022/bootkit-ng0-components-popover.mjs.map +1 -0
  34. package/fesm2022/{bootkit-ng0-toast.mjs → bootkit-ng0-components-toast.mjs} +9 -9
  35. package/fesm2022/bootkit-ng0-components-toast.mjs.map +1 -0
  36. package/fesm2022/{bootkit-ng0-tooltip.mjs → bootkit-ng0-components-tooltip.mjs} +8 -8
  37. package/fesm2022/bootkit-ng0-components-tooltip.mjs.map +1 -0
  38. package/fesm2022/bootkit-ng0-data.mjs +153 -0
  39. package/fesm2022/bootkit-ng0-data.mjs.map +1 -0
  40. package/fesm2022/bootkit-ng0-http.mjs +229 -0
  41. package/fesm2022/bootkit-ng0-http.mjs.map +1 -0
  42. package/fesm2022/bootkit-ng0-localization.mjs +301 -0
  43. package/fesm2022/bootkit-ng0-localization.mjs.map +1 -0
  44. package/fesm2022/bootkit-ng0-security.mjs +130 -0
  45. package/fesm2022/bootkit-ng0-security.mjs.map +1 -0
  46. package/http/index.d.ts +66 -0
  47. package/index.d.ts +3 -5
  48. package/localization/index.d.ts +178 -0
  49. package/package.json +60 -58
  50. package/security/index.d.ts +48 -0
  51. package/accordion/accordion-item.component.d.ts +0 -13
  52. package/accordion/accordion.component.d.ts +0 -13
  53. package/accordion/accordion.module.d.ts +0 -8
  54. package/accordion/index.d.ts +0 -5
  55. package/accordion/public-api.d.ts +0 -3
  56. package/collapse/collapse.component.d.ts +0 -18
  57. package/collapse/collapse.directive.d.ts +0 -32
  58. package/collapse/collapse.module.d.ts +0 -8
  59. package/collapse/index.d.ts +0 -5
  60. package/collapse/public-api.d.ts +0 -3
  61. package/common/public-api.d.ts +0 -2
  62. package/common/types.d.ts +0 -4
  63. package/common/utils.d.ts +0 -3
  64. package/esm2022/accordion/accordion-item.component.mjs +0 -34
  65. package/esm2022/accordion/accordion.component.mjs +0 -25
  66. package/esm2022/accordion/accordion.module.mjs +0 -25
  67. package/esm2022/accordion/bootkit-ng0-accordion.mjs +0 -5
  68. package/esm2022/accordion/public-api.mjs +0 -4
  69. package/esm2022/bootkit-ng0.mjs +0 -5
  70. package/esm2022/collapse/bootkit-ng0-collapse.mjs +0 -5
  71. package/esm2022/collapse/collapse.component.mjs +0 -46
  72. package/esm2022/collapse/collapse.directive.mjs +0 -94
  73. package/esm2022/collapse/collapse.module.mjs +0 -23
  74. package/esm2022/collapse/public-api.mjs +0 -4
  75. package/esm2022/common/bootkit-ng0-common.mjs +0 -5
  76. package/esm2022/common/public-api.mjs +0 -3
  77. package/esm2022/common/types.mjs +0 -3
  78. package/esm2022/common/utils.mjs +0 -16
  79. package/esm2022/lib/index.mjs +0 -3
  80. package/esm2022/lib/types.mjs +0 -2
  81. package/esm2022/modal/bootkit-ng0-modal.mjs +0 -5
  82. package/esm2022/modal/modal.component.mjs +0 -44
  83. package/esm2022/modal/modal.module.mjs +0 -20
  84. package/esm2022/modal/public-api.mjs +0 -3
  85. package/esm2022/modal/types.mjs +0 -3
  86. package/esm2022/nav/bootkit-ng0-nav.mjs +0 -5
  87. package/esm2022/nav/nav-item.directive.mjs +0 -26
  88. package/esm2022/nav/nav-link.directive.mjs +0 -45
  89. package/esm2022/nav/nav.directive.mjs +0 -23
  90. package/esm2022/nav/nav.module.mjs +0 -35
  91. package/esm2022/nav/public-api.mjs +0 -7
  92. package/esm2022/nav/tab-content.component.mjs +0 -29
  93. package/esm2022/nav/tab-pane.directive.mjs +0 -20
  94. package/esm2022/offcanvas/bootkit-ng0-offcanvas.mjs +0 -5
  95. package/esm2022/offcanvas/offcanvas.directive.mjs +0 -118
  96. package/esm2022/offcanvas/offcanvas.module.mjs +0 -19
  97. package/esm2022/offcanvas/public-api.mjs +0 -3
  98. package/esm2022/overlay/bootkit-ng0-overlay.mjs +0 -5
  99. package/esm2022/overlay/overlay.directive.mjs +0 -111
  100. package/esm2022/overlay/overlay.module.mjs +0 -22
  101. package/esm2022/overlay/private/utils.mjs +0 -58
  102. package/esm2022/overlay/public-api.mjs +0 -3
  103. package/esm2022/popover/bootkit-ng0-popover.mjs +0 -5
  104. package/esm2022/popover/popover-wrapper/popover-wrapper.component.mjs +0 -29
  105. package/esm2022/popover/popover.directive.mjs +0 -140
  106. package/esm2022/popover/public-api.mjs +0 -2
  107. package/esm2022/popover/types.mjs +0 -2
  108. package/esm2022/public-api.mjs +0 -5
  109. package/esm2022/toast/bootkit-ng0-toast.mjs +0 -5
  110. package/esm2022/toast/public-api.mjs +0 -4
  111. package/esm2022/toast/toast-ref.mjs +0 -27
  112. package/esm2022/toast/toast.component.mjs +0 -68
  113. package/esm2022/toast/toast.service.mjs +0 -93
  114. package/esm2022/toast/types.mjs +0 -2
  115. package/esm2022/tooltip/bootkit-ng0-tooltip.mjs +0 -5
  116. package/esm2022/tooltip/public-api.mjs +0 -3
  117. package/esm2022/tooltip/tooltip-wrapper/tooltip-wrapper.component.mjs +0 -44
  118. package/esm2022/tooltip/tooltip.directive.mjs +0 -93
  119. package/esm2022/tooltip/types.mjs +0 -2
  120. package/fesm2022/bootkit-ng0-accordion.mjs.map +0 -1
  121. package/fesm2022/bootkit-ng0-collapse.mjs.map +0 -1
  122. package/fesm2022/bootkit-ng0-modal.mjs.map +0 -1
  123. package/fesm2022/bootkit-ng0-nav.mjs.map +0 -1
  124. package/fesm2022/bootkit-ng0-offcanvas.mjs.map +0 -1
  125. package/fesm2022/bootkit-ng0-overlay.mjs +0 -194
  126. package/fesm2022/bootkit-ng0-overlay.mjs.map +0 -1
  127. package/fesm2022/bootkit-ng0-popover.mjs.map +0 -1
  128. package/fesm2022/bootkit-ng0-toast.mjs.map +0 -1
  129. package/fesm2022/bootkit-ng0-tooltip.mjs.map +0 -1
  130. package/lib/index.d.ts +0 -2
  131. package/lib/types.d.ts +0 -1
  132. package/modal/index.d.ts +0 -5
  133. package/modal/modal.component.d.ts +0 -18
  134. package/modal/modal.module.d.ts +0 -7
  135. package/modal/public-api.d.ts +0 -2
  136. package/modal/types.d.ts +0 -2
  137. package/nav/index.d.ts +0 -5
  138. package/nav/nav-item.directive.d.ts +0 -13
  139. package/nav/nav-link.directive.d.ts +0 -16
  140. package/nav/nav.directive.d.ts +0 -11
  141. package/nav/nav.module.d.ts +0 -11
  142. package/nav/public-api.d.ts +0 -6
  143. package/nav/tab-content.component.d.ts +0 -15
  144. package/nav/tab-pane.directive.d.ts +0 -9
  145. package/offcanvas/index.d.ts +0 -5
  146. package/offcanvas/offcanvas.module.d.ts +0 -7
  147. package/offcanvas/public-api.d.ts +0 -2
  148. package/overlay/index.d.ts +0 -5
  149. package/overlay/overlay.directive.d.ts +0 -50
  150. package/overlay/overlay.module.d.ts +0 -10
  151. package/overlay/private/utils.d.ts +0 -10
  152. package/overlay/public-api.d.ts +0 -2
  153. package/popover/index.d.ts +0 -5
  154. package/popover/popover-wrapper/popover-wrapper.component.d.ts +0 -15
  155. package/popover/popover.directive.d.ts +0 -30
  156. package/popover/public-api.d.ts +0 -1
  157. package/popover/types.d.ts +0 -4
  158. package/public-api.d.ts +0 -1
  159. package/toast/index.d.ts +0 -5
  160. package/toast/public-api.d.ts +0 -3
  161. package/toast/toast-ref.d.ts +0 -12
  162. package/toast/toast.component.d.ts +0 -19
  163. package/toast/toast.service.d.ts +0 -43
  164. package/toast/types.d.ts +0 -44
  165. package/tooltip/index.d.ts +0 -5
  166. package/tooltip/public-api.d.ts +0 -2
  167. package/tooltip/tooltip-wrapper/tooltip-wrapper.component.d.ts +0 -19
  168. package/tooltip/tooltip.directive.d.ts +0 -24
  169. package/tooltip/types.d.ts +0 -3
@@ -0,0 +1,301 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Pipe, NgModule, InjectionToken } from '@angular/core';
3
+ import { Subject } from 'rxjs';
4
+ import { CommonModule } from '@angular/common';
5
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
+
7
+ /** Locale */
8
+ class Locale {
9
+ definition;
10
+ constructor(definition) {
11
+ this.definition = definition;
12
+ }
13
+ /**
14
+ * Returns the name of the locale
15
+ * @returns The name of the locale
16
+ */
17
+ get name() {
18
+ return this.definition.name;
19
+ }
20
+ /**
21
+ * Translates a key in the dictionary
22
+ * @param key The key to look up
23
+ * @returns The translated string or the key itself if not found
24
+ */
25
+ translate(key) {
26
+ return this.definition.dictionary[key] ?? key;
27
+ }
28
+ /**
29
+ * Translates an enum value
30
+ * @param enumName The name of the enum
31
+ * @param enumValue The value of the enum to translate
32
+ * @returns The translated string or the enum value itself if not found
33
+ */
34
+ translateEnum(enumName, enumValue) {
35
+ if (this.definition?.enums && this.definition.enums[enumName])
36
+ return this.definition.enums[enumName][enumValue];
37
+ else
38
+ return enumValue;
39
+ }
40
+ /**
41
+ * Translates a form validation error
42
+ * @param errorKey The key of the error to translate
43
+ * @param error The error object
44
+ */
45
+ translateError(errorKey, error, fallbackMessage = undefined) {
46
+ const errors = this.definition?.form?.validation?.errors;
47
+ if (!errors) {
48
+ return fallbackMessage;
49
+ }
50
+ const translatorFunc = errors[errorKey] ?? errors['*'];
51
+ return typeof translatorFunc === 'function' ? translatorFunc(error) : fallbackMessage;
52
+ }
53
+ /**
54
+ * Translates validation errors
55
+ * @param errors Validation errors object
56
+ * @returns Array of translated validation errors
57
+ */
58
+ translateErrors(errors) {
59
+ const result = [];
60
+ for (const key in errors) {
61
+ if (Object.prototype.hasOwnProperty.call(errors, key)) {
62
+ result.push({
63
+ key: key,
64
+ value: errors[key],
65
+ text: this.translateError(key, errors[key])
66
+ });
67
+ }
68
+ }
69
+ return result;
70
+ }
71
+ /**
72
+ * Translates the first error in the validation errors object
73
+ * @param errors Validation errors object
74
+ * @returns TranslatedValidationError or undefined if no errors
75
+ */
76
+ translateFirstError(errors, fallbackMessage = undefined) {
77
+ const keys = Object.keys(errors);
78
+ if (keys.length === 0) {
79
+ return undefined;
80
+ }
81
+ const key = keys[0];
82
+ const value = errors[key];
83
+ return {
84
+ key,
85
+ value,
86
+ text: this.translateError(key, value, fallbackMessage)
87
+ };
88
+ }
89
+ /**
90
+ * Clones and extends this object and returns a new Locale (without modifying this object).
91
+ */
92
+ extend(values) {
93
+ return new Locale({
94
+ name: this.definition.name,
95
+ rtl: this.definition.rtl,
96
+ dictionary: { ...this.definition.dictionary, ...values?.dictionary },
97
+ enums: { ...this.definition.enums, ...values?.enums },
98
+ form: {
99
+ validation: {
100
+ errors: { ...this.definition?.form?.validation?.errors, ...values?.form?.validation?.errors }
101
+ }
102
+ }
103
+ });
104
+ }
105
+ /**
106
+ *
107
+ * @param date Date string or timestamp
108
+ * @returns Formatted date string based on the locale
109
+ */
110
+ formatDate(date, format) {
111
+ return date ? new Date(date).toLocaleDateString(this.definition.name, { hour: '2-digit', minute: '2-digit' }) : '';
112
+ }
113
+ }
114
+
115
+ class LocalizationService {
116
+ _locales = [];
117
+ _activeLocale;
118
+ _changeSubject = new Subject();
119
+ change = this._changeSubject.asObservable();
120
+ constructor() {
121
+ }
122
+ add(l) {
123
+ if (l instanceof Locale) {
124
+ this._locales.push(l);
125
+ }
126
+ else if (Array.isArray(l)) {
127
+ l.forEach(x => this.add(x));
128
+ }
129
+ else {
130
+ throw Error('Invalid locale');
131
+ }
132
+ if (this._locales.length == 1) {
133
+ this._activeLocale = this._locales[0];
134
+ }
135
+ }
136
+ /** Changes the active locale */
137
+ set(localeName) {
138
+ const locale = this._locales.find(x => x.name === localeName);
139
+ if (locale) {
140
+ this._changeSubject.next({ old: this._activeLocale, new: locale });
141
+ this._activeLocale = locale;
142
+ return;
143
+ }
144
+ throw Error('Locale not found.');
145
+ }
146
+ /** Gets the active locale */
147
+ get() {
148
+ return this._activeLocale;
149
+ }
150
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LocalizationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
151
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LocalizationService, providedIn: 'root' });
152
+ }
153
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LocalizationService, decorators: [{
154
+ type: Injectable,
155
+ args: [{
156
+ providedIn: 'root'
157
+ }]
158
+ }], ctorParameters: () => [] });
159
+
160
+ class TranslatePipe {
161
+ _locale;
162
+ _recompute = true;
163
+ _value;
164
+ constructor(localizationService) {
165
+ this._locale = localizationService.get();
166
+ localizationService.change.pipe(takeUntilDestroyed()).subscribe(x => {
167
+ this._locale = x.new;
168
+ this._recompute = true;
169
+ });
170
+ }
171
+ transform(dictionaryKey, ...args) {
172
+ if (this._recompute) {
173
+ this._value = this._locale.translate(dictionaryKey);
174
+ this._recompute = false;
175
+ }
176
+ return this._value;
177
+ }
178
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: TranslatePipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
179
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: TranslatePipe, isStandalone: true, name: "ng0Translate", pure: false });
180
+ }
181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: TranslatePipe, decorators: [{
182
+ type: Pipe,
183
+ args: [{
184
+ name: 'ng0Translate',
185
+ standalone: true,
186
+ pure: false
187
+ }]
188
+ }], ctorParameters: () => [{ type: LocalizationService }] });
189
+
190
+ class EnumPipe {
191
+ _locale;
192
+ _recompute = true;
193
+ _value;
194
+ constructor(localeProvider) {
195
+ this._locale = localeProvider.get();
196
+ localeProvider.change.pipe(takeUntilDestroyed()).subscribe(x => {
197
+ this._locale = x.new;
198
+ this._recompute = true;
199
+ });
200
+ }
201
+ transform(enumValue, ...args) {
202
+ if (this._recompute) {
203
+ var enumName = args[0];
204
+ var nullDictionaryKey = args[1];
205
+ this._value = enumValue ?
206
+ (this._locale.translateEnum(enumName, enumValue) ?? enumValue) :
207
+ (nullDictionaryKey ? this._locale.translate(nullDictionaryKey) : '');
208
+ this._recompute = false;
209
+ }
210
+ return this._value;
211
+ }
212
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: EnumPipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
213
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: EnumPipe, isStandalone: true, name: "ng0Enum", pure: false });
214
+ }
215
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: EnumPipe, decorators: [{
216
+ type: Pipe,
217
+ args: [{
218
+ name: 'ng0Enum',
219
+ standalone: true,
220
+ pure: false
221
+ }]
222
+ }], ctorParameters: () => [{ type: LocalizationService }] });
223
+
224
+ class BooleanPipe {
225
+ localeProvider;
226
+ constructor(localeProvider) {
227
+ this.localeProvider = localeProvider;
228
+ }
229
+ transform(value, falseKey = 'true', trueKey) {
230
+ return this.localeProvider.get().translate(value ? trueKey : falseKey);
231
+ }
232
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: BooleanPipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
233
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: BooleanPipe, isStandalone: true, name: "ng0Bool" });
234
+ }
235
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: BooleanPipe, decorators: [{
236
+ type: Pipe,
237
+ args: [{
238
+ name: 'ng0Bool',
239
+ standalone: true,
240
+ }]
241
+ }], ctorParameters: () => [{ type: LocalizationService }] });
242
+
243
+ class DatePipe {
244
+ _locale;
245
+ _value;
246
+ constructor(localeProvider) {
247
+ this._locale = localeProvider.get();
248
+ localeProvider.change.pipe(takeUntilDestroyed()).subscribe(x => {
249
+ this._locale = x.new;
250
+ });
251
+ }
252
+ transform(value) {
253
+ return this._locale.formatDate(value, '');
254
+ }
255
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DatePipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
256
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: DatePipe, isStandalone: true, name: "ng0Date" });
257
+ }
258
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DatePipe, decorators: [{
259
+ type: Pipe,
260
+ args: [{
261
+ name: 'ng0Date',
262
+ standalone: true
263
+ }]
264
+ }], ctorParameters: () => [{ type: LocalizationService }] });
265
+
266
+ const Declarables = [
267
+ TranslatePipe,
268
+ EnumPipe,
269
+ BooleanPipe,
270
+ DatePipe
271
+ ];
272
+ class LocalizationModule {
273
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LocalizationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
274
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: LocalizationModule, imports: [CommonModule, TranslatePipe,
275
+ EnumPipe,
276
+ BooleanPipe,
277
+ DatePipe], exports: [TranslatePipe,
278
+ EnumPipe,
279
+ BooleanPipe,
280
+ DatePipe] });
281
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LocalizationModule, imports: [CommonModule] });
282
+ }
283
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LocalizationModule, decorators: [{
284
+ type: NgModule,
285
+ args: [{
286
+ imports: [
287
+ CommonModule,
288
+ Declarables
289
+ ],
290
+ exports: Declarables
291
+ }]
292
+ }] });
293
+
294
+ const LOCALE = new InjectionToken('LOCALE');
295
+
296
+ /**
297
+ * Generated bundle index. Do not edit.
298
+ */
299
+
300
+ export { BooleanPipe, DatePipe, EnumPipe, LOCALE, Locale, LocalizationModule, LocalizationService, TranslatePipe };
301
+ //# sourceMappingURL=bootkit-ng0-localization.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootkit-ng0-localization.mjs","sources":["../../../projects/ng0/localization/locale.ts","../../../projects/ng0/localization/localization.service.ts","../../../projects/ng0/localization/translate.pipe.ts","../../../projects/ng0/localization/enum.pipe.ts","../../../projects/ng0/localization/boolean-pipe.ts","../../../projects/ng0/localization/date.pipe.ts","../../../projects/ng0/localization/localization.module.ts","../../../projects/ng0/localization/types.ts","../../../projects/ng0/localization/bootkit-ng0-localization.ts"],"sourcesContent":["import { LocaleDefinitionExtend, LocaleDefinition } from \"./locale-definition\";\r\nimport { TranslatedValidationError } from \"./types\";\r\n\r\n/** Locale */\r\nexport class Locale {\r\n\r\n constructor(public readonly definition: LocaleDefinition) {\r\n }\r\n\r\n /** \r\n * Returns the name of the locale\r\n * @returns The name of the locale\r\n */\r\n get name(): string {\r\n return this.definition.name;\r\n }\r\n\r\n /** \r\n * Translates a key in the dictionary\r\n * @param key The key to look up\r\n * @returns The translated string or the key itself if not found\r\n */\r\n translate(key: string): string {\r\n return this.definition.dictionary[key] ?? key;\r\n }\r\n\r\n /**\r\n * Translates an enum value \r\n * @param enumName The name of the enum \r\n * @param enumValue The value of the enum to translate \r\n * @returns The translated string or the enum value itself if not found \r\n */\r\n translateEnum(enumName: string, enumValue: any): string | undefined {\r\n if (this.definition?.enums && this.definition.enums[enumName])\r\n return this.definition.enums[enumName][enumValue];\r\n else\r\n return enumValue;\r\n }\r\n\r\n /** \r\n * Translates a form validation error\r\n * @param errorKey The key of the error to translate\r\n * @param error The error object\r\n */\r\n translateError(errorKey: string, error: any, fallbackMessage: string | undefined = undefined): string | undefined {\r\n const errors = this.definition?.form?.validation?.errors;\r\n\r\n if (!errors) {\r\n return fallbackMessage;\r\n }\r\n\r\n const translatorFunc = errors[errorKey] ?? errors['*'];\r\n return typeof translatorFunc === 'function' ? translatorFunc(error) : fallbackMessage;\r\n }\r\n\r\n /** \r\n * Translates validation errors \r\n * @param errors Validation errors object\r\n * @returns Array of translated validation errors\r\n */\r\n translateErrors(errors: any): TranslatedValidationError[] {\r\n const result: TranslatedValidationError[] = [];\r\n for (const key in errors) {\r\n if (Object.prototype.hasOwnProperty.call(errors, key)) {\r\n result.push({\r\n key: key,\r\n value: errors[key],\r\n text: this.translateError(key, errors[key])\r\n });\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /** \r\n * Translates the first error in the validation errors object \r\n * @param errors Validation errors object\r\n * @returns TranslatedValidationError or undefined if no errors\r\n */\r\n translateFirstError(errors: any, fallbackMessage: string | undefined = undefined): TranslatedValidationError | undefined {\r\n const keys = Object.keys(errors);\r\n if (keys.length === 0) {\r\n return undefined;\r\n }\r\n\r\n const key = keys[0];\r\n const value = errors[key];\r\n return {\r\n key,\r\n value,\r\n text: this.translateError(key, value, fallbackMessage)\r\n };\r\n }\r\n\r\n /**\r\n * Clones and extends this object and returns a new Locale (without modifying this object).\r\n */\r\n extend(values?: LocaleDefinitionExtend): Locale {\r\n return new Locale({\r\n name: this.definition.name,\r\n rtl: this.definition.rtl,\r\n dictionary: { ...this.definition.dictionary, ...values?.dictionary },\r\n enums: { ...this.definition.enums, ...values?.enums },\r\n form: {\r\n validation: {\r\n errors: { ...this.definition?.form?.validation?.errors, ...values?.form?.validation?.errors }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * \r\n * @param date Date string or timestamp\r\n * @returns Formatted date string based on the locale \r\n */\r\n formatDate(date: string | number, format: string): string {\r\n return date ? new Date(date).toLocaleDateString(this.definition.name, { hour: '2-digit', minute: '2-digit' }) : '';\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { Subject } from 'rxjs';\r\nimport { Locale } from './locale';\r\nimport { LocaleChangeEvent } from './types';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class LocalizationService {\r\n private _locales: Locale[] = [];\r\n private _activeLocale?: Locale;\r\n private _changeSubject = new Subject<LocaleChangeEvent>();\r\n readonly change = this._changeSubject.asObservable();\r\n\r\n constructor() {\r\n }\r\n\r\n /** Adds a Locale */\r\n add(locale: Locale): void;\r\n /** Adds an array of Locales to this LocaleProvider */\r\n add(locales: Locale[]): void;\r\n add(l: any): void {\r\n if (l instanceof Locale) {\r\n this._locales.push(l);\r\n } else if (Array.isArray(l)) {\r\n l.forEach(x => this.add(x));\r\n } else {\r\n throw Error('Invalid locale');\r\n }\r\n\r\n if (this._locales.length == 1) {\r\n this._activeLocale = this._locales[0];\r\n }\r\n }\r\n\r\n /** Changes the active locale */\r\n set(localeName: string): void {\r\n const locale = this._locales.find(x => x.name === localeName);\r\n if (locale) {\r\n this._changeSubject.next({ old: this._activeLocale, new: locale });\r\n this._activeLocale = locale;\r\n return;\r\n }\r\n\r\n throw Error('Locale not found.');\r\n }\r\n\r\n /** Gets the active locale */\r\n get(): Locale | undefined {\r\n return this._activeLocale;\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\nimport { LocalizationService } from './localization.service';\r\nimport { Locale } from './locale';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\n\r\n@Pipe({\r\n name: 'ng0Translate',\r\n standalone: true,\r\n pure: false\r\n})\r\nexport class TranslatePipe implements PipeTransform {\r\n private _locale: Locale;\r\n private _recompute = true;\r\n private _value!: string;\r\n\r\n constructor(localizationService: LocalizationService) {\r\n this._locale = localizationService.get();\r\n\r\n localizationService.change.pipe(takeUntilDestroyed()).subscribe(x => {\r\n this._locale = x.new;\r\n this._recompute = true;\r\n });\r\n }\r\n\r\n transform(dictionaryKey: string, ...args: unknown[]): string {\r\n if (this._recompute) {\r\n this._value = this._locale.translate(dictionaryKey);\r\n this._recompute = false;\r\n }\r\n\r\n return this._value;\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\nimport { LocalizationService } from './localization.service';\r\nimport { Locale } from './locale';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\n\r\n@Pipe({\r\n name: 'ng0Enum',\r\n standalone: true,\r\n pure: false\r\n})\r\nexport class EnumPipe implements PipeTransform {\r\n private _locale: Locale;\r\n private _recompute = true;\r\n private _value!: string;\r\n\r\n constructor(localeProvider: LocalizationService) {\r\n this._locale = localeProvider.get();\r\n\r\n localeProvider.change.pipe(takeUntilDestroyed()).subscribe(x => {\r\n this._locale = x.new;\r\n this._recompute = true;\r\n });\r\n }\r\n\r\n transform(enumValue?: string | null, ...args: string[]): string {\r\n if (this._recompute) {\r\n var enumName = args[0];\r\n var nullDictionaryKey = args[1];\r\n this._value = enumValue ?\r\n (this._locale.translateEnum(enumName, enumValue) ?? enumValue) :\r\n (nullDictionaryKey ? this._locale.translate(nullDictionaryKey) : '');\r\n\r\n this._recompute = false;\r\n }\r\n\r\n return this._value;\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\nimport { LocalizationService } from './localization.service';\r\n\r\n@Pipe({\r\n name: 'ng0Bool',\r\n standalone: true,\r\n})\r\nexport class BooleanPipe implements PipeTransform {\r\n\r\n constructor(private localeProvider: LocalizationService) {\r\n }\r\n\r\n transform(value: any, falseKey = 'true', trueKey: 'false') {\r\n return this.localeProvider.get().translate(value ? trueKey : falseKey);\r\n }\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\nimport { Locale } from './locale';\r\nimport { LocalizationService } from './localization.service';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\n\r\n@Pipe({\r\n name: 'ng0Date',\r\n standalone: true\r\n})\r\nexport class DatePipe implements PipeTransform {\r\n private _locale: Locale;\r\n private _value!: string;\r\n\r\n constructor(localeProvider: LocalizationService) {\r\n this._locale = localeProvider.get();\r\n\r\n localeProvider.change.pipe(takeUntilDestroyed()).subscribe(x => {\r\n this._locale = x.new;\r\n });\r\n }\r\n\r\n transform(value: number | string): string {\r\n return this._locale.formatDate(value, '');\r\n }\r\n}\r\n","import { CommonModule } from '@angular/common';\r\nimport { NgModule } from '@angular/core';\r\nimport { TranslatePipe } from './translate.pipe';\r\nimport { EnumPipe } from './enum.pipe';\r\nimport { BooleanPipe } from './boolean-pipe';\r\nimport { DatePipe } from './date.pipe';\r\n\r\nconst Declarables = [\r\n TranslatePipe,\r\n EnumPipe,\r\n BooleanPipe,\r\n DatePipe\r\n];\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n Declarables\r\n ],\r\n exports: Declarables\r\n})\r\nexport class LocalizationModule {\r\n}\r\n\r\n","import { InjectionToken } from '@angular/core';\r\nimport { LocalizationService } from './localization.service';\r\nimport { Locale } from './locale';\r\n\r\nexport const LOCALE = new InjectionToken<Locale | LocalizationService>('LOCALE');\r\n\r\nexport interface TranslatedValidationError {\r\n /** Error key */\r\n key: string;\r\n \r\n /** Error object */\r\n value: any;\r\n \r\n /** localized error text */\r\n text?: string;\r\n }\r\n \r\n export interface LocaleChangeEvent {\r\n old?: Locale;\r\n new: Locale;\r\n }\r\n ","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.LocalizationService"],"mappings":";;;;;;AAGA;MACa,MAAM,CAAA;AAEW,IAAA,UAAA;AAA5B,IAAA,WAAA,CAA4B,UAA4B,EAAA;QAA5B,IAAU,CAAA,UAAA,GAAV,UAAU;;AAGtC;;;AAGG;AACH,IAAA,IAAI,IAAI,GAAA;AACN,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI;;AAG7B;;;;AAIG;AACH,IAAA,SAAS,CAAC,GAAW,EAAA;QACnB,OAAO,IAA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AAc,CAA+B,QAAQ;;ACJ/E;;AAEG;;;;"}
@@ -0,0 +1,130 @@
1
+ import * as i0 from '@angular/core';
2
+ import { signal, Injectable, input, effect, Directive, NgModule } from '@angular/core';
3
+
4
+ /** User */
5
+ class User {
6
+ claims;
7
+ constructor(claims) {
8
+ this.claims = claims;
9
+ }
10
+ hasClaims(claims) {
11
+ return claims.every(x => this.claims.some(y => x === y));
12
+ }
13
+ hasAnyClaim(claims) {
14
+ return claims.length == 0 || claims.some(x => this.claims.some(y => x === y));
15
+ }
16
+ hasClaim(claim) {
17
+ var type = typeof claim;
18
+ if (type === 'string') {
19
+ return this.claims.some(x => x === claim);
20
+ }
21
+ if (type === 'object') {
22
+ const co = claim;
23
+ if (co?.any && co?.all) {
24
+ throw Error('Setting "any" and "all" at the same time is not valid.');
25
+ }
26
+ if (Array.isArray(co?.any)) {
27
+ return this.hasAnyClaim(co.any);
28
+ }
29
+ if (Array.isArray(co?.all)) {
30
+ return this.hasClaims(co.all);
31
+ }
32
+ }
33
+ throw Error('Invalid claim');
34
+ }
35
+ }
36
+
37
+ class UserStore {
38
+ user = signal(undefined);
39
+ constructor() {
40
+ }
41
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: UserStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
42
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: UserStore, providedIn: 'root' });
43
+ }
44
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: UserStore, decorators: [{
45
+ type: Injectable,
46
+ args: [{ providedIn: 'root' }]
47
+ }], ctorParameters: () => [] });
48
+
49
+ class UserDirective {
50
+ claim = input(undefined, { alias: 'ng0Claim' });
51
+ _viewCreated = false;
52
+ constructor(templateRef, viewContainer, userStore) {
53
+ effect(() => {
54
+ let claim = this.claim();
55
+ let user = userStore.user();
56
+ let show = !user ? false : (claim == undefined ? true : user.hasClaim(claim));
57
+ if (show && !this._viewCreated) {
58
+ viewContainer.createEmbeddedView(templateRef);
59
+ this._viewCreated = true;
60
+ }
61
+ else if (!show && this._viewCreated) {
62
+ viewContainer.clear();
63
+ this._viewCreated = false;
64
+ }
65
+ });
66
+ }
67
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: UserDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: UserStore }], target: i0.ɵɵFactoryTarget.Directive });
68
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.0.6", type: UserDirective, isStandalone: true, selector: "[ng0Claim]", inputs: { claim: { classPropertyName: "claim", publicName: "ng0Claim", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ng0Claim"], ngImport: i0 });
69
+ }
70
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: UserDirective, decorators: [{
71
+ type: Directive,
72
+ args: [{
73
+ selector: '[ng0Claim]',
74
+ exportAs: 'ng0Claim',
75
+ standalone: true
76
+ }]
77
+ }], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: UserStore }] });
78
+
79
+ class GuestUserDirective {
80
+ _created = false;
81
+ constructor(templateRef, viewContainer, userStore) {
82
+ effect(() => {
83
+ let show = userStore.user() == undefined;
84
+ if (show && !this._created) {
85
+ viewContainer.createEmbeddedView(templateRef);
86
+ this._created = true;
87
+ }
88
+ else if (!show && this._created) {
89
+ viewContainer.clear();
90
+ this._created = false;
91
+ }
92
+ });
93
+ }
94
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: GuestUserDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: UserStore }], target: i0.ɵɵFactoryTarget.Directive });
95
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.6", type: GuestUserDirective, isStandalone: true, selector: "[ng0GuestUser]", exportAs: ["ng0GuestUser"], ngImport: i0 });
96
+ }
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: GuestUserDirective, decorators: [{
98
+ type: Directive,
99
+ args: [{
100
+ selector: '[ng0GuestUser]',
101
+ exportAs: 'ng0GuestUser',
102
+ standalone: true
103
+ }]
104
+ }], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: UserStore }] });
105
+
106
+ const items = [
107
+ UserDirective,
108
+ GuestUserDirective
109
+ ];
110
+ class SecurityModule {
111
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SecurityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
112
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.6", ngImport: i0, type: SecurityModule, imports: [UserDirective,
113
+ GuestUserDirective], exports: [UserDirective,
114
+ GuestUserDirective] });
115
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SecurityModule });
116
+ }
117
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SecurityModule, decorators: [{
118
+ type: NgModule,
119
+ args: [{
120
+ imports: items,
121
+ exports: items
122
+ }]
123
+ }] });
124
+
125
+ /**
126
+ * Generated bundle index. Do not edit.
127
+ */
128
+
129
+ export { GuestUserDirective, SecurityModule, User, UserDirective, UserStore };
130
+ //# sourceMappingURL=bootkit-ng0-security.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootkit-ng0-security.mjs","sources":["../../../projects/ng0/security/user.ts","../../../projects/ng0/security/user-store.ts","../../../projects/ng0/security/claim.directive.ts","../../../projects/ng0/security/guest-user.directive.ts","../../../projects/ng0/security/security.module.ts","../../../projects/ng0/security/bootkit-ng0-security.ts"],"sourcesContent":["import { ClaimLike, ClaimObject } from './types';\r\n\r\n/** User */\r\nexport class User {\r\n constructor(public readonly claims: string[]) {\r\n }\r\n\r\n public hasClaims(claims: string[]): boolean {\r\n return claims.every(x => this.claims.some(y => x === y));\r\n }\r\n\r\n public hasAnyClaim(claims: string[]): boolean {\r\n return claims.length == 0 || claims.some(x => this.claims.some(y => x === y));\r\n }\r\n\r\n public hasClaim(claim: ClaimLike): boolean {\r\n var type = typeof claim;\r\n if (type === 'string') {\r\n return this.claims.some(x => x === claim);\r\n }\r\n\r\n if (type === 'object') {\r\n const co = claim as ClaimObject;\r\n if (co?.any && co?.all) {\r\n throw Error('Setting \"any\" and \"all\" at the same time is not valid.');\r\n }\r\n\r\n if (Array.isArray(co?.any)) {\r\n return this.hasAnyClaim(co.any);\r\n }\r\n if (Array.isArray(co?.all)) {\r\n return this.hasClaims(co.all);\r\n }\r\n }\r\n\r\n throw Error('Invalid claim');\r\n }\r\n}\r\n","import { User } from './user';\r\nimport { Injectable, signal } from '@angular/core';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class UserStore<U extends User = User> {\r\n public readonly user = signal<U | null | undefined>(undefined);\r\n\r\n constructor() {\r\n }\r\n}","import { Directive, TemplateRef, ViewContainerRef, input, effect } from '@angular/core';\r\nimport { ClaimLike } from './types';\r\nimport { UserStore } from './user-store';\r\n\r\n@Directive({\r\n selector: '[ng0Claim]',\r\n exportAs: 'ng0Claim',\r\n standalone: true\r\n})\r\nexport class UserDirective {\r\n public claim = input<ClaimLike | null | undefined>(undefined, { alias: 'ng0Claim' });\r\n private _viewCreated = false;\r\n\r\n constructor(\r\n templateRef: TemplateRef<any>,\r\n viewContainer: ViewContainerRef,\r\n userStore: UserStore,\r\n ) {\r\n effect(() => {\r\n let claim = this.claim();\r\n let user = userStore.user();\r\n let show = !user ? false : (claim == undefined ? true : user.hasClaim(claim))\r\n\r\n if (show && !this._viewCreated) {\r\n viewContainer.createEmbeddedView(templateRef);\r\n this._viewCreated = true;\r\n } else if (!show && this._viewCreated) {\r\n viewContainer.clear();\r\n this._viewCreated = false;\r\n }\r\n })\r\n }\r\n}\r\n","import { Directive, TemplateRef, ViewContainerRef, effect } from '@angular/core';\r\nimport { UserStore } from './user-store';\r\n\r\n@Directive({\r\n selector: '[ng0GuestUser]',\r\n exportAs: 'ng0GuestUser',\r\n standalone: true\r\n})\r\nexport class GuestUserDirective {\r\n private _created = false;\r\n\r\n constructor(\r\n templateRef: TemplateRef<any>,\r\n viewContainer: ViewContainerRef,\r\n userStore: UserStore,\r\n ) {\r\n effect(() => {\r\n let show = userStore.user() == undefined\r\n\r\n if (show && !this._created) {\r\n viewContainer.createEmbeddedView(templateRef);\r\n this._created = true;\r\n } else if (!show && this._created) {\r\n viewContainer.clear();\r\n this._created = false;\r\n }\r\n })\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { UserDirective } from './claim.directive';\r\nimport { GuestUserDirective } from './guest-user.directive';\r\n\r\nconst items = [\r\n UserDirective,\r\n GuestUserDirective\r\n]\r\n\r\n@NgModule({\r\n imports: items,\r\n exports: items\r\n})\r\nexport class SecurityModule { }\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.UserStore"],"mappings":";;;AAEA;MACa,IAAI,CAAA;AACe,IAAA,MAAA;AAA5B,IAAA,WAAA,CAA4B,MAAgB,EAAA;QAAhB,IAAM,CAAA,MAAA,GAAN,MAAM;;AAG3B,IAAA,SAAS,CAAC,MAAgB,EAAA;QAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;AAGrD,IAAA,WAAW,CAAC,MAAgB,EAAA;AAC/B,QAAA,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,C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AC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACHD,MAAM,KAAK,GAAG;IACV,aAAa;IACb;CACH;MAMY,cAAc,CAAA;uGAAd,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;AAAd,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,YARvB,aAAa;AACb,YAAA,kBAAkB,aADlB,aAAa;YACb,kBAAkB,CAAA,EAAA,CAAA;wGAOT,cAAc,EAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAJ1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,KAAK;AACd,oBAAA,OAAO,EAAE;AACZ,iBAAA;;;ACZD;;AAEG;;;;"}
@@ -0,0 +1,66 @@
1
+ import { HttpHeaders, HttpClient } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import * as i0 from '@angular/core';
4
+ import { InjectionToken, TransferState } from '@angular/core';
5
+ import { DataRequest, DataResult } from '@bootkit/ng0/data';
6
+
7
+ declare const HttpServiceBaseUrl: InjectionToken<unknown>;
8
+ interface HttpOptions {
9
+ /** Http request ID */
10
+ id?: string;
11
+ query?: any;
12
+ pathType?: 'relative' | 'absolute';
13
+ responseType?: 'json' | 'blob' | 'text';
14
+ contentType?: 'json' | 'multipart/form-data';
15
+ reportProgress?: boolean;
16
+ observe?: 'response' | 'body' | 'events';
17
+ /**
18
+ * Save response in transfer state
19
+ */
20
+ transferState?: {
21
+ enable: boolean;
22
+ clearAfterUse?: boolean;
23
+ };
24
+ }
25
+ declare abstract class HttpEvent {
26
+ readonly url: string;
27
+ readonly options?: HttpOptions;
28
+ constructor(url: string, options?: HttpOptions);
29
+ }
30
+ declare class HttpRequestSendEvent extends HttpEvent {
31
+ constructor(url: string, options?: HttpOptions);
32
+ }
33
+ declare class HttpResponseEvent extends HttpEvent {
34
+ constructor(url: string, options?: HttpOptions);
35
+ }
36
+ declare class HttpErrorEvent extends HttpEvent {
37
+ constructor(url: string, options?: HttpOptions);
38
+ }
39
+
40
+ declare class HttpService {
41
+ private _http;
42
+ private transferState;
43
+ private platformId;
44
+ private _eventsSubject;
45
+ private _baseUrl?;
46
+ events: Observable<HttpEvent>;
47
+ defaultHeaders?: HttpHeaders;
48
+ constructor(_http: HttpClient, transferState: TransferState, platformId: object, baseUrl?: string);
49
+ get<T>(url: string, options?: HttpOptions): Observable<T>;
50
+ getResult<T>(url: string, request: DataRequest, options?: HttpOptions): Observable<DataResult<T>>;
51
+ post<T>(url: string, body: any, options?: HttpOptions): Observable<T>;
52
+ put<T>(url: string, body: any, options?: HttpOptions): Observable<T>;
53
+ delete<T>(url: string, options?: HttpOptions): Observable<T>;
54
+ private tap;
55
+ private makeUrl;
56
+ private makeHttpClientOptions;
57
+ private makeBody;
58
+ private processBodyFields;
59
+ private mapDataRequesToQueryObject;
60
+ private _handleTransferState;
61
+ static ɵfac: i0.ɵɵFactoryDeclaration<HttpService, [null, null, null, { optional: true; }]>;
62
+ static ɵprov: i0.ɵɵInjectableDeclaration<HttpService>;
63
+ }
64
+
65
+ export { HttpErrorEvent, HttpEvent, HttpRequestSendEvent, HttpResponseEvent, HttpService, HttpServiceBaseUrl };
66
+ export type { HttpOptions };
package/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="@bootkit/ng0" />
5
- export * from './public-api';
1
+ declare const LibName = "bootkit/angular-pro";
2
+
3
+ export { LibName };