@porscheinformatik/clr-addons 19.14.1 → 19.14.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InputDateDisplayFormat } from '../daterange.constants';
|
|
2
2
|
import { NullableDaterange } from '../interfaces/daterange.interface';
|
|
3
3
|
import { NullableTimerange } from '../interfaces/timerange.interface';
|
|
4
|
+
import { NullableTimeModel } from '../models/time.model';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
/**
|
|
6
7
|
* Daterange parsing service.
|
|
@@ -42,12 +43,19 @@ export declare class DaterangeParsingService {
|
|
|
42
43
|
* @returns Daterange object.
|
|
43
44
|
*/
|
|
44
45
|
parse(daterangeString: string, separator?: string): NullableDaterange;
|
|
46
|
+
parseWithTime(daterangeString: string, separator?: string): NullableTimerange;
|
|
45
47
|
/**
|
|
46
48
|
* Get `DayModel` from date string.
|
|
47
49
|
* @param dateString - Date string.
|
|
48
50
|
* @returns DayModel.
|
|
49
51
|
*/
|
|
50
52
|
private getDayModelFromDateString;
|
|
53
|
+
/**
|
|
54
|
+
* Get `TimeModel` from time string.
|
|
55
|
+
* @param timeString - Time string in HH:mm:ss or HH:mm format.
|
|
56
|
+
* @returns TimeModel.
|
|
57
|
+
*/
|
|
58
|
+
getTimeModelFromDateString(timeString: string): NullableTimeModel;
|
|
51
59
|
/**
|
|
52
60
|
* Get `DayModel` from date string parts.
|
|
53
61
|
* @param yearString - Year string.
|
package/fesm2022/clr-addons.mjs
CHANGED
|
@@ -13331,6 +13331,88 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
13331
13331
|
type: Injectable
|
|
13332
13332
|
}] });
|
|
13333
13333
|
|
|
13334
|
+
/**
|
|
13335
|
+
* Time model.
|
|
13336
|
+
* Takes care of keeping records of full time.
|
|
13337
|
+
*/
|
|
13338
|
+
class TimeModel {
|
|
13339
|
+
constructor(...args) {
|
|
13340
|
+
if (args[0] instanceof Date) {
|
|
13341
|
+
const date = args[0];
|
|
13342
|
+
this.hours = date.getHours();
|
|
13343
|
+
this.minutes = date.getMinutes();
|
|
13344
|
+
this.seconds = date.getSeconds();
|
|
13345
|
+
}
|
|
13346
|
+
else if (typeof args[0] === 'string') {
|
|
13347
|
+
const [hours, minutes, seconds] = args[0].split(':').map(n => parseInt(n));
|
|
13348
|
+
this.hours = hours;
|
|
13349
|
+
this.minutes = minutes;
|
|
13350
|
+
this.seconds = seconds;
|
|
13351
|
+
}
|
|
13352
|
+
else {
|
|
13353
|
+
this.hours = args[0];
|
|
13354
|
+
this.minutes = args[1];
|
|
13355
|
+
this.seconds = args[2];
|
|
13356
|
+
}
|
|
13357
|
+
}
|
|
13358
|
+
/**
|
|
13359
|
+
* Checks if the passed value is equal to current time model.
|
|
13360
|
+
* @param value - Time model.
|
|
13361
|
+
* @returns Whether value is equal to current time model.
|
|
13362
|
+
*/
|
|
13363
|
+
isEqual(value) {
|
|
13364
|
+
if (value) {
|
|
13365
|
+
return this.hours === value.hours && this.minutes === value.minutes && this.seconds === value.seconds;
|
|
13366
|
+
}
|
|
13367
|
+
return false;
|
|
13368
|
+
}
|
|
13369
|
+
/**
|
|
13370
|
+
* Checks if current time model is after value.
|
|
13371
|
+
* @param value - time model.
|
|
13372
|
+
* @returns Whether current time model is after value.
|
|
13373
|
+
*/
|
|
13374
|
+
isAfter(value) {
|
|
13375
|
+
return this.toDate() > value.toDate();
|
|
13376
|
+
}
|
|
13377
|
+
/**
|
|
13378
|
+
* Checks if current time model is before value.
|
|
13379
|
+
* @param value - Time model.
|
|
13380
|
+
* @returns Whether current time model is before value.
|
|
13381
|
+
*/
|
|
13382
|
+
isBefore(value) {
|
|
13383
|
+
return this.toDate() < value.toDate();
|
|
13384
|
+
}
|
|
13385
|
+
/**
|
|
13386
|
+
* Clones the current odel.
|
|
13387
|
+
* @returns Cloned model.
|
|
13388
|
+
*/
|
|
13389
|
+
clone() {
|
|
13390
|
+
return new TimeModel(this.hours, this.minutes, this.seconds);
|
|
13391
|
+
}
|
|
13392
|
+
/**
|
|
13393
|
+
* Convert to Javascript Date object.
|
|
13394
|
+
* @returns Javascript Date object.
|
|
13395
|
+
*/
|
|
13396
|
+
toDate() {
|
|
13397
|
+
return new Date(new Date().setHours(this.hours, this.minutes, this.seconds ? this.seconds : 0));
|
|
13398
|
+
}
|
|
13399
|
+
/**
|
|
13400
|
+
* To HTML5 time spec string.
|
|
13401
|
+
* @returns Time as HTML5 spec string.
|
|
13402
|
+
*/
|
|
13403
|
+
toHTML5SpecTimeString() {
|
|
13404
|
+
// The clarity time picker uses the format 'hh:mm:ss'.
|
|
13405
|
+
if (this.seconds) {
|
|
13406
|
+
return this.pad(this.hours) + ':' + this.pad(this.minutes) + ':' + this.pad(this.seconds);
|
|
13407
|
+
}
|
|
13408
|
+
// The clarity time picker uses the format 'hh:mm'.
|
|
13409
|
+
return this.pad(this.hours) + ':' + this.pad(this.minutes);
|
|
13410
|
+
}
|
|
13411
|
+
pad(num) {
|
|
13412
|
+
return num < 10 ? `0${num}` : `${num}`;
|
|
13413
|
+
}
|
|
13414
|
+
}
|
|
13415
|
+
|
|
13334
13416
|
/**
|
|
13335
13417
|
* Daterange parsing service.
|
|
13336
13418
|
* Heavy inspired by `date-io.service.ts` from Clarity.
|
|
@@ -13456,6 +13538,20 @@ class DaterangeParsingService {
|
|
|
13456
13538
|
}
|
|
13457
13539
|
return { from, to };
|
|
13458
13540
|
}
|
|
13541
|
+
parseWithTime(daterangeString, separator = SEPARATOR_TEXT_DEFAULT) {
|
|
13542
|
+
if (daterangeString == null || daterangeString === '') {
|
|
13543
|
+
return null;
|
|
13544
|
+
}
|
|
13545
|
+
const [fromString, toString] = daterangeString.split(separator);
|
|
13546
|
+
const from = this.getDayModelFromDateString(fromString.split(' ')[0]);
|
|
13547
|
+
const to = this.getDayModelFromDateString(toString.split(' ')[0]);
|
|
13548
|
+
const fromTime = this.getTimeModelFromDateString(fromString.split(' ')[1]);
|
|
13549
|
+
const toTime = this.getTimeModelFromDateString(toString.split(' ')[1]);
|
|
13550
|
+
if (from == null && to == null) {
|
|
13551
|
+
return null;
|
|
13552
|
+
}
|
|
13553
|
+
return { from, to, fromTime, toTime };
|
|
13554
|
+
}
|
|
13459
13555
|
/**
|
|
13460
13556
|
* Get `DayModel` from date string.
|
|
13461
13557
|
* @param dateString - Date string.
|
|
@@ -13483,6 +13579,33 @@ class DaterangeParsingService {
|
|
|
13483
13579
|
return this.getDayModelFromDateParts(firstPart, secondPart, thirdPart);
|
|
13484
13580
|
}
|
|
13485
13581
|
}
|
|
13582
|
+
/**
|
|
13583
|
+
* Get `TimeModel` from time string.
|
|
13584
|
+
* @param timeString - Time string in HH:mm:ss or HH:mm format.
|
|
13585
|
+
* @returns TimeModel.
|
|
13586
|
+
*/
|
|
13587
|
+
getTimeModelFromDateString(timeString) {
|
|
13588
|
+
// If no time string provided, return null
|
|
13589
|
+
if (timeString == null || timeString === '') {
|
|
13590
|
+
return null;
|
|
13591
|
+
}
|
|
13592
|
+
// Parse the time string
|
|
13593
|
+
const timeParts = timeString.trim().split(':');
|
|
13594
|
+
if (timeParts.length < 1 || timeParts.length > 3) {
|
|
13595
|
+
return null;
|
|
13596
|
+
}
|
|
13597
|
+
const hours = parseInt(timeParts[0], 10);
|
|
13598
|
+
const minutes = parseInt(timeParts[1], 10);
|
|
13599
|
+
const seconds = timeParts.length === 3 ? parseInt(timeParts[2], 10) : 0;
|
|
13600
|
+
// Validate time values
|
|
13601
|
+
if (isNaN(hours) || isNaN(minutes) || isNaN(seconds)) {
|
|
13602
|
+
return null;
|
|
13603
|
+
}
|
|
13604
|
+
if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) {
|
|
13605
|
+
return null;
|
|
13606
|
+
}
|
|
13607
|
+
return new TimeModel(hours, minutes, seconds);
|
|
13608
|
+
}
|
|
13486
13609
|
/**
|
|
13487
13610
|
* Get `DayModel` from date string parts.
|
|
13488
13611
|
* @param yearString - Year string.
|
|
@@ -13717,88 +13840,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
13717
13840
|
args: [ClrControlSuccess]
|
|
13718
13841
|
}] } });
|
|
13719
13842
|
|
|
13720
|
-
/**
|
|
13721
|
-
* Time model.
|
|
13722
|
-
* Takes care of keeping records of full time.
|
|
13723
|
-
*/
|
|
13724
|
-
class TimeModel {
|
|
13725
|
-
constructor(...args) {
|
|
13726
|
-
if (args[0] instanceof Date) {
|
|
13727
|
-
const date = args[0];
|
|
13728
|
-
this.hours = date.getHours();
|
|
13729
|
-
this.minutes = date.getMinutes();
|
|
13730
|
-
this.seconds = date.getSeconds();
|
|
13731
|
-
}
|
|
13732
|
-
else if (typeof args[0] === 'string') {
|
|
13733
|
-
const [hours, minutes, seconds] = args[0].split(':').map(n => parseInt(n));
|
|
13734
|
-
this.hours = hours;
|
|
13735
|
-
this.minutes = minutes;
|
|
13736
|
-
this.seconds = seconds;
|
|
13737
|
-
}
|
|
13738
|
-
else {
|
|
13739
|
-
this.hours = args[0];
|
|
13740
|
-
this.minutes = args[1];
|
|
13741
|
-
this.seconds = args[2];
|
|
13742
|
-
}
|
|
13743
|
-
}
|
|
13744
|
-
/**
|
|
13745
|
-
* Checks if the passed value is equal to current time model.
|
|
13746
|
-
* @param value - Time model.
|
|
13747
|
-
* @returns Whether value is equal to current time model.
|
|
13748
|
-
*/
|
|
13749
|
-
isEqual(value) {
|
|
13750
|
-
if (value) {
|
|
13751
|
-
return this.hours === value.hours && this.minutes === value.minutes && this.seconds === value.seconds;
|
|
13752
|
-
}
|
|
13753
|
-
return false;
|
|
13754
|
-
}
|
|
13755
|
-
/**
|
|
13756
|
-
* Checks if current time model is after value.
|
|
13757
|
-
* @param value - time model.
|
|
13758
|
-
* @returns Whether current time model is after value.
|
|
13759
|
-
*/
|
|
13760
|
-
isAfter(value) {
|
|
13761
|
-
return this.toDate() > value.toDate();
|
|
13762
|
-
}
|
|
13763
|
-
/**
|
|
13764
|
-
* Checks if current time model is before value.
|
|
13765
|
-
* @param value - Time model.
|
|
13766
|
-
* @returns Whether current time model is before value.
|
|
13767
|
-
*/
|
|
13768
|
-
isBefore(value) {
|
|
13769
|
-
return this.toDate() < value.toDate();
|
|
13770
|
-
}
|
|
13771
|
-
/**
|
|
13772
|
-
* Clones the current odel.
|
|
13773
|
-
* @returns Cloned model.
|
|
13774
|
-
*/
|
|
13775
|
-
clone() {
|
|
13776
|
-
return new TimeModel(this.hours, this.minutes, this.seconds);
|
|
13777
|
-
}
|
|
13778
|
-
/**
|
|
13779
|
-
* Convert to Javascript Date object.
|
|
13780
|
-
* @returns Javascript Date object.
|
|
13781
|
-
*/
|
|
13782
|
-
toDate() {
|
|
13783
|
-
return new Date(new Date().setHours(this.hours, this.minutes, this.seconds ? this.seconds : 0));
|
|
13784
|
-
}
|
|
13785
|
-
/**
|
|
13786
|
-
* To HTML5 time spec string.
|
|
13787
|
-
* @returns Time as HTML5 spec string.
|
|
13788
|
-
*/
|
|
13789
|
-
toHTML5SpecTimeString() {
|
|
13790
|
-
// The clarity time picker uses the format 'hh:mm:ss'.
|
|
13791
|
-
if (this.seconds) {
|
|
13792
|
-
return this.pad(this.hours) + ':' + this.pad(this.minutes) + ':' + this.pad(this.seconds);
|
|
13793
|
-
}
|
|
13794
|
-
// The clarity time picker uses the format 'hh:mm'.
|
|
13795
|
-
return this.pad(this.hours) + ':' + this.pad(this.minutes);
|
|
13796
|
-
}
|
|
13797
|
-
pad(num) {
|
|
13798
|
-
return num < 10 ? `0${num}` : `${num}`;
|
|
13799
|
-
}
|
|
13800
|
-
}
|
|
13801
|
-
|
|
13802
13843
|
/**
|
|
13803
13844
|
* Daterangepicker.
|
|
13804
13845
|
*/
|
|
@@ -13932,7 +13973,13 @@ class ClrDaterangepickerDirective {
|
|
|
13932
13973
|
this.daterangeService.updateSelectedDaterange(null, true);
|
|
13933
13974
|
return;
|
|
13934
13975
|
}
|
|
13935
|
-
|
|
13976
|
+
let daterange;
|
|
13977
|
+
if (this.daterangeService.timeActive) {
|
|
13978
|
+
daterange = this.daterangeParsingService.parseWithTime(target.value, this.separatorText);
|
|
13979
|
+
}
|
|
13980
|
+
else {
|
|
13981
|
+
daterange = this.daterangeParsingService.parse(target.value, this.separatorText);
|
|
13982
|
+
}
|
|
13936
13983
|
const invalidDaterange = daterange == null || daterange.from == null || daterange.to == null;
|
|
13937
13984
|
// Invalid manual daterange specified.
|
|
13938
13985
|
if (invalidDaterange) {
|