@bootkit/ng0 0.0.0-alpha.3 → 0.0.0-alpha.30
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.
- package/common/index.d.ts +271 -7
- package/components/accordion/index.d.ts +1 -1
- package/components/backdrop/index.d.ts +12 -0
- package/components/button/index.d.ts +48 -0
- package/components/card/index.d.ts +27 -0
- package/components/code/index.d.ts +35 -0
- package/components/confirmation/index.d.ts +66 -0
- package/components/dropdown/index.d.ts +140 -0
- package/components/form-field/index.d.ts +24 -41
- package/components/list/index.d.ts +259 -0
- package/components/modal/index.d.ts +22 -4
- package/components/nav/index.d.ts +23 -19
- package/components/pagination/index.d.ts +35 -9
- package/components/popover/index.d.ts +1 -1
- package/components/select/index.d.ts +159 -0
- package/components/sidenav/index.d.ts +59 -0
- package/components/stepper/index.d.ts +26 -0
- package/components/table/index.d.ts +273 -0
- package/components/toast/index.d.ts +1 -1
- package/components/tooltip/index.d.ts +1 -1
- package/components/vertical-menu/index.d.ts +61 -0
- package/data/index.d.ts +145 -45
- package/date/index.d.ts +34 -0
- package/fesm2022/bootkit-ng0-common.mjs +295 -12
- package/fesm2022/bootkit-ng0-common.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-accordion.mjs +15 -15
- package/fesm2022/bootkit-ng0-components-accordion.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-backdrop.mjs +46 -0
- package/fesm2022/bootkit-ng0-components-backdrop.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-button.mjs +119 -0
- package/fesm2022/bootkit-ng0-components-button.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-card.mjs +62 -0
- package/fesm2022/bootkit-ng0-components-card.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-code.mjs +70 -0
- package/fesm2022/bootkit-ng0-components-code.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-collapse.mjs +16 -16
- package/fesm2022/bootkit-ng0-components-collapse.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-confirmation.mjs +167 -0
- package/fesm2022/bootkit-ng0-components-confirmation.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-dropdown.mjs +302 -0
- package/fesm2022/bootkit-ng0-components-dropdown.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-form-field.mjs +62 -84
- package/fesm2022/bootkit-ng0-components-form-field.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-list.mjs +563 -0
- package/fesm2022/bootkit-ng0-components-list.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-modal.mjs +41 -24
- package/fesm2022/bootkit-ng0-components-modal.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-nav.mjs +59 -60
- package/fesm2022/bootkit-ng0-components-nav.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-offcanvas.mjs +10 -10
- package/fesm2022/bootkit-ng0-components-offcanvas.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-overlay.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-pagination.mjs +59 -24
- package/fesm2022/bootkit-ng0-components-pagination.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-popover.mjs +11 -11
- package/fesm2022/bootkit-ng0-components-popover.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-select.mjs +446 -0
- package/fesm2022/bootkit-ng0-components-select.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-sidenav.mjs +153 -0
- package/fesm2022/bootkit-ng0-components-sidenav.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-stepper.mjs +91 -0
- package/fesm2022/bootkit-ng0-components-stepper.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-table.mjs +461 -0
- package/fesm2022/bootkit-ng0-components-table.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-components-toast.mjs +7 -7
- package/fesm2022/bootkit-ng0-components-toast.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-tooltip.mjs +9 -9
- package/fesm2022/bootkit-ng0-components-tooltip.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-vertical-menu.mjs +161 -0
- package/fesm2022/bootkit-ng0-components-vertical-menu.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-data.mjs +180 -90
- package/fesm2022/bootkit-ng0-data.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-date.mjs +50 -0
- package/fesm2022/bootkit-ng0-date.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-file.mjs +50 -0
- package/fesm2022/bootkit-ng0-file.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-form.mjs +514 -0
- package/fesm2022/bootkit-ng0-form.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-http.mjs +224 -176
- package/fesm2022/bootkit-ng0-http.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-layouts-layout1.mjs +138 -0
- package/fesm2022/bootkit-ng0-layouts-layout1.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-localization-locales.mjs +101 -0
- package/fesm2022/bootkit-ng0-localization-locales.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-localization.mjs +347 -105
- package/fesm2022/bootkit-ng0-localization.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-platform-browser.mjs +51 -0
- package/fesm2022/bootkit-ng0-platform-browser.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-routing.mjs +80 -0
- package/fesm2022/bootkit-ng0-routing.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-script.mjs +59 -0
- package/fesm2022/bootkit-ng0-script.mjs.map +1 -0
- package/fesm2022/bootkit-ng0-security.mjs +18 -16
- package/fesm2022/bootkit-ng0-security.mjs.map +1 -1
- package/file/index.d.ts +22 -0
- package/form/index.d.ts +127 -0
- package/http/index.d.ts +138 -37
- package/layouts/layout1/index.d.ts +92 -0
- package/localization/index.d.ts +180 -41
- package/localization/locales/index.d.ts +7 -0
- package/package.json +95 -15
- package/platform/browser/index.d.ts +22 -0
- package/routing/index.d.ts +124 -0
- package/script/index.d.ts +27 -0
- package/security/index.d.ts +3 -9
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Pipe, NgModule, InjectionToken } from '@angular/core';
|
|
2
|
+
import { Injectable, Pipe, inject, NgModule, InjectionToken } from '@angular/core';
|
|
3
3
|
import { Subject } from 'rxjs';
|
|
4
|
-
import { CommonModule } from '@angular/common';
|
|
5
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
5
|
|
|
7
6
|
/** Locale */
|
|
@@ -20,22 +19,36 @@ class Locale {
|
|
|
20
19
|
/**
|
|
21
20
|
* Translates a key in the dictionary
|
|
22
21
|
* @param key The key to look up
|
|
23
|
-
* @
|
|
22
|
+
* @param fallback Optional fallback value if the key is not found
|
|
23
|
+
* @returns The translated string or the fallbackValue if not found
|
|
24
24
|
*/
|
|
25
|
-
translate(key) {
|
|
26
|
-
return this.definition.dictionary[key] ??
|
|
25
|
+
translate(key, fallback) {
|
|
26
|
+
return this.definition.dictionary?.[key] ?? fallback;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Translates an enum value
|
|
30
30
|
* @param enumName The name of the enum
|
|
31
31
|
* @param enumValue The value of the enum to translate
|
|
32
|
+
* @param fallback
|
|
32
33
|
* @returns The translated string or the enum value itself if not found
|
|
33
34
|
*/
|
|
34
|
-
translateEnum(enumName, enumValue) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
translateEnum(enumName, enumValue, fallback) {
|
|
36
|
+
let e = this.definition.enums?.[enumName];
|
|
37
|
+
if (!e) {
|
|
38
|
+
return fallback || enumValue?.toString();
|
|
39
|
+
}
|
|
40
|
+
if (enumValue === null) {
|
|
41
|
+
return e['[null]'] || e['[empty]'];
|
|
42
|
+
}
|
|
43
|
+
else if (enumValue === undefined) {
|
|
44
|
+
return e['[undefined]'] || e['[empty]'];
|
|
45
|
+
}
|
|
46
|
+
else if (enumValue === '') {
|
|
47
|
+
return e['empty'];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return e[enumValue] || e['[?]'] || fallback || enumValue?.toString();
|
|
51
|
+
}
|
|
39
52
|
}
|
|
40
53
|
/**
|
|
41
54
|
* Translates a form validation error
|
|
@@ -89,18 +102,8 @@ class Locale {
|
|
|
89
102
|
/**
|
|
90
103
|
* Clones and extends this object and returns a new Locale (without modifying this object).
|
|
91
104
|
*/
|
|
92
|
-
extend(
|
|
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
|
-
});
|
|
105
|
+
extend(definition) {
|
|
106
|
+
return new Locale({ ...this.definition, ...definition });
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
106
109
|
*
|
|
@@ -112,6 +115,8 @@ class Locale {
|
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
|
|
118
|
+
;
|
|
119
|
+
|
|
115
120
|
class LocalizationService {
|
|
116
121
|
_locales = [];
|
|
117
122
|
_activeLocale;
|
|
@@ -147,147 +152,384 @@ class LocalizationService {
|
|
|
147
152
|
get() {
|
|
148
153
|
return this._activeLocale;
|
|
149
154
|
}
|
|
150
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
151
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.
|
|
155
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
156
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizationService, providedIn: 'root' });
|
|
152
157
|
}
|
|
153
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizationService, decorators: [{
|
|
154
159
|
type: Injectable,
|
|
155
160
|
args: [{
|
|
156
161
|
providedIn: 'root'
|
|
157
162
|
}]
|
|
158
163
|
}], ctorParameters: () => [] });
|
|
159
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Pipe to translate a dictionary key into a localized string.
|
|
167
|
+
* It uses the LocalizationService to fetch the translation.
|
|
168
|
+
* If the translation is not found, it returns the fallback string if provided.
|
|
169
|
+
*/
|
|
160
170
|
class TranslatePipe {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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;
|
|
171
|
+
_ls;
|
|
172
|
+
constructor(_ls) {
|
|
173
|
+
this._ls = _ls;
|
|
177
174
|
}
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
transform(dictionaryKey, fallback) {
|
|
176
|
+
return this._ls.get()?.translate(dictionaryKey, fallback) || dictionaryKey;
|
|
177
|
+
}
|
|
178
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TranslatePipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
179
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: TranslatePipe, isStandalone: true, name: "ng0Translate" });
|
|
180
180
|
}
|
|
181
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TranslatePipe, decorators: [{
|
|
182
182
|
type: Pipe,
|
|
183
183
|
args: [{
|
|
184
184
|
name: 'ng0Translate',
|
|
185
185
|
standalone: true,
|
|
186
|
+
pure: true
|
|
187
|
+
}]
|
|
188
|
+
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
189
|
+
|
|
190
|
+
class TranslateEnumPipe {
|
|
191
|
+
_ls;
|
|
192
|
+
constructor(_ls) {
|
|
193
|
+
this._ls = _ls;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* @param enumValue
|
|
198
|
+
* @param enumName
|
|
199
|
+
* @param nullValueKey
|
|
200
|
+
* @param returnEnumAsFallback
|
|
201
|
+
* @param fallbackKey
|
|
202
|
+
* @returns
|
|
203
|
+
*/
|
|
204
|
+
transform(enumValue, enumName, fallback) {
|
|
205
|
+
return this._ls.get()?.translateEnum(enumName, enumValue, fallback);
|
|
206
|
+
}
|
|
207
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TranslateEnumPipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
208
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: TranslateEnumPipe, isStandalone: true, name: "ng0TranslateEnum" });
|
|
209
|
+
}
|
|
210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TranslateEnumPipe, decorators: [{
|
|
211
|
+
type: Pipe,
|
|
212
|
+
args: [{
|
|
213
|
+
name: 'ng0TranslateEnum',
|
|
214
|
+
standalone: true,
|
|
215
|
+
pure: true
|
|
216
|
+
}]
|
|
217
|
+
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
218
|
+
|
|
219
|
+
class TranslateBooleanPipe {
|
|
220
|
+
localeProvider;
|
|
221
|
+
constructor(localeProvider) {
|
|
222
|
+
this.localeProvider = localeProvider;
|
|
223
|
+
}
|
|
224
|
+
transform(value, falseKey = 'true', trueKey = 'false') {
|
|
225
|
+
return this.localeProvider.get()?.translate(value ? trueKey : falseKey);
|
|
226
|
+
}
|
|
227
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TranslateBooleanPipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
228
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: TranslateBooleanPipe, isStandalone: true, name: "ng0TranslateBool" });
|
|
229
|
+
}
|
|
230
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: TranslateBooleanPipe, decorators: [{
|
|
231
|
+
type: Pipe,
|
|
232
|
+
args: [{
|
|
233
|
+
name: 'ng0TranslateBool',
|
|
234
|
+
standalone: true,
|
|
235
|
+
pure: true
|
|
236
|
+
}]
|
|
237
|
+
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
238
|
+
|
|
239
|
+
class DatePipe {
|
|
240
|
+
_ls;
|
|
241
|
+
constructor(_ls) {
|
|
242
|
+
this._ls = _ls;
|
|
243
|
+
}
|
|
244
|
+
transform(value, format) {
|
|
245
|
+
return this._ls.get()?.formatDate(value, format);
|
|
246
|
+
}
|
|
247
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: DatePipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
248
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: DatePipe, isStandalone: true, name: "ng0Date" });
|
|
249
|
+
}
|
|
250
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: DatePipe, decorators: [{
|
|
251
|
+
type: Pipe,
|
|
252
|
+
args: [{
|
|
253
|
+
name: 'ng0Date',
|
|
254
|
+
standalone: true,
|
|
255
|
+
pure: true
|
|
256
|
+
}]
|
|
257
|
+
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
258
|
+
|
|
259
|
+
class LocalizePipe {
|
|
260
|
+
_ls;
|
|
261
|
+
constructor(_ls) {
|
|
262
|
+
this._ls = _ls;
|
|
263
|
+
}
|
|
264
|
+
transform(dictionaryKey) {
|
|
265
|
+
return this._ls.get()?.translate(dictionaryKey);
|
|
266
|
+
}
|
|
267
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizePipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
268
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: LocalizePipe, isStandalone: true, name: "ng0Localize", pure: false });
|
|
269
|
+
}
|
|
270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizePipe, decorators: [{
|
|
271
|
+
type: Pipe,
|
|
272
|
+
args: [{
|
|
273
|
+
name: 'ng0Localize',
|
|
274
|
+
standalone: true,
|
|
186
275
|
pure: false
|
|
187
276
|
}]
|
|
188
277
|
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
189
278
|
|
|
190
|
-
class
|
|
191
|
-
|
|
279
|
+
class LocalizeEnumPipe {
|
|
280
|
+
_ls;
|
|
192
281
|
_recompute = true;
|
|
193
282
|
_value;
|
|
194
|
-
constructor(
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
this._locale = x.new;
|
|
198
|
-
this._recompute = true;
|
|
199
|
-
});
|
|
283
|
+
constructor(_ls) {
|
|
284
|
+
this._ls = _ls;
|
|
285
|
+
_ls.change.pipe(takeUntilDestroyed()).subscribe(x => this._recompute = true);
|
|
200
286
|
}
|
|
201
|
-
|
|
287
|
+
/**
|
|
288
|
+
*
|
|
289
|
+
* @param enumValue
|
|
290
|
+
* @param enumName
|
|
291
|
+
* @param nullValueKey
|
|
292
|
+
* @param returnEnumAsFallback
|
|
293
|
+
* @param fallbackKey
|
|
294
|
+
* @returns
|
|
295
|
+
*/
|
|
296
|
+
transform(enumValue, enumName, fallback) {
|
|
202
297
|
if (this._recompute) {
|
|
203
|
-
|
|
204
|
-
var nullDictionaryKey = args[1];
|
|
205
|
-
this._value = enumValue ?
|
|
206
|
-
(this._locale.translateEnum(enumName, enumValue) ?? enumValue) :
|
|
207
|
-
(nullDictionaryKey ? this._locale.translate(nullDictionaryKey) : '');
|
|
298
|
+
this._value = this._ls.get()?.translateEnum(enumName, enumValue, fallback);
|
|
208
299
|
this._recompute = false;
|
|
209
300
|
}
|
|
210
301
|
return this._value;
|
|
211
302
|
}
|
|
212
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
213
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.
|
|
303
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizeEnumPipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
304
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: LocalizeEnumPipe, isStandalone: true, name: "ng0LocalizeEnum", pure: false });
|
|
214
305
|
}
|
|
215
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
306
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizeEnumPipe, decorators: [{
|
|
216
307
|
type: Pipe,
|
|
217
308
|
args: [{
|
|
218
|
-
name: '
|
|
309
|
+
name: 'ng0LocalizeEnum',
|
|
219
310
|
standalone: true,
|
|
220
311
|
pure: false
|
|
221
312
|
}]
|
|
222
313
|
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
223
314
|
|
|
224
|
-
class
|
|
225
|
-
|
|
226
|
-
constructor(
|
|
227
|
-
this.
|
|
315
|
+
class LocalizeBooleanPipe {
|
|
316
|
+
_ls;
|
|
317
|
+
constructor(_ls) {
|
|
318
|
+
this._ls = _ls;
|
|
228
319
|
}
|
|
229
320
|
transform(value, falseKey = 'true', trueKey) {
|
|
230
|
-
return this.
|
|
321
|
+
return this._ls.get()?.translate(value ? trueKey : falseKey);
|
|
231
322
|
}
|
|
232
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
233
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.
|
|
323
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizeBooleanPipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
324
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: LocalizeBooleanPipe, isStandalone: true, name: "ng0LocalizeBool", pure: false });
|
|
234
325
|
}
|
|
235
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
326
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizeBooleanPipe, decorators: [{
|
|
236
327
|
type: Pipe,
|
|
237
328
|
args: [{
|
|
238
|
-
name: '
|
|
329
|
+
name: 'ng0LocalizeBool',
|
|
239
330
|
standalone: true,
|
|
331
|
+
pure: false
|
|
240
332
|
}]
|
|
241
333
|
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
242
334
|
|
|
243
|
-
class
|
|
244
|
-
|
|
335
|
+
class LocalizeDatePipe {
|
|
336
|
+
_ls;
|
|
245
337
|
_value;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
338
|
+
_recompute = true;
|
|
339
|
+
constructor(_ls) {
|
|
340
|
+
this._ls = _ls;
|
|
341
|
+
_ls.change.pipe(takeUntilDestroyed()).subscribe(x => this._recompute = true);
|
|
251
342
|
}
|
|
252
|
-
transform(value) {
|
|
253
|
-
|
|
343
|
+
transform(value, format) {
|
|
344
|
+
if (this._recompute) {
|
|
345
|
+
this._value = this._ls.get()?.formatDate(value, format);
|
|
346
|
+
this._recompute = false;
|
|
347
|
+
}
|
|
348
|
+
return this._value;
|
|
254
349
|
}
|
|
255
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
256
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.
|
|
350
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizeDatePipe, deps: [{ token: LocalizationService }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
351
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: LocalizeDatePipe, isStandalone: true, name: "ng0LocalizeDate", pure: false });
|
|
257
352
|
}
|
|
258
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
353
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizeDatePipe, decorators: [{
|
|
259
354
|
type: Pipe,
|
|
260
355
|
args: [{
|
|
261
|
-
name: '
|
|
262
|
-
standalone: true
|
|
356
|
+
name: 'ng0LocalizeDate',
|
|
357
|
+
standalone: true,
|
|
358
|
+
pure: false
|
|
263
359
|
}]
|
|
264
360
|
}], ctorParameters: () => [{ type: LocalizationService }] });
|
|
265
361
|
|
|
266
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Default object formatter function.
|
|
364
|
+
* @param value The item to format.
|
|
365
|
+
* @returns The formatted string.
|
|
366
|
+
*/
|
|
367
|
+
function defaultFormatter(obj) {
|
|
368
|
+
return obj?.toString() || '';
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Creates a field formatter function.
|
|
372
|
+
* @param field
|
|
373
|
+
* @returns
|
|
374
|
+
* @private
|
|
375
|
+
*/
|
|
376
|
+
function createFieldFormatter(field) {
|
|
377
|
+
return (obj) => obj?.[field];
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Creates an array index formatter function.
|
|
381
|
+
* An array index formatter always returns the item at the specified index from an array object.
|
|
382
|
+
* @param index
|
|
383
|
+
* @returns an ObjectFormatter function.
|
|
384
|
+
* @private
|
|
385
|
+
*/
|
|
386
|
+
function createIndexFormatter(index) {
|
|
387
|
+
return (obj) => {
|
|
388
|
+
if (Array.isArray(obj)) {
|
|
389
|
+
return obj[+index]; // use + to cast boolean values to numbers
|
|
390
|
+
}
|
|
391
|
+
throw Error('Object is not an array');
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function createArrayFormatter(array) {
|
|
395
|
+
if (!Array.isArray(array)) {
|
|
396
|
+
throw Error('Object is not an array');
|
|
397
|
+
}
|
|
398
|
+
return (index) => array[+index];
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Returns a formatter function by its name and parameters.
|
|
402
|
+
* @param formatterName The format string in the form of "formatterName:param1:param2:..."
|
|
403
|
+
* @returns A ValueFormatterFunction
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
function createLocaleFormatter(locale, formatterName) {
|
|
407
|
+
let formatter = locale.definition.formatters?.[formatterName];
|
|
408
|
+
let formatterType = typeof formatter;
|
|
409
|
+
if (!formatter) {
|
|
410
|
+
console.warn(`The formatter "${formatterName}" is not defined in locale ${locale.definition.name}`);
|
|
411
|
+
return defaultFormatter;
|
|
412
|
+
}
|
|
413
|
+
if (formatterType === 'function') {
|
|
414
|
+
return formatter;
|
|
415
|
+
}
|
|
416
|
+
else if (Array.isArray(formatter)) {
|
|
417
|
+
return createArrayFormatter(formatter);
|
|
418
|
+
}
|
|
419
|
+
else if (formatterType == 'object' && formatter != null) {
|
|
420
|
+
return (value) => formatter[value] || '';
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
throw Error(`Invalid locale formatter: ${formatterName}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Creates an ObjectFormatter from various ObjectFormatterLike types.
|
|
428
|
+
* @param formatter The ObjectFormatterLike value to convert.
|
|
429
|
+
* @param locale Optional locale object for locale-based formatting.
|
|
430
|
+
* @returns An ObjectFormatter function.
|
|
431
|
+
*/
|
|
432
|
+
function createObjectFormatter(formatter, locale) {
|
|
433
|
+
switch (typeof formatter) {
|
|
434
|
+
case 'function':
|
|
435
|
+
return formatter;
|
|
436
|
+
case 'number':
|
|
437
|
+
return createIndexFormatter(formatter);
|
|
438
|
+
case 'string':
|
|
439
|
+
if (formatter.startsWith('@')) {
|
|
440
|
+
if (locale == null) {
|
|
441
|
+
throw Error('For using locale formatters, provide a Locale object.');
|
|
442
|
+
}
|
|
443
|
+
return createLocaleFormatter(locale, formatter.substring(1));
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
return createFieldFormatter(formatter);
|
|
447
|
+
}
|
|
448
|
+
case 'object':
|
|
449
|
+
if (Array.isArray(formatter)) {
|
|
450
|
+
// Create a composite formatter from multiple formatters.
|
|
451
|
+
const formatters = formatter.map(item => createObjectFormatter(item, locale));
|
|
452
|
+
return (obj) => formatters.reduce((previous, current, index) => index == 0 ? current(obj) : current(previous));
|
|
453
|
+
}
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
throw Error('invalid formatter value', { cause: formatter });
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Creates a function that converts a ObjectFormatterLike value into a ObjectFormatter.
|
|
460
|
+
* @param locale Optional locale object for locale-based formatting.
|
|
461
|
+
* @returns A function that takes a ObjectFormatterLike and returns a ObjectFormatter.
|
|
462
|
+
*/
|
|
463
|
+
function objectFormatterAttribute(locale) {
|
|
464
|
+
return (v) => createObjectFormatter(v, locale);
|
|
465
|
+
}
|
|
466
|
+
;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Format pipe to format objects using various formatter types.
|
|
470
|
+
*/
|
|
471
|
+
class FormatPipe {
|
|
472
|
+
_localizationService = inject(LocalizationService, { optional: true });
|
|
473
|
+
transform(obj, formatter, ...params) {
|
|
474
|
+
return createObjectFormatter(formatter, this._localizationService?.get())(obj, ...params);
|
|
475
|
+
}
|
|
476
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: FormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
477
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: FormatPipe, isStandalone: true, name: "ng0Format" });
|
|
478
|
+
}
|
|
479
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: FormatPipe, decorators: [{
|
|
480
|
+
type: Pipe,
|
|
481
|
+
args: [{
|
|
482
|
+
name: 'ng0Format',
|
|
483
|
+
standalone: true,
|
|
484
|
+
pure: true
|
|
485
|
+
}]
|
|
486
|
+
}] });
|
|
487
|
+
|
|
488
|
+
const Declares = [
|
|
489
|
+
// Pure pipes
|
|
267
490
|
TranslatePipe,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
DatePipe
|
|
491
|
+
TranslateEnumPipe,
|
|
492
|
+
TranslateBooleanPipe,
|
|
493
|
+
DatePipe,
|
|
494
|
+
FormatPipe,
|
|
495
|
+
// Impure pipes
|
|
496
|
+
LocalizePipe,
|
|
497
|
+
LocalizeEnumPipe,
|
|
498
|
+
LocalizeBooleanPipe,
|
|
499
|
+
LocalizeDatePipe
|
|
271
500
|
];
|
|
272
501
|
class LocalizationModule {
|
|
273
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.
|
|
274
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
502
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
503
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: LocalizationModule, imports: [
|
|
504
|
+
// Pure pipes
|
|
505
|
+
TranslatePipe,
|
|
506
|
+
TranslateEnumPipe,
|
|
507
|
+
TranslateBooleanPipe,
|
|
508
|
+
DatePipe,
|
|
509
|
+
FormatPipe,
|
|
510
|
+
// Impure pipes
|
|
511
|
+
LocalizePipe,
|
|
512
|
+
LocalizeEnumPipe,
|
|
513
|
+
LocalizeBooleanPipe,
|
|
514
|
+
LocalizeDatePipe], exports: [
|
|
515
|
+
// Pure pipes
|
|
516
|
+
TranslatePipe,
|
|
517
|
+
TranslateEnumPipe,
|
|
518
|
+
TranslateBooleanPipe,
|
|
519
|
+
DatePipe,
|
|
520
|
+
FormatPipe,
|
|
521
|
+
// Impure pipes
|
|
522
|
+
LocalizePipe,
|
|
523
|
+
LocalizeEnumPipe,
|
|
524
|
+
LocalizeBooleanPipe,
|
|
525
|
+
LocalizeDatePipe] });
|
|
526
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizationModule });
|
|
282
527
|
}
|
|
283
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.
|
|
528
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: LocalizationModule, decorators: [{
|
|
284
529
|
type: NgModule,
|
|
285
530
|
args: [{
|
|
286
|
-
imports:
|
|
287
|
-
|
|
288
|
-
Declarables
|
|
289
|
-
],
|
|
290
|
-
exports: Declarables
|
|
531
|
+
imports: Declares,
|
|
532
|
+
exports: Declares
|
|
291
533
|
}]
|
|
292
534
|
}] });
|
|
293
535
|
|
|
@@ -297,5 +539,5 @@ const LOCALE = new InjectionToken('LOCALE');
|
|
|
297
539
|
* Generated bundle index. Do not edit.
|
|
298
540
|
*/
|
|
299
541
|
|
|
300
|
-
export {
|
|
542
|
+
export { DatePipe, FormatPipe, LOCALE, Locale, LocalizationModule, LocalizationService, LocalizeBooleanPipe, LocalizeDatePipe, LocalizeEnumPipe, LocalizePipe, TranslateBooleanPipe, TranslateEnumPipe, TranslatePipe, createObjectFormatter, defaultFormatter, objectFormatterAttribute };
|
|
301
543
|
//# sourceMappingURL=bootkit-ng0-localization.mjs.map
|