@onemrvapublic/design-system 18.2.15 → 18.2.16-develop.10
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/esm2022/mat-paginator/src/onemrva-mat-paginator.component.mjs +6 -2
- package/esm2022/shared/index.mjs +3 -2
- package/esm2022/shared/src/lib/adapters/index.mjs +3 -0
- package/esm2022/shared/src/lib/adapters/luxon.date.adapter.mjs +253 -0
- package/esm2022/shared/src/lib/adapters/luxon.utils.mjs +23 -0
- package/esm2022/shared/src/lib/adapters/native.date.adapter.mjs +66 -0
- package/esm2022/shared/src/lib/constants/date.format.mjs +7 -5
- package/esm2022/shared/src/lib/providers/index.mjs +5 -0
- package/esm2022/shared/src/lib/providers/onemrva.date.luxon.provider.mjs +16 -0
- package/esm2022/shared/src/lib/providers/onemrva.date.luxon.year.month.provider.mjs +16 -0
- package/esm2022/shared/src/lib/providers/onemrva.date.native.provider.mjs +16 -0
- package/esm2022/shared/src/lib/providers/onemrva.date.native.year.month.provider.mjs +16 -0
- package/fesm2022/onemrvapublic-design-system-mat-paginator.mjs +5 -1
- package/fesm2022/onemrvapublic-design-system-mat-paginator.mjs.map +1 -1
- package/fesm2022/onemrvapublic-design-system-shared.mjs +372 -153
- package/fesm2022/onemrvapublic-design-system-shared.mjs.map +1 -1
- package/mat-paginator/src/onemrva-mat-paginator.component.d.ts +1 -0
- package/package.json +1 -1
- package/shared/index.d.ts +2 -1
- package/shared/src/lib/adapters/index.d.ts +2 -0
- package/shared/src/lib/adapters/luxon.date.adapter.d.ts +50 -0
- package/shared/src/lib/adapters/luxon.utils.d.ts +26 -0
- package/shared/src/lib/adapters/native.date.adapter.d.ts +17 -0
- package/shared/src/lib/providers/index.d.ts +4 -0
- package/shared/src/lib/providers/onemrva.date.luxon.provider.d.ts +2 -0
- package/shared/src/lib/providers/onemrva.date.luxon.year.month.provider.d.ts +2 -0
- package/shared/src/lib/providers/onemrva.date.native.provider.d.ts +2 -0
- package/shared/src/lib/providers/onemrva.date.native.year.month.provider.d.ts +2 -0
- package/esm2022/shared/src/lib/modules/index.mjs +0 -5
- package/esm2022/shared/src/lib/modules/shared.datepicker.luxon.module.mjs +0 -46
- package/esm2022/shared/src/lib/modules/shared.datepicker.luxon.year.month.module.mjs +0 -46
- package/esm2022/shared/src/lib/modules/shared.datepicker.native.module.mjs +0 -51
- package/esm2022/shared/src/lib/modules/shared.datepicker.native.year.month.module.mjs +0 -51
- package/shared/src/lib/modules/index.d.ts +0 -4
- package/shared/src/lib/modules/shared.datepicker.luxon.module.d.ts +0 -12
- package/shared/src/lib/modules/shared.datepicker.luxon.year.month.module.d.ts +0 -12
- package/shared/src/lib/modules/shared.datepicker.native.module.d.ts +0 -12
- package/shared/src/lib/modules/shared.datepicker.native.year.month.module.d.ts +0 -12
|
@@ -8,19 +8,17 @@ import * as i1 from '@angular/cdk/clipboard';
|
|
|
8
8
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
9
9
|
import * as i1$1 from '@angular/cdk/platform';
|
|
10
10
|
import { _isTestEnvironment } from '@angular/cdk/platform';
|
|
11
|
-
import { Subject, merge, NEVER, take, tap, catchError, startWith, switchMap, shareReplay, filter, finalize, of, forkJoin, ReplaySubject, skip, distinctUntilChanged, map as map$1, combineLatestWith, from } from 'rxjs';
|
|
11
|
+
import { Subject, merge, NEVER, take, tap, catchError, startWith, switchMap, shareReplay, filter, finalize, of, forkJoin, ReplaySubject, skip, distinctUntilChanged, map as map$1, combineLatestWith, from, takeUntil } from 'rxjs';
|
|
12
12
|
import { OnemrvaMatColor } from '@onemrvapublic/design-system/utils';
|
|
13
13
|
import * as i1$2 from '@angular/cdk/layout';
|
|
14
14
|
import { catchError as catchError$1, map, startWith as startWith$1 } from 'rxjs/operators';
|
|
15
15
|
import * as i1$3 from '@angular/common/http';
|
|
16
16
|
import { __decorate } from 'tslib';
|
|
17
17
|
import * as i1$4 from '@ngx-translate/core';
|
|
18
|
-
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
|
19
18
|
import { countrySpecs, validateIBAN, electronicFormatIBAN, ValidationErrorsIBAN } from 'ibantools';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
19
|
+
import { NativeDateAdapter, DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS } from '@angular/material/core';
|
|
20
|
+
import { DateTime, Info } from 'luxon';
|
|
22
21
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
23
|
-
import { provideLuxonDateAdapter } from '@angular/material-luxon-adapter';
|
|
24
22
|
|
|
25
23
|
class ClipboardIconComponent {
|
|
26
24
|
constructor(_elementRef, clipboardService) {
|
|
@@ -49,6 +47,7 @@ const NISS_MASK = '000000/000-00';
|
|
|
49
47
|
|
|
50
48
|
const parseNativeDateFormats = [
|
|
51
49
|
'ddMMyyyy',
|
|
50
|
+
'dd/MM/yyyy',
|
|
52
51
|
'd/M/yyyy',
|
|
53
52
|
'dd/M/yyyy',
|
|
54
53
|
'd/MM/yyyy',
|
|
@@ -82,6 +81,7 @@ const parseLuxonYearMonthFormats = [
|
|
|
82
81
|
];
|
|
83
82
|
const parseLuxonDateFormat = [
|
|
84
83
|
'ddLLyyyy',
|
|
84
|
+
'd/LL/yyyy',
|
|
85
85
|
'd/L/yyyy',
|
|
86
86
|
'dd/L/yyyy',
|
|
87
87
|
'd/LL/yyyy',
|
|
@@ -101,8 +101,8 @@ const ONEMRVA_MAT_NATIVE_DATE_FORMAT = {
|
|
|
101
101
|
},
|
|
102
102
|
display: {
|
|
103
103
|
dateInput: 'dd/MM/yyyy',
|
|
104
|
-
monthYearLabel: '
|
|
105
|
-
dateA11yLabel: '
|
|
104
|
+
monthYearLabel: 'LL / yyyy',
|
|
105
|
+
dateA11yLabel: 'LL',
|
|
106
106
|
monthYearA11yLabel: 'MMMM yyyy',
|
|
107
107
|
},
|
|
108
108
|
};
|
|
@@ -112,8 +112,8 @@ const ONEMRVA_MAT_NATIVE_YEAR_MONTH_FORMAT = {
|
|
|
112
112
|
},
|
|
113
113
|
display: {
|
|
114
114
|
dateInput: 'dd/MM/yyyy',
|
|
115
|
-
monthYearLabel: '
|
|
116
|
-
dateA11yLabel: '
|
|
115
|
+
monthYearLabel: 'LL / yyyy',
|
|
116
|
+
dateA11yLabel: 'LL',
|
|
117
117
|
monthYearA11yLabel: 'MMM yyyy',
|
|
118
118
|
},
|
|
119
119
|
};
|
|
@@ -1336,166 +1336,385 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImpor
|
|
|
1336
1336
|
}]
|
|
1337
1337
|
}] });
|
|
1338
1338
|
|
|
1339
|
-
class
|
|
1339
|
+
class OnemrvaNativeDateAdapter extends NativeDateAdapter {
|
|
1340
1340
|
constructor(translateService) {
|
|
1341
|
-
|
|
1342
|
-
translateService
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1341
|
+
super();
|
|
1342
|
+
this.translateService = translateService;
|
|
1343
|
+
this.destroyNotifier$ = new Subject();
|
|
1344
|
+
this.localeChanges = new Subject();
|
|
1345
|
+
this.setLocale(this.translateService.currentLang);
|
|
1346
|
+
this.localeChanges.next(this);
|
|
1347
|
+
if (this.translateService !== undefined) {
|
|
1348
|
+
this.translateService.onLangChange
|
|
1349
|
+
.pipe(takeUntil(this.destroyNotifier$))
|
|
1350
|
+
.subscribe(({ lang }) => {
|
|
1351
|
+
this.setLocale(lang);
|
|
1352
|
+
this.localeChanges.next(this);
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
format(date, formats) {
|
|
1357
|
+
const dt = DateTime.fromJSDate(date);
|
|
1358
|
+
return dt.toFormat(formats);
|
|
1359
|
+
}
|
|
1360
|
+
parse(value) {
|
|
1361
|
+
const formats = ONEMRVA_MAT_NATIVE_DATE_FORMAT;
|
|
1362
|
+
if (value && typeof value === 'string') {
|
|
1363
|
+
value = value.replace(/\D/g, '/');
|
|
1364
|
+
}
|
|
1365
|
+
if (value === null || value === '') {
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1368
|
+
const dt = DateTime.fromFormat(value, formats.display.dateInput, {
|
|
1369
|
+
locale: this.locale,
|
|
1346
1370
|
});
|
|
1371
|
+
if (dt.isValid) {
|
|
1372
|
+
return dt.toJSDate();
|
|
1373
|
+
}
|
|
1374
|
+
for (const format of formats.parse.dateInput) {
|
|
1375
|
+
const parsed = DateTime.fromFormat(value, format, {
|
|
1376
|
+
locale: this.locale,
|
|
1377
|
+
});
|
|
1378
|
+
if (parsed.isValid) {
|
|
1379
|
+
return parsed.toJSDate();
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return this.invalid();
|
|
1347
1383
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
], imports: [MatDatepickerModule, TranslateModule, MatNativeDateModule] }); }
|
|
1384
|
+
getFirstDayOfWeek() {
|
|
1385
|
+
return 1;
|
|
1386
|
+
}
|
|
1387
|
+
ngOnDestroy() {
|
|
1388
|
+
this.destroyNotifier$.next();
|
|
1389
|
+
this.destroyNotifier$.complete();
|
|
1390
|
+
}
|
|
1391
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaNativeDateAdapter, deps: [{ token: i1$4.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1392
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaNativeDateAdapter }); }
|
|
1358
1393
|
}
|
|
1359
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type:
|
|
1360
|
-
type:
|
|
1361
|
-
args: [{
|
|
1362
|
-
declarations: [],
|
|
1363
|
-
imports: [MatDatepickerModule, TranslateModule, MatNativeDateModule],
|
|
1364
|
-
exports: [],
|
|
1365
|
-
providers: [
|
|
1366
|
-
{
|
|
1367
|
-
provide: MAT_DATE_LOCALE,
|
|
1368
|
-
useFactory: (translateService) => translateService.currentLang,
|
|
1369
|
-
deps: [TranslateService],
|
|
1370
|
-
},
|
|
1371
|
-
provideLuxonDateAdapter(ONEMRVA_MAT_LUXON_DATE_FORMATS),
|
|
1372
|
-
],
|
|
1373
|
-
}]
|
|
1394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaNativeDateAdapter, decorators: [{
|
|
1395
|
+
type: Injectable
|
|
1374
1396
|
}], ctorParameters: () => [{ type: i1$4.TranslateService }] });
|
|
1375
1397
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1398
|
+
/** InjectionToken for LuxonDateAdapter to configure options. */
|
|
1399
|
+
const MAT_LUXON_DATE_ADAPTER_OPTIONS = new InjectionToken('MAT_LUXON_DATE_ADAPTER_OPTIONS', {
|
|
1400
|
+
providedIn: 'root',
|
|
1401
|
+
factory: MAT_LUXON_DATE_ADAPTER_OPTIONS_FACTORY,
|
|
1402
|
+
});
|
|
1403
|
+
/** @docs-private */
|
|
1404
|
+
function MAT_LUXON_DATE_ADAPTER_OPTIONS_FACTORY() {
|
|
1405
|
+
return {
|
|
1406
|
+
useUtc: false,
|
|
1407
|
+
firstDayOfWeek: 0,
|
|
1408
|
+
defaultOutputCalendar: 'gregory',
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
/** Creates an array and fills it with values. */
|
|
1412
|
+
function luxonRange(length, valueFunction) {
|
|
1413
|
+
const valuesArray = Array(length);
|
|
1414
|
+
for (let i = 0; i < length; i++) {
|
|
1415
|
+
valuesArray[i] = valueFunction(i);
|
|
1384
1416
|
}
|
|
1385
|
-
|
|
1386
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaDatepickerSharedModule, imports: [MatDatepickerModule, TranslateModule, MatNativeDateModule] }); }
|
|
1387
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaDatepickerSharedModule, providers: [
|
|
1388
|
-
{
|
|
1389
|
-
provide: MAT_DATE_LOCALE,
|
|
1390
|
-
useFactory: (translateService) => translateService.currentLang,
|
|
1391
|
-
deps: [TranslateService],
|
|
1392
|
-
},
|
|
1393
|
-
{
|
|
1394
|
-
provide: MAT_DATE_FORMATS,
|
|
1395
|
-
useValue: ONEMRVA_MAT_NATIVE_DATE_FORMAT,
|
|
1396
|
-
},
|
|
1397
|
-
], imports: [MatDatepickerModule, TranslateModule, MatNativeDateModule] }); }
|
|
1417
|
+
return valuesArray;
|
|
1398
1418
|
}
|
|
1399
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaDatepickerSharedModule, decorators: [{
|
|
1400
|
-
type: NgModule,
|
|
1401
|
-
args: [{
|
|
1402
|
-
declarations: [],
|
|
1403
|
-
imports: [MatDatepickerModule, TranslateModule, MatNativeDateModule],
|
|
1404
|
-
exports: [],
|
|
1405
|
-
providers: [
|
|
1406
|
-
{
|
|
1407
|
-
provide: MAT_DATE_LOCALE,
|
|
1408
|
-
useFactory: (translateService) => translateService.currentLang,
|
|
1409
|
-
deps: [TranslateService],
|
|
1410
|
-
},
|
|
1411
|
-
{
|
|
1412
|
-
provide: MAT_DATE_FORMATS,
|
|
1413
|
-
useValue: ONEMRVA_MAT_NATIVE_DATE_FORMAT,
|
|
1414
|
-
},
|
|
1415
|
-
],
|
|
1416
|
-
}]
|
|
1417
|
-
}], ctorParameters: () => [{ type: i1$4.TranslateService }] });
|
|
1418
1419
|
|
|
1419
|
-
|
|
1420
|
+
/**
|
|
1421
|
+
* @license
|
|
1422
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1423
|
+
*
|
|
1424
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1425
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
1426
|
+
*/
|
|
1427
|
+
/** Adapts Luxon Dates for use with Angular Material. */
|
|
1428
|
+
class OnemrvaLuxonDateAdapter extends DateAdapter {
|
|
1420
1429
|
constructor(translateService) {
|
|
1421
|
-
|
|
1422
|
-
translateService
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1430
|
+
super();
|
|
1431
|
+
this.translateService = translateService;
|
|
1432
|
+
const dateLocale = inject(MAT_DATE_LOCALE, { optional: true });
|
|
1433
|
+
const options = inject(MAT_LUXON_DATE_ADAPTER_OPTIONS, {
|
|
1434
|
+
optional: true,
|
|
1426
1435
|
});
|
|
1436
|
+
this._useUTC = !!options?.useUtc;
|
|
1437
|
+
this._firstDayOfWeek = options?.firstDayOfWeek || 0;
|
|
1438
|
+
this._defaultOutputCalendar = options?.defaultOutputCalendar || 'gregory';
|
|
1439
|
+
this.setLocale(dateLocale || DateTime.local().locale);
|
|
1440
|
+
this.setLocale(this.translateService.currentLang);
|
|
1441
|
+
if (this.translateService !== undefined) {
|
|
1442
|
+
this.translateService.onLangChange
|
|
1443
|
+
.pipe(takeUntilDestroyed())
|
|
1444
|
+
.subscribe(({ lang }) => {
|
|
1445
|
+
this.setLocale(lang);
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1427
1448
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1449
|
+
getYear(date) {
|
|
1450
|
+
return date.year;
|
|
1451
|
+
}
|
|
1452
|
+
getMonth(date) {
|
|
1453
|
+
// Luxon works with 1-indexed months whereas our code expects 0-indexed.
|
|
1454
|
+
return date.month - 1;
|
|
1455
|
+
}
|
|
1456
|
+
getDate(date) {
|
|
1457
|
+
return date.day;
|
|
1458
|
+
}
|
|
1459
|
+
getDayOfWeek(date) {
|
|
1460
|
+
return date.weekday;
|
|
1461
|
+
}
|
|
1462
|
+
getMonthNames(style) {
|
|
1463
|
+
// Adding outputCalendar option, because LuxonInfo doesn't get effected by LuxonSettings
|
|
1464
|
+
return Info.months(style, {
|
|
1465
|
+
locale: this.locale,
|
|
1466
|
+
outputCalendar: this._defaultOutputCalendar,
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
getDateNames() {
|
|
1470
|
+
// At the time of writing, Luxon doesn't offer similar
|
|
1471
|
+
// functionality so we have to fall back to the Intl API.
|
|
1472
|
+
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
1473
|
+
day: 'numeric',
|
|
1474
|
+
timeZone: 'utc',
|
|
1475
|
+
});
|
|
1476
|
+
// Format a UTC date in order to avoid DST issues.
|
|
1477
|
+
return luxonRange(31, i => dtf.format(DateTime.utc(2017, 1, i + 1).toJSDate()));
|
|
1478
|
+
}
|
|
1479
|
+
getDayOfWeekNames(style) {
|
|
1480
|
+
// Note that we shift the array once, because Luxon returns Monday as the
|
|
1481
|
+
// first day of the week, whereas our logic assumes that it's Sunday. See:
|
|
1482
|
+
// https://moment.github.io/luxon/api-docs/index.html#infoweekdays
|
|
1483
|
+
const days = Info.weekdays(style, { locale: this.locale });
|
|
1484
|
+
days.unshift(days.pop());
|
|
1485
|
+
return days;
|
|
1486
|
+
}
|
|
1487
|
+
getYearName(date) {
|
|
1488
|
+
return date.toFormat('yyyy', this._getOptions());
|
|
1489
|
+
}
|
|
1490
|
+
getFirstDayOfWeek() {
|
|
1491
|
+
return this._firstDayOfWeek;
|
|
1492
|
+
}
|
|
1493
|
+
getNumDaysInMonth(date) {
|
|
1494
|
+
return date.daysInMonth;
|
|
1495
|
+
}
|
|
1496
|
+
clone(date) {
|
|
1497
|
+
return DateTime.fromObject(date.toObject(), this._getOptions());
|
|
1498
|
+
}
|
|
1499
|
+
createDate(year, month, date) {
|
|
1500
|
+
const options = this._getOptions();
|
|
1501
|
+
if (month < 0 || month > 11) {
|
|
1502
|
+
throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
|
|
1503
|
+
}
|
|
1504
|
+
if (date < 1) {
|
|
1505
|
+
throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
|
|
1506
|
+
}
|
|
1507
|
+
// Luxon uses 1-indexed months so we need to add one to the month.
|
|
1508
|
+
const result = this._useUTC
|
|
1509
|
+
? DateTime.utc(year, month + 1, date, options)
|
|
1510
|
+
: DateTime.local(year, month + 1, date, options);
|
|
1511
|
+
if (!this.isValid(result)) {
|
|
1512
|
+
throw Error(`Invalid date "${date}". Reason: "${result.invalidReason}".`);
|
|
1513
|
+
}
|
|
1514
|
+
return result;
|
|
1515
|
+
}
|
|
1516
|
+
today() {
|
|
1517
|
+
const options = this._getOptions();
|
|
1518
|
+
return this._useUTC
|
|
1519
|
+
? DateTime.utc(options)
|
|
1520
|
+
: DateTime.local(options);
|
|
1521
|
+
}
|
|
1522
|
+
parse(value, parseFormat) {
|
|
1523
|
+
const options = this._getOptions();
|
|
1524
|
+
if (typeof value == 'string' && value.length > 0) {
|
|
1525
|
+
// This is screwing things up as 062005 would become 05 0602
|
|
1526
|
+
// const iso8601Date = LuxonDateTime.fromISO(value, options);
|
|
1527
|
+
//
|
|
1528
|
+
// if (this.isValid(iso8601Date)) {
|
|
1529
|
+
// console.log(iso8601Date);
|
|
1530
|
+
// return iso8601Date;
|
|
1531
|
+
// }
|
|
1532
|
+
const formats = Array.isArray(parseFormat) ? parseFormat : [parseFormat];
|
|
1533
|
+
if (!parseFormat.length) {
|
|
1534
|
+
throw Error('Formats array must not be empty.');
|
|
1535
|
+
}
|
|
1536
|
+
console.log(formats);
|
|
1537
|
+
for (const format of formats) {
|
|
1538
|
+
console.log(format);
|
|
1539
|
+
const fromFormat = DateTime.fromFormat(value, format, options);
|
|
1540
|
+
if (this.isValid(fromFormat)) {
|
|
1541
|
+
return fromFormat;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
return this.invalid();
|
|
1545
|
+
}
|
|
1546
|
+
else if (typeof value === 'number') {
|
|
1547
|
+
return DateTime.fromMillis(value, options);
|
|
1548
|
+
}
|
|
1549
|
+
else if (value instanceof Date) {
|
|
1550
|
+
return DateTime.fromJSDate(value, options);
|
|
1551
|
+
}
|
|
1552
|
+
else if (value instanceof DateTime) {
|
|
1553
|
+
return DateTime.fromMillis(value.toMillis(), options);
|
|
1554
|
+
}
|
|
1555
|
+
return null;
|
|
1556
|
+
}
|
|
1557
|
+
format(date, displayFormat) {
|
|
1558
|
+
if (!this.isValid(date)) {
|
|
1559
|
+
throw Error('LuxonDateAdapter: Cannot format invalid date.');
|
|
1560
|
+
}
|
|
1561
|
+
if (this._useUTC) {
|
|
1562
|
+
return date.setLocale(this.locale).setZone('utc').toFormat(displayFormat);
|
|
1563
|
+
}
|
|
1564
|
+
else {
|
|
1565
|
+
return date.setLocale(this.locale).toFormat(displayFormat);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
addCalendarYears(date, years) {
|
|
1569
|
+
return date.reconfigure(this._getOptions()).plus({ years });
|
|
1570
|
+
}
|
|
1571
|
+
addCalendarMonths(date, months) {
|
|
1572
|
+
return date.reconfigure(this._getOptions()).plus({ months });
|
|
1573
|
+
}
|
|
1574
|
+
addCalendarDays(date, days) {
|
|
1575
|
+
return date.reconfigure(this._getOptions()).plus({ days });
|
|
1576
|
+
}
|
|
1577
|
+
toIso8601(date) {
|
|
1578
|
+
return date.toISO();
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Returns the given value if given a valid Luxon or null. Deserializes valid ISO 8601 strings
|
|
1582
|
+
* (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid DateTime and empty
|
|
1583
|
+
* string into null. Returns an invalid date for all other values.
|
|
1584
|
+
*/
|
|
1585
|
+
deserialize(value) {
|
|
1586
|
+
const options = this._getOptions();
|
|
1587
|
+
let date;
|
|
1588
|
+
if (value instanceof Date) {
|
|
1589
|
+
date = DateTime.fromJSDate(value, options);
|
|
1590
|
+
}
|
|
1591
|
+
if (typeof value === 'string') {
|
|
1592
|
+
if (!value) {
|
|
1593
|
+
return null;
|
|
1594
|
+
}
|
|
1595
|
+
date = DateTime.fromISO(value, options);
|
|
1596
|
+
}
|
|
1597
|
+
if (date && this.isValid(date)) {
|
|
1598
|
+
return date;
|
|
1599
|
+
}
|
|
1600
|
+
return super.deserialize(value);
|
|
1601
|
+
}
|
|
1602
|
+
isDateInstance(obj) {
|
|
1603
|
+
return obj instanceof DateTime;
|
|
1604
|
+
}
|
|
1605
|
+
isValid(date) {
|
|
1606
|
+
return date.isValid;
|
|
1607
|
+
}
|
|
1608
|
+
invalid() {
|
|
1609
|
+
return DateTime.invalid('Invalid Luxon DateTime object.');
|
|
1610
|
+
}
|
|
1611
|
+
setTime(target, hours, minutes, seconds) {
|
|
1612
|
+
//if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1613
|
+
if (hours < 0 || hours > 23) {
|
|
1614
|
+
throw Error(`Invalid hours "${hours}". Hours value must be between 0 and 23.`);
|
|
1615
|
+
}
|
|
1616
|
+
if (minutes < 0 || minutes > 59) {
|
|
1617
|
+
throw Error(`Invalid minutes "${minutes}". Minutes value must be between 0 and 59.`);
|
|
1618
|
+
}
|
|
1619
|
+
if (seconds < 0 || seconds > 59) {
|
|
1620
|
+
throw Error(`Invalid seconds "${seconds}". Seconds value must be between 0 and 59.`);
|
|
1621
|
+
}
|
|
1622
|
+
//}
|
|
1623
|
+
return this.clone(target).set({
|
|
1624
|
+
hour: hours,
|
|
1625
|
+
minute: minutes,
|
|
1626
|
+
second: seconds,
|
|
1627
|
+
millisecond: 0,
|
|
1469
1628
|
});
|
|
1470
1629
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1630
|
+
getHours(date) {
|
|
1631
|
+
return date.hour;
|
|
1632
|
+
}
|
|
1633
|
+
getMinutes(date) {
|
|
1634
|
+
return date.minute;
|
|
1635
|
+
}
|
|
1636
|
+
getSeconds(date) {
|
|
1637
|
+
return date.second;
|
|
1638
|
+
}
|
|
1639
|
+
parseTime(value, parseFormat) {
|
|
1640
|
+
const result = this.parse(value, parseFormat);
|
|
1641
|
+
if ((!result || !this.isValid(result)) && typeof value === 'string') {
|
|
1642
|
+
// It seems like Luxon doesn't work well cross-browser for strings that have
|
|
1643
|
+
// additional characters around the time. Try parsing without those characters.
|
|
1644
|
+
return (this.parse(value.replace(/[^0-9:(AM|PM)]/gi, ''), parseFormat) || result);
|
|
1645
|
+
}
|
|
1646
|
+
return result;
|
|
1647
|
+
}
|
|
1648
|
+
addSeconds(date, amount) {
|
|
1649
|
+
return date.reconfigure(this._getOptions()).plus({ seconds: amount });
|
|
1650
|
+
}
|
|
1651
|
+
/** Gets the options that should be used when constructing a new `DateTime` object. */
|
|
1652
|
+
_getOptions() {
|
|
1653
|
+
return {
|
|
1654
|
+
zone: this._useUTC ? 'utc' : undefined,
|
|
1655
|
+
locale: this.locale,
|
|
1656
|
+
outputCalendar: this._defaultOutputCalendar,
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaLuxonDateAdapter, deps: [{ token: i1$4.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1660
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaLuxonDateAdapter }); }
|
|
1481
1661
|
}
|
|
1482
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type:
|
|
1483
|
-
type:
|
|
1484
|
-
args: [{
|
|
1485
|
-
declarations: [],
|
|
1486
|
-
imports: [MatDatepickerModule, TranslateModule, MatNativeDateModule],
|
|
1487
|
-
exports: [],
|
|
1488
|
-
providers: [
|
|
1489
|
-
{
|
|
1490
|
-
provide: MAT_DATE_LOCALE,
|
|
1491
|
-
useFactory: (translateService) => translateService.currentLang,
|
|
1492
|
-
deps: [TranslateService],
|
|
1493
|
-
},
|
|
1494
|
-
provideLuxonDateAdapter(ONEMRVA_MAT_LUXON_YEAR_MONTH_FORMATS),
|
|
1495
|
-
],
|
|
1496
|
-
}]
|
|
1662
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: OnemrvaLuxonDateAdapter, decorators: [{
|
|
1663
|
+
type: Injectable
|
|
1497
1664
|
}], ctorParameters: () => [{ type: i1$4.TranslateService }] });
|
|
1498
1665
|
|
|
1666
|
+
function onemrvaDateNativeYearMonthProvider() {
|
|
1667
|
+
return [
|
|
1668
|
+
{
|
|
1669
|
+
provide: MAT_DATE_FORMATS,
|
|
1670
|
+
useValue: ONEMRVA_MAT_NATIVE_YEAR_MONTH_FORMAT,
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
provide: DateAdapter,
|
|
1674
|
+
useClass: OnemrvaNativeDateAdapter,
|
|
1675
|
+
},
|
|
1676
|
+
];
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
function onemrvaDateNativeProvider() {
|
|
1680
|
+
return [
|
|
1681
|
+
{
|
|
1682
|
+
provide: MAT_DATE_FORMATS,
|
|
1683
|
+
useValue: ONEMRVA_MAT_NATIVE_DATE_FORMAT,
|
|
1684
|
+
},
|
|
1685
|
+
{
|
|
1686
|
+
provide: DateAdapter,
|
|
1687
|
+
useClass: OnemrvaNativeDateAdapter,
|
|
1688
|
+
},
|
|
1689
|
+
];
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
function onemrvaDateLuxonProvider() {
|
|
1693
|
+
return [
|
|
1694
|
+
{
|
|
1695
|
+
provide: MAT_DATE_FORMATS,
|
|
1696
|
+
useValue: ONEMRVA_MAT_LUXON_DATE_FORMATS,
|
|
1697
|
+
},
|
|
1698
|
+
{
|
|
1699
|
+
provide: DateAdapter,
|
|
1700
|
+
useClass: OnemrvaLuxonDateAdapter,
|
|
1701
|
+
},
|
|
1702
|
+
];
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
function onemrvaDateLuxonYearMonthProvider() {
|
|
1706
|
+
return [
|
|
1707
|
+
{
|
|
1708
|
+
provide: MAT_DATE_FORMATS,
|
|
1709
|
+
useValue: ONEMRVA_MAT_LUXON_YEAR_MONTH_FORMATS,
|
|
1710
|
+
},
|
|
1711
|
+
{
|
|
1712
|
+
provide: DateAdapter,
|
|
1713
|
+
useClass: OnemrvaLuxonDateAdapter,
|
|
1714
|
+
},
|
|
1715
|
+
];
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1499
1718
|
/*
|
|
1500
1719
|
* Public API Surface of shared
|
|
1501
1720
|
*/
|
|
@@ -1504,5 +1723,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImpor
|
|
|
1504
1723
|
* Generated bundle index. Do not edit.
|
|
1505
1724
|
*/
|
|
1506
1725
|
|
|
1507
|
-
export { CDNUrlModeOptions, CDN_URLS, CDN_URL_MODE, ClipboardIconComponent, CommonCountryLookupService, DefaultStorage, DigitOnlyDirective, HttpRequestCache, IBAN_SUPPORTED_COUNTRIES, IfWidthIsDirective, MatRowClickableDirective, NISS_MASK, ONEMRVA_MAT_LUXON_DATE_FORMATS, ONEMRVA_MAT_LUXON_YEAR_MONTH_FORMATS, ONEMRVA_MAT_NATIVE_DATE_FORMAT, ONEMRVA_MAT_NATIVE_YEAR_MONTH_FORMAT, OnemRvaCDNCountryService, OnemRvaCDNMimeService, OnemRvaCDNService, OnemRvaClipboardDirective, OnemRvaColorDirective, OnemRvaIconRightDirective, OnemrvaBcePipe,
|
|
1726
|
+
export { CDNUrlModeOptions, CDN_URLS, CDN_URL_MODE, ClipboardIconComponent, CommonCountryLookupService, DefaultStorage, DigitOnlyDirective, HttpRequestCache, IBAN_SUPPORTED_COUNTRIES, IfWidthIsDirective, MatRowClickableDirective, NISS_MASK, ONEMRVA_MAT_LUXON_DATE_FORMATS, ONEMRVA_MAT_LUXON_YEAR_MONTH_FORMATS, ONEMRVA_MAT_NATIVE_DATE_FORMAT, ONEMRVA_MAT_NATIVE_YEAR_MONTH_FORMAT, OnemRvaCDNCountryService, OnemRvaCDNMimeService, OnemRvaCDNService, OnemRvaClipboardDirective, OnemRvaColorDirective, OnemRvaIconRightDirective, OnemrvaBcePipe, OnemrvaLuxonDateAdapter, OnemrvaMaskDirective, OnemrvaNativeDateAdapter, OnemrvaNissPipe, OnemrvaSharedModule, OnemrvaTranslateCDNLoader, OnemrvaTranslateHttpLoader, OnemrvaValidators, RequestTimes, WebComponentOverlayContainer, bankAccountValidator, directives, onemrvaDateLuxonProvider, onemrvaDateLuxonYearMonthProvider, onemrvaDateNativeProvider, onemrvaDateNativeYearMonthProvider, setTranslationLanguage, setTranslationLanguageFromWO };
|
|
1508
1727
|
//# sourceMappingURL=onemrvapublic-design-system-shared.mjs.map
|