@acorex/core 19.15.0-next.2 → 19.15.0-next.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { AXFormatOptions, AXFormatter } from '@acorex/core/format';
2
+ import { AXTranslationService } from '@acorex/core/translation';
2
3
  import * as i0 from "@angular/core";
3
4
  export interface AXTimeDurationFormatterOptions extends AXFormatOptions {
4
5
  format: string;
@@ -12,7 +13,8 @@ type AXTimeDurationUnit = 'YEAR' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE'
12
13
  export declare class AXTimeDurationFormatter implements AXFormatter {
13
14
  get name(): string;
14
15
  format(value: number, options?: AXTimeDurationFormatterOptions): string;
15
- millisecondsToMask(milliseconds: number, start?: AXTimeDurationUnit, end?: string, lang?: 'fa' | 'en'): string;
16
+ translationService: AXTranslationService;
17
+ millisecondsToMask(ms: number, startUnit?: AXTimeDurationUnit, endUnit?: AXTimeDurationUnit): Promise<string>;
16
18
  static ɵfac: i0.ɵɵFactoryDeclaration<AXTimeDurationFormatter, never>;
17
19
  static ɵprov: i0.ɵɵInjectableDeclaration<AXTimeDurationFormatter>;
18
20
  }
@@ -20,10 +20,10 @@ class AXComponentService {
20
20
  async createFromTemplate(content) {
21
21
  return this.getRootViewContainerRef().createEmbeddedView(content);
22
22
  }
23
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXComponentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
24
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXComponentService, providedIn: 'root' }); }
23
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXComponentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
24
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXComponentService, providedIn: 'root' }); }
25
25
  }
26
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXComponentService, decorators: [{
26
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXComponentService, decorators: [{
27
27
  type: Injectable,
28
28
  args: [{
29
29
  providedIn: 'root',
@@ -23,10 +23,10 @@ class AXConfigService {
23
23
  const v2 = this.injector.get(providerToken);
24
24
  return get(v2, parts[parts.length - 1], defaultValue);
25
25
  }
26
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXConfigService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
27
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXConfigService, providedIn: 'root' }); }
26
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXConfigService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
27
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXConfigService, providedIn: 'root' }); }
28
28
  }
29
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXConfigService, decorators: [{
29
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXConfigService, decorators: [{
30
30
  type: Injectable,
31
31
  args: [{ providedIn: 'root' }]
32
32
  }], ctorParameters: () => [{ type: i0.Injector }] });
@@ -8,7 +8,7 @@ import { BehaviorSubject, Subject } from 'rxjs';
8
8
  import { AX_GLOBAL_CONFIG } from '@acorex/core/config';
9
9
  import { defaults, orderBy, set, isNil } from 'lodash-es';
10
10
  import { isBrowser } from '@acorex/core/platform';
11
- import { translateSync } from '@acorex/core/translation';
11
+ import { translateSync, AXTranslationService } from '@acorex/core/translation';
12
12
 
13
13
  class AXCalendar {
14
14
  /**
@@ -1192,10 +1192,10 @@ class AXCalendarService {
1192
1192
  calendar: calendar.name(),
1193
1193
  });
1194
1194
  }
1195
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXCalendarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1196
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXCalendarService, providedIn: 'root' }); }
1195
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXCalendarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1196
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXCalendarService, providedIn: 'root' }); }
1197
1197
  }
1198
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXCalendarService, decorators: [{
1198
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXCalendarService, decorators: [{
1199
1199
  type: Injectable,
1200
1200
  args: [{ providedIn: 'root' }]
1201
1201
  }], ctorParameters: () => [] });
@@ -1219,10 +1219,10 @@ class AXDateTimePipe {
1219
1219
  const val = this._calendarService.convert(value, calendar.name());
1220
1220
  return this.formatService.format(val, 'datetime', format);
1221
1221
  }
1222
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1223
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimePipe, isStandalone: true, name: "axDate" }); }
1222
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1223
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimePipe, isStandalone: true, name: "axDate" }); }
1224
1224
  }
1225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimePipe, decorators: [{
1225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimePipe, decorators: [{
1226
1226
  type: Pipe,
1227
1227
  args: [{ name: 'axDate' }]
1228
1228
  }] });
@@ -1267,10 +1267,10 @@ class AXDateFormatter {
1267
1267
  .convert(value, effectiveOptions.calendar)
1268
1268
  .format(format, { locale: effectiveOptions.locale });
1269
1269
  }
1270
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1271
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateFormatter }); }
1270
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1271
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateFormatter }); }
1272
1272
  }
1273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateFormatter, decorators: [{
1273
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateFormatter, decorators: [{
1274
1274
  type: Injectable
1275
1275
  }] });
1276
1276
 
@@ -1324,14 +1324,17 @@ class AXDateTimeFormatter {
1324
1324
  .convert(value, effectiveOptions.calendar)
1325
1325
  .format(format, { locale: effectiveOptions.locale });
1326
1326
  }
1327
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1328
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeFormatter }); }
1327
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1328
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeFormatter }); }
1329
1329
  }
1330
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeFormatter, decorators: [{
1330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeFormatter, decorators: [{
1331
1331
  type: Injectable
1332
1332
  }] });
1333
1333
 
1334
1334
  class AXTimeDurationFormatter {
1335
+ constructor() {
1336
+ this.translationService = inject(AXTranslationService);
1337
+ }
1335
1338
  get name() {
1336
1339
  return 'time-duration';
1337
1340
  }
@@ -1374,45 +1377,62 @@ class AXTimeDurationFormatter {
1374
1377
  // Join the parts according to the format
1375
1378
  return formattedTime.join(format.includes('ms') || format.includes('MS') ? ':' : ':');
1376
1379
  }
1377
- millisecondsToMask(milliseconds, start = 'YEAR', end = 'MILLISECOND', lang = 'en') {
1378
- if (milliseconds <= 0)
1380
+ async millisecondsToMask(ms, startUnit = 'YEAR', endUnit = 'MILLISECOND') {
1381
+ if (ms <= 0)
1379
1382
  return '';
1380
- const year = lang === 'fa' ? 'سال' : 'YEAR';
1381
- const month = lang === 'fa' ? 'ماه' : 'MONTH';
1382
- const week = lang === 'fa' ? 'هفته' : 'WEEK';
1383
- const day = lang === 'fa' ? 'روز' : 'DAY';
1384
- const hour = lang === 'fa' ? 'ساعت' : 'HOUR';
1385
- const minute = lang === 'fa' ? 'دقیقه' : 'MINUTE';
1386
- const second = lang === 'fa' ? 'ثانیه' : 'SECOND';
1387
- const millisecond = lang === 'fa' ? 'میلی ثانیه' : 'MILLISECOND';
1388
- const allUnits = [
1389
- { name: year, value: 31536000000 },
1390
- { name: month, value: 2592000000 },
1391
- { name: week, value: 604800000 },
1392
- { name: day, value: 86400000 },
1393
- { name: hour, value: 3600000 },
1394
- { name: minute, value: 60000 },
1395
- { name: second, value: 1000 },
1396
- { name: millisecond, value: 1 },
1383
+ const translations = await Promise.all([
1384
+ this.translationService.translateAsync('dateTime.year'),
1385
+ this.translationService.translateAsync('dateTime.month'),
1386
+ this.translationService.translateAsync('dateTime.week'),
1387
+ this.translationService.translateAsync('dateTime.day'),
1388
+ this.translationService.translateAsync('dateTime.hour'),
1389
+ this.translationService.translateAsync('dateTime.minute'),
1390
+ this.translationService.translateAsync('dateTime.second'),
1391
+ this.translationService.translateAsync('dateTime.millisecond'),
1392
+ ]);
1393
+ const units = [
1394
+ { key: 'YEAR', label: translations[0].toLocaleUpperCase(), value: 1000 * 60 * 60 * 24 * 365 },
1395
+ { key: 'MONTH', label: translations[1].toLocaleUpperCase(), value: 1000 * 60 * 60 * 24 * 30 },
1396
+ { key: 'WEEK', label: translations[2].toLocaleUpperCase(), value: 1000 * 60 * 60 * 24 * 7 },
1397
+ { key: 'DAY', label: translations[3].toLocaleUpperCase(), value: 1000 * 60 * 60 * 24 },
1398
+ { key: 'HOUR', label: translations[4].toLocaleUpperCase(), value: 1000 * 60 * 60 },
1399
+ { key: 'MINUTE', label: translations[5].toLocaleUpperCase(), value: 1000 * 60 },
1400
+ { key: 'SECOND', label: translations[6].toLocaleUpperCase(), value: 1000 },
1401
+ { key: 'MILLISECOND', label: translations[7].toLocaleUpperCase(), value: 1 },
1397
1402
  ];
1398
- const startIndex = allUnits.findIndex((unit) => unit.name === start);
1399
- const endIndex = allUnits.findIndex((unit) => unit.name === end);
1400
- const units = allUnits.slice(startIndex, endIndex + 1);
1401
- let remaining = milliseconds;
1402
- const parts = [];
1403
- for (const unit of units) {
1404
- if (remaining >= unit.value) {
1405
- const value = Math.floor(remaining / unit.value);
1406
- remaining = remaining % unit.value;
1407
- parts.push(`${value.toString().padStart(2, '0')}(${unit.name})`);
1408
- }
1403
+ const startIndex = units.findIndex((u) => u.key === startUnit.toUpperCase());
1404
+ const endIndex = units.findIndex((u) => u.key === endUnit.toUpperCase());
1405
+ if (startIndex === -1 || endIndex === -1 || startIndex > endIndex) {
1406
+ throw new Error('Invalid time unit range');
1409
1407
  }
1410
- return parts.join(':');
1408
+ const limitedUnits = units.slice(startIndex, endIndex + 1);
1409
+ const result = limitedUnits.map((unit) => {
1410
+ const count = Math.floor(ms / unit.value);
1411
+ ms %= unit.value;
1412
+ // Special handling for milliseconds (3 digits)
1413
+ if (unit.key === 'MILLISECOND') {
1414
+ if (count < 10) {
1415
+ return `00${count} (${unit.label})`;
1416
+ }
1417
+ else if (count < 100) {
1418
+ return `0${count} (${unit.label})`;
1419
+ }
1420
+ else {
1421
+ return `${count} (${unit.label})`;
1422
+ }
1423
+ }
1424
+ else {
1425
+ // For other units, pad with one zero if less than 10
1426
+ const paddedCount = count < 10 ? `0${count}` : `${count}`;
1427
+ return `${paddedCount} (${unit.label})`;
1428
+ }
1429
+ });
1430
+ return result.join(' : ');
1411
1431
  }
1412
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeDurationFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1413
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeDurationFormatter }); }
1432
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeDurationFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1433
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeDurationFormatter }); }
1414
1434
  }
1415
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeDurationFormatter, decorators: [{
1435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeDurationFormatter, decorators: [{
1416
1436
  type: Injectable
1417
1437
  }] });
1418
1438
 
@@ -1456,10 +1476,10 @@ class AXTimeFormatter {
1456
1476
  .convert(value, effectiveOptions.calendar)
1457
1477
  .format(format, { locale: effectiveOptions.locale });
1458
1478
  }
1459
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1460
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeFormatter }); }
1479
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1480
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeFormatter }); }
1461
1481
  }
1462
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeFormatter, decorators: [{
1482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeFormatter, decorators: [{
1463
1483
  type: Injectable
1464
1484
  }] });
1465
1485
 
@@ -1543,21 +1563,21 @@ class AXTimeLeftFormatter {
1543
1563
  return 'Invalid format';
1544
1564
  }
1545
1565
  }
1546
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeLeftFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1547
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeLeftFormatter }); }
1566
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeLeftFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1567
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeLeftFormatter }); }
1548
1568
  }
1549
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXTimeLeftFormatter, decorators: [{
1569
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXTimeLeftFormatter, decorators: [{
1550
1570
  type: Injectable
1551
1571
  }] });
1552
1572
 
1553
1573
  class AXDateTimeModule {
1554
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1555
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeModule, imports: [i1.AXFormatModule, AXDateTimePipe], exports: [AXDateTimePipe] }); }
1556
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeModule, imports: [AXFormatModule.forChild({
1574
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1575
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeModule, imports: [i1.AXFormatModule, AXDateTimePipe], exports: [AXDateTimePipe] }); }
1576
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeModule, imports: [AXFormatModule.forChild({
1557
1577
  formatters: [AXDateTimeFormatter, AXDateFormatter, AXTimeFormatter, AXTimeLeftFormatter, AXTimeDurationFormatter],
1558
1578
  })] }); }
1559
1579
  }
1560
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDateTimeModule, decorators: [{
1580
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: AXDateTimeModule, decorators: [{
1561
1581
  type: NgModule,
1562
1582
  args: [{
1563
1583
  imports: [