@acorex/core 19.13.0 → 19.13.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.
- package/fesm2022/acorex-core-format.mjs +17 -16
- package/fesm2022/acorex-core-format.mjs.map +1 -1
- package/fesm2022/{acorex-core-locale-en-AU.profile-BW-_9tgT.mjs → acorex-core-locale-en-AU.profile-DNjKIaZS.mjs} +2 -2
- package/fesm2022/acorex-core-locale-en-AU.profile-DNjKIaZS.mjs.map +1 -0
- package/fesm2022/acorex-core-locale.mjs +2 -2
- package/fesm2022/acorex-core-locale.mjs.map +1 -1
- package/fesm2022/acorex-core-translation.mjs +250 -209
- package/fesm2022/acorex-core-translation.mjs.map +1 -1
- package/fesm2022/acorex-core-utils.mjs +140 -15
- package/fesm2022/acorex-core-utils.mjs.map +1 -1
- package/format/lib/format.service.d.ts +8 -7
- package/locale/lib/locale.types.d.ts +7 -7
- package/package.json +1 -1
- package/translation/index.d.ts +1 -1
- package/translation/lib/translation-loader.service.d.ts +20 -0
- package/translation/lib/translation.config.d.ts +19 -6
- package/translation/lib/translation.loader.d.ts +2 -2
- package/translation/lib/translation.parser.d.ts +7 -0
- package/translation/lib/translation.resolver.d.ts +9 -0
- package/translation/lib/translation.service.d.ts +13 -32
- package/translation/lib/translation.types.d.ts +8 -2
- package/translation/lib/translator.directive.d.ts +2 -2
- package/translation/lib/translator.pipe.d.ts +0 -2
- package/utils/index.d.ts +6 -5
- package/utils/lib/execution.utils.d.ts +33 -0
- package/utils/lib/string.utils.d.ts +4 -0
- package/fesm2022/acorex-core-locale-en-AU.profile-BW-_9tgT.mjs.map +0 -1
- package/utils/lib/string-util.d.ts +0 -6
- /package/utils/lib/{color-util.d.ts → color.utils.d.ts} +0 -0
- /package/utils/lib/{drawing-util.d.ts → drawing.utils.d.ts} +0 -0
- /package/utils/lib/{html-util.d.ts → html-utils.d.ts} +0 -0
- /package/utils/lib/{auto-unsubscribe.d.ts → lifecycle-helpers.utils.d.ts} +0 -0
@@ -27,6 +27,18 @@ class AXFormatterRegistryService {
|
|
27
27
|
get formatters() {
|
28
28
|
return this.plugins;
|
29
29
|
}
|
30
|
+
/**
|
31
|
+
* Resolves a formatter by its name.
|
32
|
+
* @param name The name of the formatter.
|
33
|
+
* @returns The formatter if found, otherwise throws an error.
|
34
|
+
*/
|
35
|
+
get(name) {
|
36
|
+
const formatter = this.formatters.find((c) => c.name == name);
|
37
|
+
if (!formatter) {
|
38
|
+
throw new Error(`Formatter not found: ${name}`);
|
39
|
+
}
|
40
|
+
return formatter;
|
41
|
+
}
|
30
42
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFormatterRegistryService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
31
43
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFormatterRegistryService, providedIn: 'root' }); }
|
32
44
|
}
|
@@ -46,26 +58,14 @@ class AXFormatService {
|
|
46
58
|
render() {
|
47
59
|
this.renderSubject.next();
|
48
60
|
}
|
49
|
-
/**
|
50
|
-
* Resolves a formatter by its name.
|
51
|
-
* @param name The name of the formatter.
|
52
|
-
* @returns The formatter if found, otherwise throws an error.
|
53
|
-
*/
|
54
|
-
resolveFormatter(name) {
|
55
|
-
const formatter = this.pluginRegistry.formatters.find((c) => c.name == name);
|
56
|
-
if (!formatter) {
|
57
|
-
throw new Error(`Formatter not found: ${name}`);
|
58
|
-
}
|
59
|
-
return formatter;
|
60
|
-
}
|
61
61
|
// Implementation of the format method
|
62
62
|
format(value, formatter, options) {
|
63
63
|
if (typeof formatter === 'string') {
|
64
|
-
const formatterRef = this.
|
64
|
+
const formatterRef = this.pluginRegistry.get(formatter);
|
65
65
|
return formatterRef.format(value, options);
|
66
66
|
}
|
67
67
|
else {
|
68
|
-
return new AXFormatFluent(this, value);
|
68
|
+
return new AXFormatFluent(this, this.pluginRegistry, value);
|
69
69
|
}
|
70
70
|
}
|
71
71
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.9", ngImport: i0, type: AXFormatService, deps: [{ token: AXFormatterRegistryService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
@@ -76,8 +76,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImpor
|
|
76
76
|
args: [{ providedIn: 'root' }]
|
77
77
|
}], ctorParameters: () => [{ type: AXFormatterRegistryService }] });
|
78
78
|
class AXFormatFluent {
|
79
|
-
constructor(formatService, initialValue) {
|
79
|
+
constructor(formatService, pluginRegistry, initialValue) {
|
80
80
|
this.formatService = formatService;
|
81
|
+
this.pluginRegistry = pluginRegistry;
|
81
82
|
this.initialValue = initialValue;
|
82
83
|
}
|
83
84
|
/**
|
@@ -88,7 +89,7 @@ class AXFormatFluent {
|
|
88
89
|
*/
|
89
90
|
to(formatter, options) {
|
90
91
|
try {
|
91
|
-
const formatterRef = this.
|
92
|
+
const formatterRef = this.pluginRegistry.get(formatter);
|
92
93
|
return formatterRef.format(this.initialValue, options);
|
93
94
|
}
|
94
95
|
catch (error) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-format.mjs","sources":["../../../../libs/core/format/src/lib/format.config.ts","../../../../libs/core/format/src/lib/format.service.ts","../../../../libs/core/format/src/lib/format.directive.ts","../../../../libs/core/format/src/lib/formatters/number.formatter.ts","../../../../libs/core/format/src/lib/formatters/string.formatter.ts","../../../../libs/core/format/src/lib/format.pipe.ts","../../../../libs/core/format/src/lib/format.module.ts","../../../../libs/core/format/src/acorex-core-format.ts"],"sourcesContent":["import { AXFormatOptions } from './format.types';\n\nexport abstract class AXFormatter {\n abstract get name(): string;\n abstract format(value: unknown, options?: AXFormatOptions | string): string;\n}\n","import { Injectable, Injector } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { AXFormatter } from './format.config';\nimport { AXFormatOptionsMap } from './format.types';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXFormatterRegistryService {\n private plugins: AXFormatter[] = [];\n\n private injector: Injector;\n\n constructor(injector: Injector) {\n this.injector = injector;\n }\n\n register(...plugins: (new () => AXFormatter)[]) {\n plugins.forEach((t) => {\n const childInjector = Injector.create({\n providers: [{ provide: t, useClass: t, deps: [] }],\n parent: this.injector,\n });\n const v = childInjector.get(t);\n\n if (v && !this.plugins.some((p) => p.name == v.name)) {\n this.plugins.push(v);\n }\n });\n }\n\n get formatters(): AXFormatter[] {\n return this.plugins;\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class AXFormatService {\n constructor(private pluginRegistry: AXFormatterRegistryService) {}\n\n private renderSubject = new Subject<void>();\n\n // Observable that other services/components can subscribe to\n onRender = this.renderSubject.asObservable();\n\n render() {\n this.renderSubject.next();\n }\n\n /**\n * Resolves a formatter by its name.\n * @param name The name of the formatter.\n * @returns The formatter if found, otherwise throws an error.\n */\n resolveFormatter(name: string): AXFormatter {\n const formatter = this.pluginRegistry.formatters.find((c) => c.name == name);\n if (!formatter) {\n throw new Error(`Formatter not found: ${name}`);\n }\n return formatter;\n }\n\n // Overload for traditional formatting\n format<K extends keyof AXFormatOptionsMap>(value: unknown, formatter: K, options?: AXFormatOptionsMap[K]): string;\n\n // Overload for starting fluent API chain\n format(value: unknown): AXFormatFluent;\n\n // Implementation of the format method\n format<K extends keyof AXFormatOptionsMap>(value: unknown, formatter?: K, options?: AXFormatOptionsMap[K]): string | AXFormatFluent {\n if (typeof formatter === 'string') {\n const formatterRef = this.resolveFormatter(formatter);\n return formatterRef.format(value, options);\n } else {\n return new AXFormatFluent(this, value);\n }\n }\n}\n\nclass AXFormatFluent {\n constructor(\n private formatService: AXFormatService,\n private initialValue: unknown,\n ) {}\n\n /**\n * Formats the value using the specified formatter and options.\n * @param formatter The name of the formatter to use.\n * @param options The options to pass to the formatter.\n * @returns The formatted string.\n */\n to<K extends keyof AXFormatOptionsMap>(formatter: K, options?: AXFormatOptionsMap[K]): string {\n try {\n const formatterRef = this.formatService.resolveFormatter(formatter);\n return formatterRef.format(this.initialValue, options);\n } catch (error) {\n return String(this.initialValue);\n }\n }\n}\n","import { Directive, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { AXFormatService } from './format.service';\nimport { AXFormatOptionsMap } from './format.types';\n\n@Directive({\n selector: '[formatter]',\n standalone: true,\n})\nexport class AXFormatterDirective implements OnInit {\n constructor(\n private templateRef: TemplateRef<any>,\n private viewContainer: ViewContainerRef,\n private formatService: AXFormatService,\n ) { }\n\n ngOnInit() {\n this.viewContainer.clear();\n this.viewContainer.createEmbeddedView(this.templateRef, {\n $implicit: <K extends keyof AXFormatOptionsMap>(value: unknown, formatter: K, options?: AXFormatOptionsMap[K]) => {\n return this.formatService.format(value, formatter, options);\n },\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport { defaults, isInteger, padStart } from 'lodash-es';\nimport { AXFormatter } from '../format.config';\nimport { AXFormatOptions } from '../format.types';\n\nexport interface AXNumberFormatterOptions extends AXFormatOptions {\n decimalPlaces?: number;\n thousandSeparator?: string;\n decimalSeparator?: string;\n zeroPadLength?: number; // New option for zero padding,\n locale?: string;\n}\n\ndeclare module '../format.types' {\n interface AXFormatOptionsMap {\n number: AXNumberFormatterOptions;\n }\n}\n\n@Injectable()\nexport class AXNumberFormatter implements AXFormatter {\n private separatorsCache: any = {};\n\n get name(): string {\n return 'number';\n }\n\n format(value: number, options: AXNumberFormatterOptions): string {\n const { thousandSeparator, decimalSeparator } = this.getLocaleSeparators(options?.locale);\n // Merge user options with default options\n const effectiveOptions = defaults({}, options, {\n thousandSeparator,\n decimalSeparator,\n zeroPadLength: 0,\n locale: navigator.language,\n });\n\n const sign = value < 0 ? '-' : '';\n const absoluteValue = Math.abs(value);\n\n // Handling zero padding for integer part\n let integerPart = Math.floor(absoluteValue).toString();\n if (effectiveOptions.zeroPadLength && effectiveOptions.zeroPadLength > integerPart.length) {\n integerPart = padStart(integerPart, effectiveOptions.zeroPadLength, '0');\n }\n\n // Applying thousand separator to integer part\n if (effectiveOptions.thousandSeparator) {\n integerPart = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, effectiveOptions.thousandSeparator);\n }\n\n // Constructing the final formatted value\n let formattedValue = sign + integerPart;\n if (effectiveOptions.decimalPlaces !== undefined) {\n // Limiting decimal places if specified\n const decimalPart = absoluteValue.toFixed(effectiveOptions.decimalPlaces).split('.')[1];\n formattedValue += effectiveOptions.decimalSeparator + decimalPart;\n } else if (!isInteger(value)) {\n // Showing full decimal part if decimalPlaces is not specified\n const decimalPart = absoluteValue.toString().split('.')[1] || '';\n if (decimalPart.length > 0) {\n formattedValue += effectiveOptions.decimalSeparator + decimalPart;\n }\n }\n\n return formattedValue;\n }\n\n private getLocaleSeparators(locale = navigator.language): {\n thousandSeparator: string;\n decimalSeparator: string;\n } {\n // Use cache if available\n if (this.separatorsCache[locale]) {\n return this.separatorsCache[locale];\n }\n\n const numberFormat = new Intl.NumberFormat(locale);\n const parts = numberFormat.formatToParts(1234567.89);\n let thousandSeparator = '';\n let decimalSeparator = '';\n\n for (const part of parts) {\n if (part.type === 'group') {\n thousandSeparator = part.value;\n } else if (part.type === 'decimal') {\n decimalSeparator = part.value;\n }\n }\n\n // Cache the result\n this.separatorsCache[locale] = { thousandSeparator, decimalSeparator };\n return this.separatorsCache[locale];\n }\n}\n","import { get } from 'lodash-es';\nimport { AXFormatter } from '../format.config';\nimport { AXFormatOptions } from '../format.types';\n\nexport interface AXStringFormatterOptions extends AXFormatOptions {\n [key: string]: any;\n}\n\ndeclare module '../format.types' {\n interface AXFormatOptionsMap {\n string: AXStringFormatterOptions;\n }\n}\n\nexport class AXStringFormatter implements AXFormatter {\n get name(): string {\n return 'string';\n }\n\n format(value: unknown, options: AXStringFormatterOptions): string {\n if (typeof value != 'string') return String(value);\n const result = get(options, value)\n ? get(options, value)\n : value.replace(/{{\\s*([^}]+)\\s*}}/g, (match, path: string) => {\n return (get(options, path.trim()) as string) ?? match;\n });\n\n return result;\n }\n}\n","import { AXEventData, AXEventService } from '@acorex/core/events';\nimport { Pipe, PipeTransform, inject } from '@angular/core';\nimport { Observable, filter, of, startWith, switchMap } from 'rxjs';\nimport { AXFormatService } from './format.service';\nimport { AXFormatOptions } from './format.types';\n\nenum AXLocaleEvents {\n AXLocaleChanged = 'AX_LOCALE_CHANGED',\n AXLocaleLoaded = 'AX_LOCALE_LOADED',\n //\n AXCalendarChanged = 'AX_CALENDAR_CHANGED',\n //\n AXLanguageChanged = 'AX_LANGUAGE_CHANGED',\n AXLanguageLoaded = 'AX_LANGUAGE_LOADED',\n}\n\n\n@Pipe({\n name: 'format',\n standalone: true,\n pure: true,\n})\nexport class AXFormatPipe implements PipeTransform {\n private formatService = inject(AXFormatService);\n private eventService = inject(AXEventService);\n\n private triggers = [...Object.values(AXLocaleEvents).map((event) => event as string)];\n\n transform(value: unknown, name: string, options?: AXFormatOptions | string): Observable<string> {\n // Initial formatted value\n const initialFormattedValue = this.formatService.format(value, name as any, options);\n\n // React to language changes and re-format the value\n return this.eventService.onEvent.pipe(\n filter((event: AXEventData) => this.triggers.includes(event.type as AXLocaleEvents)),\n startWith(initialFormattedValue), // Emit the initial formatted value immediately\n switchMap((event) => {\n // Re-call format method on every language change\n const formattedValue = this.formatService.format(value, name as any, options);\n return of(formattedValue);\n }),\n );\n }\n}\n","import { Inject, ModuleWithProviders, NgModule } from '@angular/core';\nimport { AXFormatter } from './format.config';\nimport { AXFormatterDirective } from './format.directive';\nimport { AXFormatterRegistryService } from './format.service';\nimport { AXNumberFormatter } from './formatters/number.formatter';\nimport { AXStringFormatter } from './formatters/string.formatter';\nimport { AXFormatPipe } from './format.pipe';\n\nconst BUILT_IN_RULES = [AXNumberFormatter, AXStringFormatter];\n\nexport interface AXFormatModuleConfigs {\n formatters: (new () => AXFormatter)[];\n}\n\n@NgModule({\n imports: [AXFormatterDirective, AXFormatPipe],\n exports: [AXFormatterDirective, AXFormatPipe],\n})\nexport class AXFormatModule {\n static forRoot(configs?: AXFormatModuleConfigs): ModuleWithProviders<AXFormatModule> {\n return {\n ngModule: AXFormatModule,\n providers: [\n ...(configs?.formatters || []),\n {\n provide: 'AXFormatModuleFactory',\n useFactory: (pluginRegistry: AXFormatterRegistryService) => () => {\n pluginRegistry.register(...[...BUILT_IN_RULES, ...(configs?.formatters || [])]);\n },\n deps: [AXFormatterRegistryService],\n multi: true,\n },\n ],\n };\n }\n\n static forChild(configs?: AXFormatModuleConfigs): ModuleWithProviders<AXFormatModule> {\n return {\n ngModule: AXFormatModule,\n providers: [\n ...(configs?.formatters || []),\n {\n provide: 'AXFormatModuleFactory',\n useFactory: (pluginRegistry: AXFormatterRegistryService) => () => {\n pluginRegistry.register(...[...BUILT_IN_RULES, ...(configs?.formatters || [])]);\n },\n deps: [AXFormatterRegistryService],\n multi: true,\n },\n ],\n };\n }\n\n /**\n * @ignore\n */\n constructor(@Inject('AXFormatModuleFactory') instances: any[]) {\n instances.forEach((f) => {\n f();\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.AXFormatService"],"mappings":";;;;;;MAEsB,WAAW,CAAA;AAGhC;;MCGY,0BAA0B,CAAA;AAKrC,IAAA,WAAA,CAAY,QAAkB,EAAA;QAJtB,IAAO,CAAA,OAAA,GAAkB,EAAE;AAKjC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;;IAG1B,QAAQ,CAAC,GAAG,OAAkC,EAAA;AAC5C,QAAA,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAI;AACpB,YAAA,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC;AACpC,gBAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBAClD,MAAM,EAAE,IAAI,CAAC,QAAQ;AACtB,aAAA,CAAC;YACF,M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tChC,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,YAHf,oBAAoB,EAAE,YAAY,CAClC,EAAA,OAAA,EAAA,CAAA,oBAAoB,EAAE,YAAY,CAAA,EAAA,CAAA,CAAA;+GAEjC,cAAc,EAAA,CAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAJ1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,CAAC;AAC7C,oBAAA,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,CAAC;AAC9C,iBAAA;;0BAuCc,MAAM;2BAAC,uBAAuB;;;ACxD7C;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-format.mjs","sources":["../../../../libs/core/format/src/lib/format.config.ts","../../../../libs/core/format/src/lib/format.service.ts","../../../../libs/core/format/src/lib/format.directive.ts","../../../../libs/core/format/src/lib/formatters/number.formatter.ts","../../../../libs/core/format/src/lib/formatters/string.formatter.ts","../../../../libs/core/format/src/lib/format.pipe.ts","../../../../libs/core/format/src/lib/format.module.ts","../../../../libs/core/format/src/acorex-core-format.ts"],"sourcesContent":["import { AXFormatOptions } from './format.types';\n\nexport abstract class AXFormatter {\n abstract get name(): string;\n abstract format(value: unknown, options?: AXFormatOptions | string): string;\n}\n","import { Injectable, Injector } from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { AXFormatter } from './format.config';\nimport { AXFormatOptionsMap } from './format.types';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXFormatterRegistryService {\n private plugins: AXFormatter[] = [];\n\n private injector: Injector;\n\n constructor(injector: Injector) {\n this.injector = injector;\n }\n\n register(...plugins: (new () => AXFormatter)[]) {\n plugins.forEach((t) => {\n const childInjector = Injector.create({\n providers: [{ provide: t, useClass: t, deps: [] }],\n parent: this.injector,\n });\n const v = childInjector.get(t);\n\n if (v && !this.plugins.some((p) => p.name == v.name)) {\n this.plugins.push(v);\n }\n });\n }\n\n get formatters(): AXFormatter[] {\n return this.plugins;\n }\n\n /**\n * Resolves a formatter by its name.\n * @param name The name of the formatter.\n * @returns The formatter if found, otherwise throws an error.\n */\n get(name: string): AXFormatter {\n const formatter = this.formatters.find((c) => c.name == name);\n if (!formatter) {\n throw new Error(`Formatter not found: ${name}`);\n }\n return formatter;\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class AXFormatService {\n constructor(private pluginRegistry: AXFormatterRegistryService) { }\n\n private renderSubject = new Subject<void>();\n\n // Observable that other services/components can subscribe to\n onRender = this.renderSubject.asObservable();\n\n render() {\n this.renderSubject.next();\n }\n\n\n\n // Overload for traditional formatting\n format<K extends keyof AXFormatOptionsMap>(value: unknown, formatter: K, options?: AXFormatOptionsMap[K]): string;\n\n // Overload for starting fluent API chain\n format(value: unknown): AXFormatFluent;\n\n // Implementation of the format method\n format<K extends keyof AXFormatOptionsMap>(value: unknown, formatter?: K, options?: AXFormatOptionsMap[K]): string | AXFormatFluent {\n if (typeof formatter === 'string') {\n const formatterRef = this.pluginRegistry.get(formatter);\n return formatterRef.format(value, options);\n } else {\n return new AXFormatFluent(this, this.pluginRegistry, value);\n }\n }\n}\n\nclass AXFormatFluent {\n constructor(\n private formatService: AXFormatService,\n private pluginRegistry: AXFormatterRegistryService,\n private initialValue: unknown,\n ) { }\n\n /**\n * Formats the value using the specified formatter and options.\n * @param formatter The name of the formatter to use.\n * @param options The options to pass to the formatter.\n * @returns The formatted string.\n */\n to<K extends keyof AXFormatOptionsMap>(formatter: K, options?: AXFormatOptionsMap[K]): string {\n try {\n const formatterRef = this.pluginRegistry.get(formatter);\n return formatterRef.format(this.initialValue, options);\n } catch (error) {\n return String(this.initialValue);\n }\n }\n}\n","import { Directive, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { AXFormatService } from './format.service';\nimport { AXFormatOptionsMap } from './format.types';\n\n@Directive({\n selector: '[formatter]',\n standalone: true,\n})\nexport class AXFormatterDirective implements OnInit {\n constructor(\n private templateRef: TemplateRef<any>,\n private viewContainer: ViewContainerRef,\n private formatService: AXFormatService,\n ) { }\n\n ngOnInit() {\n this.viewContainer.clear();\n this.viewContainer.createEmbeddedView(this.templateRef, {\n $implicit: <K extends keyof AXFormatOptionsMap>(value: unknown, formatter: K, options?: AXFormatOptionsMap[K]) => {\n return this.formatService.format(value, formatter, options);\n },\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport { defaults, isInteger, padStart } from 'lodash-es';\nimport { AXFormatter } from '../format.config';\nimport { AXFormatOptions } from '../format.types';\n\nexport interface AXNumberFormatterOptions extends AXFormatOptions {\n decimalPlaces?: number;\n thousandSeparator?: string;\n decimalSeparator?: string;\n zeroPadLength?: number; // New option for zero padding,\n locale?: string;\n}\n\ndeclare module '../format.types' {\n interface AXFormatOptionsMap {\n number: AXNumberFormatterOptions;\n }\n}\n\n@Injectable()\nexport class AXNumberFormatter implements AXFormatter {\n private separatorsCache: any = {};\n\n get name(): string {\n return 'number';\n }\n\n format(value: number, options: AXNumberFormatterOptions): string {\n const { thousandSeparator, decimalSeparator } = this.getLocaleSeparators(options?.locale);\n // Merge user options with default options\n const effectiveOptions = defaults({}, options, {\n thousandSeparator,\n decimalSeparator,\n zeroPadLength: 0,\n locale: navigator.language,\n });\n\n const sign = value < 0 ? '-' : '';\n const absoluteValue = Math.abs(value);\n\n // Handling zero padding for integer part\n let integerPart = Math.floor(absoluteValue).toString();\n if (effectiveOptions.zeroPadLength && effectiveOptions.zeroPadLength > integerPart.length) {\n integerPart = padStart(integerPart, effectiveOptions.zeroPadLength, '0');\n }\n\n // Applying thousand separator to integer part\n if (effectiveOptions.thousandSeparator) {\n integerPart = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, effectiveOptions.thousandSeparator);\n }\n\n // Constructing the final formatted value\n let formattedValue = sign + integerPart;\n if (effectiveOptions.decimalPlaces !== undefined) {\n // Limiting decimal places if specified\n const decimalPart = absoluteValue.toFixed(effectiveOptions.decimalPlaces).split('.')[1];\n formattedValue += effectiveOptions.decimalSeparator + decimalPart;\n } else if (!isInteger(value)) {\n // Showing full decimal part if decimalPlaces is not specified\n const decimalPart = absoluteValue.toString().split('.')[1] || '';\n if (decimalPart.length > 0) {\n formattedValue += effectiveOptions.decimalSeparator + decimalPart;\n }\n }\n\n return formattedValue;\n }\n\n private getLocaleSeparators(locale = navigator.language): {\n thousandSeparator: string;\n decimalSeparator: string;\n } {\n // Use cache if available\n if (this.separatorsCache[locale]) {\n return this.separatorsCache[locale];\n }\n\n const numberFormat = new Intl.NumberFormat(locale);\n const parts = numberFormat.formatToParts(1234567.89);\n let thousandSeparator = '';\n let decimalSeparator = '';\n\n for (const part of parts) {\n if (part.type === 'group') {\n thousandSeparator = part.value;\n } else if (part.type === 'decimal') {\n decimalSeparator = part.value;\n }\n }\n\n // Cache the result\n this.separatorsCache[locale] = { thousandSeparator, decimalSeparator };\n return this.separatorsCache[locale];\n }\n}\n","import { get } from 'lodash-es';\nimport { AXFormatter } from '../format.config';\nimport { AXFormatOptions } from '../format.types';\n\nexport interface AXStringFormatterOptions extends AXFormatOptions {\n [key: string]: any;\n}\n\ndeclare module '../format.types' {\n interface AXFormatOptionsMap {\n string: AXStringFormatterOptions;\n }\n}\n\nexport class AXStringFormatter implements AXFormatter {\n get name(): string {\n return 'string';\n }\n\n format(value: unknown, options: AXStringFormatterOptions): string {\n if (typeof value != 'string') return String(value);\n const result = get(options, value)\n ? get(options, value)\n : value.replace(/{{\\s*([^}]+)\\s*}}/g, (match, path: string) => {\n return (get(options, path.trim()) as string) ?? match;\n });\n\n return result;\n }\n}\n","import { AXEventData, AXEventService } from '@acorex/core/events';\nimport { Pipe, PipeTransform, inject } from '@angular/core';\nimport { Observable, filter, of, startWith, switchMap } from 'rxjs';\nimport { AXFormatService } from './format.service';\nimport { AXFormatOptions } from './format.types';\n\nenum AXLocaleEvents {\n AXLocaleChanged = 'AX_LOCALE_CHANGED',\n AXLocaleLoaded = 'AX_LOCALE_LOADED',\n //\n AXCalendarChanged = 'AX_CALENDAR_CHANGED',\n //\n AXLanguageChanged = 'AX_LANGUAGE_CHANGED',\n AXLanguageLoaded = 'AX_LANGUAGE_LOADED',\n}\n\n\n@Pipe({\n name: 'format',\n standalone: true,\n pure: true,\n})\nexport class AXFormatPipe implements PipeTransform {\n private formatService = inject(AXFormatService);\n private eventService = inject(AXEventService);\n\n private triggers = [...Object.values(AXLocaleEvents).map((event) => event as string)];\n\n transform(value: unknown, name: string, options?: AXFormatOptions | string): Observable<string> {\n // Initial formatted value\n const initialFormattedValue = this.formatService.format(value, name as any, options);\n\n // React to language changes and re-format the value\n return this.eventService.onEvent.pipe(\n filter((event: AXEventData) => this.triggers.includes(event.type as AXLocaleEvents)),\n startWith(initialFormattedValue), // Emit the initial formatted value immediately\n switchMap((event) => {\n // Re-call format method on every language change\n const formattedValue = this.formatService.format(value, name as any, options);\n return of(formattedValue);\n }),\n );\n }\n}\n","import { Inject, ModuleWithProviders, NgModule } from '@angular/core';\nimport { AXFormatter } from './format.config';\nimport { AXFormatterDirective } from './format.directive';\nimport { AXFormatterRegistryService } from './format.service';\nimport { AXNumberFormatter } from './formatters/number.formatter';\nimport { AXStringFormatter } from './formatters/string.formatter';\nimport { AXFormatPipe } from './format.pipe';\n\nconst BUILT_IN_RULES = [AXNumberFormatter, AXStringFormatter];\n\nexport interface AXFormatModuleConfigs {\n formatters: (new () => AXFormatter)[];\n}\n\n@NgModule({\n imports: [AXFormatterDirective, AXFormatPipe],\n exports: [AXFormatterDirective, AXFormatPipe],\n})\nexport class AXFormatModule {\n static forRoot(configs?: AXFormatModuleConfigs): ModuleWithProviders<AXFormatModule> {\n return {\n ngModule: AXFormatModule,\n providers: [\n ...(configs?.formatters || []),\n {\n provide: 'AXFormatModuleFactory',\n useFactory: (pluginRegistry: AXFormatterRegistryService) => () => {\n pluginRegistry.register(...[...BUILT_IN_RULES, ...(configs?.formatters || [])]);\n },\n deps: [AXFormatterRegistryService],\n multi: true,\n },\n ],\n };\n }\n\n static forChild(configs?: AXFormatModuleConfigs): ModuleWithProviders<AXFormatModule> {\n return {\n ngModule: AXFormatModule,\n providers: [\n ...(configs?.formatters || []),\n {\n provide: 'AXFormatModuleFactory',\n useFactory: (pluginRegistry: AXFormatterRegistryService) => () => {\n pluginRegistry.register(...[...BUILT_IN_RULES, ...(configs?.formatters || [])]);\n },\n deps: [AXFormatterRegistryService],\n multi: true,\n },\n ],\n };\n }\n\n /**\n * @ignore\n */\n constructor(@Inject('AXFormatModuleFactory') instances: any[]) {\n instances.forEach((f) => {\n f();\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.AXFormatService"],"mappings":";;;;;;MAEsB,WAAW,CAAA;AAGhC;;MCGY,0BAA0B,CAAA;AAKrC,IAAA,WAAA,CAAY,QAAkB,EAAA;QAJtB,IAAO,CAAA,OAAA,GAAkB,EAAE;AAKjC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;;IAG1B,QAAQ,CAAC,GAAG,OAAkC,EAAA;AAC5C,QAAA,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAI;AACpB,YAAA,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC;AACpC,gBAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBAClD,MAAM,EAAE,IAAI,CAAC,QAAQ;AACtB,aAAA,CAAC;YACF,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YAE9B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,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AA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,YAHf,oBAAoB,EAAE,YAAY,CAClC,EAAA,OAAA,EAAA,CAAA,oBAAoB,EAAE,YAAY,CAAA,EAAA,CAAA,CAAA;+GAEjC,cAAc,EAAA,CAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAJ1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,CAAC;AAC7C,oBAAA,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,CAAC;AAC9C,iBAAA;;0BAuCc,MAAM;2BAAC,uBAAuB;;;ACxD7C;;AAEG;;;;"}
|
@@ -50,7 +50,7 @@ const AXAURegionalConfig = {
|
|
50
50
|
distance: 'kilometers',
|
51
51
|
weight: 'kilograms',
|
52
52
|
volume: 'liters',
|
53
|
-
speed: '
|
53
|
+
speed: 'kmh',
|
54
54
|
area: 'square-meters',
|
55
55
|
},
|
56
56
|
i18nMeta: {
|
@@ -61,4 +61,4 @@ const AXAURegionalConfig = {
|
|
61
61
|
};
|
62
62
|
|
63
63
|
export { AXAURegionalConfig };
|
64
|
-
//# sourceMappingURL=acorex-core-locale-en-AU.profile-
|
64
|
+
//# sourceMappingURL=acorex-core-locale-en-AU.profile-DNjKIaZS.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"acorex-core-locale-en-AU.profile-DNjKIaZS.mjs","sources":["../../../../libs/core/locale/src/lib/profiles/en-AU.profile.ts"],"sourcesContent":["import { AXLocaleProfile } from \"../locale.types\";\n\nexport const AXAURegionalConfig: AXLocaleProfile = {\n localeInfo: {\n code: 'en-AU',\n language: 'en',\n region: 'AU',\n timezone: 'Australia/Sydney',\n },\n calendar: {\n system: 'gregorian',\n week: {\n startsOn: 1, // Monday\n weekends: [0, 6], // Sunday + Saturday\n },\n clock: {\n format24Hour: true,\n },\n },\n formats: {\n date: {\n short: 'DD/MM/YY',\n medium: 'DD MMM YYYY',\n long: 'DD MMMM YYYY',\n full: 'dddd, DD MMMM YYYY',\n },\n time: {\n short: 'HH:mm',\n medium: 'HH:mm:ss',\n long: 'HH:mm:ss Z',\n full: 'HH:mm:ss ZZZZ',\n },\n datetime: {\n short: 'DD/MM/YY HH:mm',\n medium: 'DD MMM YYYY HH:mm:ss',\n long: 'DD MMMM YYYY HH:mm:ss Z',\n full: 'dddd, DD MMMM YYYY HH:mm:ss ZZZZ',\n },\n numbers: {\n decimalPattern: '1,000.00',\n currency: {\n code: 'AUD',\n },\n },\n contacts: {\n phone: '04XX XXX XXX',\n postalCode: '0000',\n },\n },\n\n units: {\n temperature: 'celsius',\n distance: 'kilometers',\n weight: 'kilograms',\n volume: 'liters',\n speed: 'kmh',\n area: 'square-meters',\n },\n\n i18nMeta: {\n rtl: false,\n fallbackLocales: ['en-AU'],\n supportedLanguages: ['en-AU'],\n },\n};\n"],"names":[],"mappings":"AAEa,MAAA,kBAAkB,GAAoB;AAC/C,IAAA,UAAU,EAAE;AACR,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,QAAQ,EAAE,kBAAkB;AAC/B,KAAA;AACD,IAAA,QAAQ,EAAE;AACN,QAAA,MAAM,EAAE,WAAW;AACnB,QAAA,IAAI,EAAE;YACF,QAAQ,EAAE,CAAC;AACX,YAAA,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACnB,SAAA;AACD,QAAA,KAAK,EAAE;AACH,YAAA,YAAY,EAAE,IAAI;AACrB,SAAA;AACJ,KAAA;AACD,IAAA,OAAO,EAAE;AACL,QAAA,IAAI,EAAE;AACF,YAAA,KAAK,EAAE,UAAU;AACjB,YAAA,MAAM,EAAE,aAAa;AACrB,YAAA,IAAI,EAAE,cAAc;AACpB,YAAA,IAAI,EAAE,oBAAoB;AAC7B,SAAA;AACD,QAAA,IAAI,EAAE;AACF,YAAA,KAAK,EAAE,OAAO;AACd,YAAA,MAAM,EAAE,UAAU;AAClB,YAAA,IAAI,EAAE,YAAY;AAClB,YAAA,IAAI,EAAE,eAAe;AACxB,SAAA;AACD,QAAA,QAAQ,EAAE;AACN,YAAA,KAAK,EAAE,gBAAgB;AACvB,YAAA,MAAM,EAAE,sBAAsB;AAC9B,YAAA,IAAI,EAAE,yBAAyB;AAC/B,YAAA,IAAI,EAAE,kCAAkC;AAC3C,SAAA;AACD,QAAA,OAAO,EAAE;AACL,YAAA,cAAc,EAAE,UAAU;AAC1B,YAAA,QAAQ,EAAE;AACN,gBAAA,IAAI,EAAE,KAAK;AACd,aAAA;AACJ,SAAA;AACD,QAAA,QAAQ,EAAE;AACN,YAAA,KAAK,EAAE,cAAc;AACrB,YAAA,UAAU,EAAE,MAAM;AACrB,SAAA;AACJ,KAAA;AAED,IAAA,KAAK,EAAE;AACH,QAAA,WAAW,EAAE,SAAS;AACtB,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,MAAM,EAAE,WAAW;AACnB,QAAA,MAAM,EAAE,QAAQ;AAChB,QAAA,KAAK,EAAE,KAAK;AACZ,QAAA,IAAI,EAAE,eAAe;AACxB,KAAA;AAED,IAAA,QAAQ,EAAE;AACN,QAAA,GAAG,EAAE,KAAK;QACV,eAAe,EAAE,CAAC,OAAO,CAAC;QAC1B,kBAAkB,EAAE,CAAC,OAAO,CAAC;AAChC,KAAA;;;;;"}
|
@@ -22,7 +22,7 @@ const AX_LOCALE_PROFILE_PROVIDERS = new InjectionToken('AX_LOCALE_PROFILE_PROVID
|
|
22
22
|
class AXLocaleProfileProviderDefault {
|
23
23
|
async provide() {
|
24
24
|
return {
|
25
|
-
'en-AU': () => import('./acorex-core-locale-en-AU.profile-
|
25
|
+
'en-AU': () => import('./acorex-core-locale-en-AU.profile-DNjKIaZS.mjs').then(m => m.AXAURegionalConfig),
|
26
26
|
'en-US': () => Promise.resolve().then(function () { return enUS_profile; }).then(m => m.AXUSLocaleProfile),
|
27
27
|
'fa-IR': () => Promise.resolve().then(function () { return faIR_profile; }).then(m => m.AXIRLocaleProfile),
|
28
28
|
};
|
@@ -229,7 +229,7 @@ const AXIRLocaleProfile = {
|
|
229
229
|
distance: 'kilometers',
|
230
230
|
weight: 'kilograms',
|
231
231
|
volume: 'liters',
|
232
|
-
speed: '
|
232
|
+
speed: 'kmh',
|
233
233
|
area: 'square-meters',
|
234
234
|
},
|
235
235
|
i18nMeta: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-locale.mjs","sources":["../../../../libs/core/locale/src/lib/locale.config.ts","../../../../libs/core/locale/src/lib/locale-profile-provider.service.ts","../../../../libs/core/locale/src/lib/locale.types.ts","../../../../libs/core/locale/src/lib/profiles/en-US.profile.ts","../../../../libs/core/locale/src/lib/profiles/fa-IR.profile.ts","../../../../libs/core/locale/src/lib/locale.service.ts","../../../../libs/core/locale/src/lib/locale.module.ts","../../../../libs/core/locale/src/lib/formatters/currency.formatter.ts","../../../../libs/core/locale/src/acorex-core-locale.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\n\n\n\nexport interface AXLocaleConfig {\n default: string;\n}\n\n\n\nexport const AX_LOCALE_CONFIG = new InjectionToken<AXLocaleConfig>('AX_LOCALE_CONFIG', {\n providedIn: 'root',\n factory: () => {\n return {\n default: 'en-US',\n };\n },\n});\n\n\n\n\n\n\n\n\n\n","import { inject, Injectable, InjectionToken } from \"@angular/core\";\nimport { AXLocaleProfile } from \"./locale.types\";\n\n// Record of locale code → loader function (returns profile or Promise<profile>)\nexport type AXLocaleProfileProviderResult = Record<string, () => Promise<AXLocaleProfile> | AXLocaleProfile>;\n\nexport interface AXLocaleProfileProvider {\n provide(): Promise<AXLocaleProfileProviderResult>;\n}\n\nexport const AX_LOCALE_PROFILE_PROVIDERS = new InjectionToken<AXLocaleProfileProvider[]>(\n 'AX_LOCALE_PROFILE_PROVIDERS',\n {\n providedIn: 'root',\n factory: () => [new AXLocaleProfileProviderDefault()],\n }\n);\n\n// ✅ Lazy-loaded default provider\nexport class AXLocaleProfileProviderDefault implements AXLocaleProfileProvider {\n async provide(): Promise<AXLocaleProfileProviderResult> {\n return {\n 'en-AU': () => import('./profiles/en-AU.profile').then(m => m.AXAURegionalConfig),\n 'en-US': () => import('./profiles/en-US.profile').then(m => m.AXUSLocaleProfile),\n 'fa-IR': () => import('./profiles/fa-IR.profile').then(m => m.AXIRLocaleProfile),\n };\n }\n}\n\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXLocaleProfileProviderService {\n private providers: AXLocaleProfileProvider[] = inject(AX_LOCALE_PROFILE_PROVIDERS);\n\n private registry = new Map<string, () => Promise<AXLocaleProfile>>();\n private resolvedCache = new Map<string, AXLocaleProfile>();\n private isInitialized = false;\n\n private async init(): Promise<void> {\n if (this.isInitialized) return;\n\n for (const provider of this.providers) {\n const result: AXLocaleProfileProviderResult = await provider.provide();\n\n for (const [localeCode, loaderFn] of Object.entries(result)) {\n if (typeof loaderFn === 'function') {\n this.registry.set(localeCode, async () => {\n const profile = await loaderFn();\n return profile;\n });\n } else {\n console.warn(`[AXLocaleService] Profile for \"${localeCode}\" is not a function. Skipped.`);\n }\n }\n }\n\n this.isInitialized = true;\n }\n\n public async getList(): Promise<AXLocaleProfile[]> {\n await this.init();\n\n const profiles: AXLocaleProfile[] = [];\n\n for (const localeCode of this.registry.keys()) {\n const profile = await this.getByLocale(localeCode);\n if (profile) profiles.push(profile);\n }\n\n return profiles;\n }\n\n public async getByLocale(localeCode: string): Promise<AXLocaleProfile | undefined> {\n await this.init();\n\n // If already loaded, return from cache\n if (this.resolvedCache.has(localeCode)) {\n return this.resolvedCache.get(localeCode);\n }\n\n // Otherwise, try to load it\n const loader = this.registry.get(localeCode);\n if (!loader) {\n console.warn(`[AXLocaleService] No profile loader found for locale: \"${localeCode}\"`);\n return undefined;\n }\n\n const profile = await loader();\n this.resolvedCache.set(localeCode, profile);\n return profile;\n }\n\n public async reload(): Promise<void> {\n this.registry.clear();\n this.resolvedCache.clear();\n this.isInitialized = false;\n await this.init();\n }\n\n public has(localeCode: string): boolean {\n return this.registry.has(localeCode);\n }\n}\n","export interface AXLocaleProfile {\n localeInfo: {\n code: string; // e.g., 'en-US'\n language: string; // e.g., 'en'\n region: string; // e.g., 'US'\n timezone: string; // e.g., 'America/New_York'\n };\n\n calendar: {\n system: 'gregorian' | 'solar-hijri' | string;\n week: {\n startsOn: number; // 0 = Sunday, 1 = Monday\n weekends: number[]; // e.g., [0, 6]\n };\n clock: {\n format24Hour: boolean;\n };\n };\n\n formats: {\n date: FormatPattern;\n time: FormatPattern;\n datetime: FormatPattern;\n numbers: {\n decimalPattern: string; // e.g., '1,000.00'\n currency: {\n code: string; // e.g., 'USD'\n };\n };\n contacts: {\n phone: string; // e.g., '000-000-0000'\n postalCode: string; // e.g., '00000'\n };\n };\n\n units?: {\n temperature: 'celsius' | 'fahrenheit';\n distance: 'kilometers' | 'miles';\n weight?: 'kilograms' | 'pounds';\n volume?: 'liters' | 'gallons';\n speed?: 'km/h' | 'mph';\n area?: 'square-meters' | 'square-feet';\n custom?: Record<string, string>; // Optional: supports domain-specific units\n };\n\n i18nMeta?: {\n fallbackLocales?: string[]; // e.g., ['en']\n supportedLanguages?: string[]; // e.g., ['en', 'fa']\n rtl?: boolean; // true for RTL languages like Arabic, Persian\n };\n}\ninterface FormatPattern {\n short: string;\n medium: string;\n long: string;\n full: string;\n}\n\n\n\nexport enum AXLocaleEvents {\n AXLocaleChanged = 'AX_LOCALE_CHANGED',\n AXLocaleLoaded = 'AX_LOCALE_LOADED',\n //\n AXCalendarChanged = 'AX_CALENDAR_CHANGED',\n //\n AXLanguageChanged = 'AX_LANGUAGE_CHANGED',\n AXLanguageLoaded = 'AX_LANGUAGE_LOADED',\n}\n\n","import { AXLocaleProfile } from \"../locale.types\";\n\nexport const AXUSLocaleProfile: AXLocaleProfile = {\n localeInfo: {\n code: 'en-US',\n language: 'en',\n region: 'US',\n timezone: 'America/New_York',\n },\n calendar: {\n system: 'gregorian',\n week: {\n startsOn: 0, // Sunday\n weekends: [0, 6], // Sunday + Saturday\n },\n clock: {\n format24Hour: false,\n },\n },\n formats: {\n date: {\n short: 'MM/DD/YY',\n medium: 'MMM DD, YYYY',\n long: 'MMMM DD, YYYY',\n full: 'dddd, MMMM DD, YYYY',\n },\n time: {\n short: 'hh:mm A',\n medium: 'hh:mm:ss A',\n long: 'hh:mm:ss A Z',\n full: 'hh:mm:ss A ZZZZ',\n },\n datetime: {\n short: 'MM/DD/YY hh:mm A',\n medium: 'MMM DD, YYYY hh:mm:ss A',\n long: 'MMMM DD, YYYY hh:mm:ss A Z',\n full: 'dddd, MMMM DD, YYYY hh:mm:ss A ZZZZ',\n },\n numbers: {\n decimalPattern: '1,000.00',\n currency: {\n code: 'USD',\n },\n },\n contacts: {\n phone: '(000) 000-0000',\n postalCode: '00000',\n },\n },\n units: {\n temperature: 'fahrenheit',\n distance: 'miles',\n weight: 'pounds',\n volume: 'gallons',\n speed: 'mph',\n area: 'square-feet',\n },\n i18nMeta: {\n rtl: false,\n fallbackLocales: ['en-US'],\n supportedLanguages: ['en-US'],\n },\n};\n","import { AXLocaleProfile } from \"../locale.types\";\n\nexport const AXIRLocaleProfile: AXLocaleProfile = {\n localeInfo: {\n code: 'fa-IR',\n language: 'fa',\n region: 'IR',\n timezone: 'Asia/Tehran',\n },\n calendar: {\n system: 'solar-hijri',\n week: {\n startsOn: 6, // Saturday\n weekends: [5], // Friday\n },\n clock: {\n format24Hour: true,\n },\n },\n formats: {\n date: {\n short: 'YY/MM/DD',\n medium: 'YYYY/MM/DD',\n long: 'dddd، D MMMM YYYY',\n full: 'dddd، D MMMM YYYY',\n },\n time: {\n short: 'HH:mm',\n medium: 'HH:mm:ss',\n long: 'HH:mm:ss Z',\n full: 'HH:mm:ss ZZZZ',\n },\n datetime: {\n short: 'YY/MM/DD HH:mm',\n medium: 'YYYY/MM/DD HH:mm:ss',\n long: 'dddd، D MMMM YYYY HH:mm:ss Z',\n full: 'dddd، D MMMM YYYY HH:mm:ss ZZZZ',\n },\n numbers: {\n decimalPattern: '1٬000٫00',\n currency: {\n code: 'IRR',\n },\n },\n contacts: {\n phone: '09XX XXX XXXX',\n postalCode: 'XXXXX-XXXXX',\n },\n },\n units: {\n temperature: 'celsius',\n distance: 'kilometers',\n weight: 'kilograms',\n volume: 'liters',\n speed: 'km/h',\n area: 'square-meters',\n },\n i18nMeta: {\n rtl: true,\n fallbackLocales: ['en-IR'],\n supportedLanguages: ['fa-IR', 'en-IR'],\n },\n};\n","import { Injectable, inject, signal } from '@angular/core';\nimport { AXLocaleProfileProviderService } from './locale-profile-provider.service';\nimport { AXLocaleProfile } from './locale.types';\n\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { cloneDeep, merge, set } from 'lodash-es';\nimport { AX_LOCALE_CONFIG } from './locale.config';\nimport { AXUSLocaleProfile } from './profiles/en-US.profile';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXLocaleService {\n private provider = inject(AXLocaleProfileProviderService);\n private config = inject(AX_LOCALE_CONFIG);\n\n private _activeProfile = signal<AXLocaleProfile>(AXUSLocaleProfile);\n public activeProfile = this._activeProfile.asReadonly();\n\n public profileChanged$ = toObservable(this._activeProfile);\n\n private originalProfile: AXLocaleProfile = cloneDeep(AXUSLocaleProfile);\n\n public async setProfile(localeCode: string): Promise<void> {\n const profile = await this.provider.getByLocale(localeCode);\n if (profile) {\n this.originalProfile = cloneDeep(profile);\n this._activeProfile.set(cloneDeep(profile));\n } else {\n console.warn(`[AXLocaleService] Locale not found: ${localeCode}`);\n }\n }\n\n /**\n *\n */\n constructor() {\n this.setProfile(this.config.default);\n }\n\n public apply(profile: Partial<AXLocaleProfile>): void;\n public apply(path: string, value: any): void;\n public apply(arg1: any, arg2?: any): void {\n const current = this.activeProfile();\n if (!current) {\n console.warn('[AXLocaleService] No active profile found');\n return;\n }\n\n const updated = cloneDeep(current);\n\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n // Overload: updateProfile('formats.date.full', 'YYYY-MM-DD')\n set(updated, arg1, arg2);\n } else if (typeof arg1 === 'object') {\n // Overload: updateProfile({ formats: { date: { short: '...' } } })\n merge(updated, arg1);\n } else {\n console.warn('[AXLocaleService] Invalid arguments passed to updateProfile()');\n return;\n }\n }\n\n public reset(): void {\n if (this.originalProfile) {\n this._activeProfile.set(cloneDeep(this.originalProfile));\n }\n }\n}\n","import { AXFormatModule } from '@acorex/core/format';\nimport { NgModule } from '@angular/core';\n\n@NgModule({\n imports: [\n AXFormatModule.forChild({\n formatters: [],\n }),\n ],\n})\nexport class AXLocaleModule {\n\n}\n","import { Injectable } from '@angular/core';\nimport { AXFormatter } from '@acorex/core/format';\nimport { AXFormatOptions } from '@acorex/core/format';\n\nexport interface AXCurrencyFormatterOptions extends AXFormatOptions {\n locale?: string;\n currency?: string;\n}\n\ndeclare module '@acorex/core/format' {\n interface AXFormatOptionsMap {\n currency: AXCurrencyFormatterOptions;\n }\n}\n\n// @Injectable()\n// export class AXCurrencyFormatter implements AXFormatter {\n\n// get name(): string {\n// return 'currency';\n// }\n\n// format(value: number, options: AXCurrencyFormatterOptions): string {\n// return value.toLocaleString(options.locale, { style: 'currency', currency: options.currency });\n// }\n// }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,gBAAgB,GAAG,IAAI,cAAc,CAAiB,kBAAkB,EAAE;AACnF,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAK;QACV,OAAO;AACH,YAAA,OAAO,EAAE,OAAO;SACnB;KACJ;AACJ,CAAA;;MCPY,2BAA2B,GAAG,IAAI,cAAc,CACzD,6BAA6B,EAC7B;AACI,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAM,CAAC,IAAI,8BAA8B,EAAE,CAAC;AACxD,CAAA;AAGL;MACa,8BAA8B,CAAA;AACvC,IAAA,MAAM,OAAO,GAAA;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,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,EALnB,OAAA,EAAA,CAAA,cAAc,CAAC,QAAQ,CAAC;AACpB,gBAAA,UAAU,EAAE,EAAE;aACjB,CAAC,CAAA,EAAA,CAAA,CAAA;;2FAGG,cAAc,EAAA,UAAA,EAAA,CAAA;kBAP1B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE;wBACL,cAAc,CAAC,QAAQ,CAAC;AACpB,4BAAA,UAAU,EAAE,EAAE;yBACjB,CAAC;AACL,qBAAA;AACJ,iBAAA;;;ACMD;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;;ACzBA;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-locale.mjs","sources":["../../../../libs/core/locale/src/lib/locale.config.ts","../../../../libs/core/locale/src/lib/locale-profile-provider.service.ts","../../../../libs/core/locale/src/lib/locale.types.ts","../../../../libs/core/locale/src/lib/profiles/en-US.profile.ts","../../../../libs/core/locale/src/lib/profiles/fa-IR.profile.ts","../../../../libs/core/locale/src/lib/locale.service.ts","../../../../libs/core/locale/src/lib/locale.module.ts","../../../../libs/core/locale/src/lib/formatters/currency.formatter.ts","../../../../libs/core/locale/src/acorex-core-locale.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\n\n\n\nexport interface AXLocaleConfig {\n default: string;\n}\n\n\n\nexport const AX_LOCALE_CONFIG = new InjectionToken<AXLocaleConfig>('AX_LOCALE_CONFIG', {\n providedIn: 'root',\n factory: () => {\n return {\n default: 'en-US',\n };\n },\n});\n\n\n\n\n\n\n\n\n\n","import { inject, Injectable, InjectionToken } from \"@angular/core\";\nimport { AXLocaleProfile } from \"./locale.types\";\n\n// Record of locale code → loader function (returns profile or Promise<profile>)\nexport type AXLocaleProfileProviderResult = Record<string, () => Promise<AXLocaleProfile> | AXLocaleProfile>;\n\nexport interface AXLocaleProfileProvider {\n provide(): Promise<AXLocaleProfileProviderResult>;\n}\n\nexport const AX_LOCALE_PROFILE_PROVIDERS = new InjectionToken<AXLocaleProfileProvider[]>(\n 'AX_LOCALE_PROFILE_PROVIDERS',\n {\n providedIn: 'root',\n factory: () => [new AXLocaleProfileProviderDefault()],\n }\n);\n\n// ✅ Lazy-loaded default provider\nexport class AXLocaleProfileProviderDefault implements AXLocaleProfileProvider {\n async provide(): Promise<AXLocaleProfileProviderResult> {\n return {\n 'en-AU': () => import('./profiles/en-AU.profile').then(m => m.AXAURegionalConfig),\n 'en-US': () => import('./profiles/en-US.profile').then(m => m.AXUSLocaleProfile),\n 'fa-IR': () => import('./profiles/fa-IR.profile').then(m => m.AXIRLocaleProfile),\n };\n }\n}\n\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXLocaleProfileProviderService {\n private providers: AXLocaleProfileProvider[] = inject(AX_LOCALE_PROFILE_PROVIDERS);\n\n private registry = new Map<string, () => Promise<AXLocaleProfile>>();\n private resolvedCache = new Map<string, AXLocaleProfile>();\n private isInitialized = false;\n\n private async init(): Promise<void> {\n if (this.isInitialized) return;\n\n for (const provider of this.providers) {\n const result: AXLocaleProfileProviderResult = await provider.provide();\n\n for (const [localeCode, loaderFn] of Object.entries(result)) {\n if (typeof loaderFn === 'function') {\n this.registry.set(localeCode, async () => {\n const profile = await loaderFn();\n return profile;\n });\n } else {\n console.warn(`[AXLocaleService] Profile for \"${localeCode}\" is not a function. Skipped.`);\n }\n }\n }\n\n this.isInitialized = true;\n }\n\n public async getList(): Promise<AXLocaleProfile[]> {\n await this.init();\n\n const profiles: AXLocaleProfile[] = [];\n\n for (const localeCode of this.registry.keys()) {\n const profile = await this.getByLocale(localeCode);\n if (profile) profiles.push(profile);\n }\n\n return profiles;\n }\n\n public async getByLocale(localeCode: string): Promise<AXLocaleProfile | undefined> {\n await this.init();\n\n // If already loaded, return from cache\n if (this.resolvedCache.has(localeCode)) {\n return this.resolvedCache.get(localeCode);\n }\n\n // Otherwise, try to load it\n const loader = this.registry.get(localeCode);\n if (!loader) {\n console.warn(`[AXLocaleService] No profile loader found for locale: \"${localeCode}\"`);\n return undefined;\n }\n\n const profile = await loader();\n this.resolvedCache.set(localeCode, profile);\n return profile;\n }\n\n public async reload(): Promise<void> {\n this.registry.clear();\n this.resolvedCache.clear();\n this.isInitialized = false;\n await this.init();\n }\n\n public has(localeCode: string): boolean {\n return this.registry.has(localeCode);\n }\n}\n","export interface AXLocaleProfile {\n localeInfo: {\n code: string; // e.g., 'en-US'\n language: string; // e.g., 'en'\n region: string; // e.g., 'US'\n timezone: string; // e.g., 'America/New_York'\n };\n\n calendar: {\n system: 'gregorian' | 'solar-hijri' | string;\n week: {\n startsOn: number; // 0 = Sunday, 1 = Monday\n weekends: number[]; // e.g., [0, 6]\n };\n clock: {\n format24Hour: boolean;\n };\n };\n\n formats: {\n date: FormatPattern;\n time: FormatPattern;\n datetime: FormatPattern;\n numbers: {\n decimalPattern: string; // e.g., '1,000.00'\n currency: {\n code: string; // e.g., 'USD'\n };\n };\n contacts: {\n phone: string; // e.g., '000-000-0000'\n postalCode: string; // e.g., '00000'\n };\n };\n\n units: {\n temperature: 'celsius' | 'fahrenheit';\n distance: 'kilometers' | 'miles';\n weight: 'kilograms' | 'pounds';\n volume: 'liters' | 'gallons';\n speed: 'kmh' | 'mph';\n area: 'square-meters' | 'square-feet';\n custom?: Record<string, string>; // Optional: supports domain-specific units\n };\n\n i18nMeta: {\n fallbackLocales?: string[]; // e.g., ['en']\n supportedLanguages?: string[]; // e.g., ['en', 'fa']\n rtl: boolean; // true for RTL languages like Arabic, Persian\n };\n}\ninterface FormatPattern {\n short: string;\n medium: string;\n long: string;\n full: string;\n}\n\n\n\nexport enum AXLocaleEvents {\n AXLocaleChanged = 'AX_LOCALE_CHANGED',\n AXLocaleLoaded = 'AX_LOCALE_LOADED',\n //\n AXCalendarChanged = 'AX_CALENDAR_CHANGED',\n //\n AXLanguageChanged = 'AX_LANGUAGE_CHANGED',\n AXLanguageLoaded = 'AX_LANGUAGE_LOADED',\n}\n\n","import { AXLocaleProfile } from \"../locale.types\";\n\nexport const AXUSLocaleProfile: AXLocaleProfile = {\n localeInfo: {\n code: 'en-US',\n language: 'en',\n region: 'US',\n timezone: 'America/New_York',\n },\n calendar: {\n system: 'gregorian',\n week: {\n startsOn: 0, // Sunday\n weekends: [0, 6], // Sunday + Saturday\n },\n clock: {\n format24Hour: false,\n },\n },\n formats: {\n date: {\n short: 'MM/DD/YY',\n medium: 'MMM DD, YYYY',\n long: 'MMMM DD, YYYY',\n full: 'dddd, MMMM DD, YYYY',\n },\n time: {\n short: 'hh:mm A',\n medium: 'hh:mm:ss A',\n long: 'hh:mm:ss A Z',\n full: 'hh:mm:ss A ZZZZ',\n },\n datetime: {\n short: 'MM/DD/YY hh:mm A',\n medium: 'MMM DD, YYYY hh:mm:ss A',\n long: 'MMMM DD, YYYY hh:mm:ss A Z',\n full: 'dddd, MMMM DD, YYYY hh:mm:ss A ZZZZ',\n },\n numbers: {\n decimalPattern: '1,000.00',\n currency: {\n code: 'USD',\n },\n },\n contacts: {\n phone: '(000) 000-0000',\n postalCode: '00000',\n },\n },\n units: {\n temperature: 'fahrenheit',\n distance: 'miles',\n weight: 'pounds',\n volume: 'gallons',\n speed: 'mph',\n area: 'square-feet',\n },\n i18nMeta: {\n rtl: false,\n fallbackLocales: ['en-US'],\n supportedLanguages: ['en-US'],\n },\n};\n","import { AXLocaleProfile } from \"../locale.types\";\n\nexport const AXIRLocaleProfile: AXLocaleProfile = {\n localeInfo: {\n code: 'fa-IR',\n language: 'fa',\n region: 'IR',\n timezone: 'Asia/Tehran',\n },\n calendar: {\n system: 'solar-hijri',\n week: {\n startsOn: 6, // Saturday\n weekends: [5], // Friday\n },\n clock: {\n format24Hour: true,\n },\n },\n formats: {\n date: {\n short: 'YY/MM/DD',\n medium: 'YYYY/MM/DD',\n long: 'dddd، D MMMM YYYY',\n full: 'dddd، D MMMM YYYY',\n },\n time: {\n short: 'HH:mm',\n medium: 'HH:mm:ss',\n long: 'HH:mm:ss Z',\n full: 'HH:mm:ss ZZZZ',\n },\n datetime: {\n short: 'YY/MM/DD HH:mm',\n medium: 'YYYY/MM/DD HH:mm:ss',\n long: 'dddd، D MMMM YYYY HH:mm:ss Z',\n full: 'dddd، D MMMM YYYY HH:mm:ss ZZZZ',\n },\n numbers: {\n decimalPattern: '1٬000٫00',\n currency: {\n code: 'IRR',\n },\n },\n contacts: {\n phone: '09XX XXX XXXX',\n postalCode: 'XXXXX-XXXXX',\n },\n },\n units: {\n temperature: 'celsius',\n distance: 'kilometers',\n weight: 'kilograms',\n volume: 'liters',\n speed: 'kmh',\n area: 'square-meters',\n },\n i18nMeta: {\n rtl: true,\n fallbackLocales: ['en-IR'],\n supportedLanguages: ['fa-IR', 'en-IR'],\n },\n};\n","import { Injectable, inject, signal } from '@angular/core';\nimport { AXLocaleProfileProviderService } from './locale-profile-provider.service';\nimport { AXLocaleProfile } from './locale.types';\n\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { cloneDeep, merge, set } from 'lodash-es';\nimport { AX_LOCALE_CONFIG } from './locale.config';\nimport { AXUSLocaleProfile } from './profiles/en-US.profile';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXLocaleService {\n private provider = inject(AXLocaleProfileProviderService);\n private config = inject(AX_LOCALE_CONFIG);\n\n private _activeProfile = signal<AXLocaleProfile>(AXUSLocaleProfile);\n public activeProfile = this._activeProfile.asReadonly();\n\n public profileChanged$ = toObservable(this._activeProfile);\n\n private originalProfile: AXLocaleProfile = cloneDeep(AXUSLocaleProfile);\n\n public async setProfile(localeCode: string): Promise<void> {\n const profile = await this.provider.getByLocale(localeCode);\n if (profile) {\n this.originalProfile = cloneDeep(profile);\n this._activeProfile.set(cloneDeep(profile));\n } else {\n console.warn(`[AXLocaleService] Locale not found: ${localeCode}`);\n }\n }\n\n /**\n *\n */\n constructor() {\n this.setProfile(this.config.default);\n }\n\n public apply(profile: Partial<AXLocaleProfile>): void;\n public apply(path: string, value: any): void;\n public apply(arg1: any, arg2?: any): void {\n const current = this.activeProfile();\n if (!current) {\n console.warn('[AXLocaleService] No active profile found');\n return;\n }\n\n const updated = cloneDeep(current);\n\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n // Overload: updateProfile('formats.date.full', 'YYYY-MM-DD')\n set(updated, arg1, arg2);\n } else if (typeof arg1 === 'object') {\n // Overload: updateProfile({ formats: { date: { short: '...' } } })\n merge(updated, arg1);\n } else {\n console.warn('[AXLocaleService] Invalid arguments passed to updateProfile()');\n return;\n }\n }\n\n public reset(): void {\n if (this.originalProfile) {\n this._activeProfile.set(cloneDeep(this.originalProfile));\n }\n }\n}\n","import { AXFormatModule } from '@acorex/core/format';\nimport { NgModule } from '@angular/core';\n\n@NgModule({\n imports: [\n AXFormatModule.forChild({\n formatters: [],\n }),\n ],\n})\nexport class AXLocaleModule {\n\n}\n","import { Injectable } from '@angular/core';\nimport { AXFormatter } from '@acorex/core/format';\nimport { AXFormatOptions } from '@acorex/core/format';\n\nexport interface AXCurrencyFormatterOptions extends AXFormatOptions {\n locale?: string;\n currency?: string;\n}\n\ndeclare module '@acorex/core/format' {\n interface AXFormatOptionsMap {\n currency: AXCurrencyFormatterOptions;\n }\n}\n\n// @Injectable()\n// export class AXCurrencyFormatter implements AXFormatter {\n\n// get name(): string {\n// return 'currency';\n// }\n\n// format(value: number, options: AXCurrencyFormatterOptions): string {\n// return value.toLocaleString(options.locale, { style: 'currency', currency: options.currency });\n// }\n// }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAUa,gBAAgB,GAAG,IAAI,cAAc,CAAiB,kBAAkB,EAAE;AACnF,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAK;QACV,OAAO;AACH,YAAA,OAAO,EAAE,OAAO;SACnB;KACJ;AACJ,CAAA;;MCPY,2BAA2B,GAAG,IAAI,cAAc,CACzD,6BAA6B,EAC7B;AACI,IAAA,UAAU,EAA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