@sebgroup/green-angular 8.1.0 → 8.1.1
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/sebgroup-green-angular-src-v-angular-datepicker.mjs +222 -203
- package/fesm2022/sebgroup-green-angular-src-v-angular-datepicker.mjs.map +1 -1
- package/fesm2022/sebgroup-green-angular-v-angular.mjs +220 -201
- package/fesm2022/sebgroup-green-angular-v-angular.mjs.map +1 -1
- package/package.json +13 -13
- package/src/v-angular/datepicker/components/calendar/calendar.component.d.ts +1 -1
- package/src/v-angular/datepicker/components/date-input/date-input.component.d.ts +1 -1
- package/src/v-angular/datepicker/components/datepicker/datepicker.component.d.ts +1 -1
- package/src/v-angular/datepicker/datepicker.utils.d.ts +7 -0
- package/v-angular/datepicker/components/calendar/calendar.component.d.ts +1 -1
- package/v-angular/datepicker/components/date-input/date-input.component.d.ts +1 -1
- package/v-angular/datepicker/components/datepicker/datepicker.component.d.ts +1 -1
- package/v-angular/datepicker/datepicker.utils.d.ts +7 -0
|
@@ -902,6 +902,220 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
902
902
|
}]
|
|
903
903
|
}] });
|
|
904
904
|
|
|
905
|
+
const weekdays = [
|
|
906
|
+
WeekDay.Monday,
|
|
907
|
+
WeekDay.Tuesday,
|
|
908
|
+
WeekDay.Wednesday,
|
|
909
|
+
WeekDay.Thursday,
|
|
910
|
+
WeekDay.Friday,
|
|
911
|
+
WeekDay.Saturday,
|
|
912
|
+
WeekDay.Sunday,
|
|
913
|
+
];
|
|
914
|
+
const sortWeekDays = (firstDayOfWeek) => {
|
|
915
|
+
const firstDayIndex = weekdays.indexOf(firstDayOfWeek);
|
|
916
|
+
const weekStart = weekdays.slice(firstDayIndex);
|
|
917
|
+
const weekEnd = weekdays.slice(0, firstDayIndex);
|
|
918
|
+
return weekStart.concat(weekEnd);
|
|
919
|
+
};
|
|
920
|
+
/**
|
|
921
|
+
* Safely converts a value to a Date object, handling timezone issues.
|
|
922
|
+
* If the value is already a Date, returns it as-is.
|
|
923
|
+
* If it's a string in ISO format (YYYY-MM-DD), parses it in local timezone.
|
|
924
|
+
* Otherwise, uses standard Date constructor.
|
|
925
|
+
*/
|
|
926
|
+
const toLocalDate = (value) => {
|
|
927
|
+
// If already a Date object, use it directly to avoid timezone issues
|
|
928
|
+
if (value instanceof Date) {
|
|
929
|
+
return value;
|
|
930
|
+
}
|
|
931
|
+
// If string is in ISO format (YYYY-MM-DD), parse in local timezone
|
|
932
|
+
const dateMatch = String(value).match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
933
|
+
if (dateMatch) {
|
|
934
|
+
const [, year, month, day] = dateMatch;
|
|
935
|
+
return new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
|
|
936
|
+
}
|
|
937
|
+
// Otherwise use standard Date constructor
|
|
938
|
+
return new Date(value);
|
|
939
|
+
};
|
|
940
|
+
/** Sets labels and sort weekday arrays based off of first day of week. */
|
|
941
|
+
const getSortedWeekDays = (firstDayOfWeek, startDate) => {
|
|
942
|
+
if (startDate === undefined)
|
|
943
|
+
startDate = new Date();
|
|
944
|
+
// sort weekdays according to firstDayOfWeek
|
|
945
|
+
const sortedWeekdays = sortWeekDays(firstDayOfWeek);
|
|
946
|
+
// get the date object for the first day of week
|
|
947
|
+
const startDayIndex = sortedWeekdays.indexOf(startDate.getDay());
|
|
948
|
+
const firstOfWeek = new Date(startDate);
|
|
949
|
+
firstOfWeek.setDate(startDate.getDate() - startDayIndex);
|
|
950
|
+
// map each day in array to a date object
|
|
951
|
+
return sortedWeekdays.map((_, offset) => {
|
|
952
|
+
// set appropriate date
|
|
953
|
+
const weekdayDate = new Date(firstOfWeek);
|
|
954
|
+
weekdayDate.setDate(weekdayDate.getDate() + offset);
|
|
955
|
+
// and return value
|
|
956
|
+
return weekdayDate;
|
|
957
|
+
});
|
|
958
|
+
};
|
|
959
|
+
/** Generate a matrix of dates used to visualize a calendar month. */
|
|
960
|
+
const generateDateMatrix = (month, year, minWeeks = 5, firstDayOfWeek) => {
|
|
961
|
+
// generate a new matrix with 5 or 6 rows (depending on number of days in that month)
|
|
962
|
+
const matrix = new Array(minWeeks);
|
|
963
|
+
matrix.fill([]);
|
|
964
|
+
const date = new Date(year, month, 1);
|
|
965
|
+
const firstDate = firstCalendarDate(date, firstDayOfWeek);
|
|
966
|
+
// for each week in that month
|
|
967
|
+
const dateMatrix = matrix.map((_, weekOffset) => {
|
|
968
|
+
const offset = weekOffset * 7;
|
|
969
|
+
// update the date with the offset for that week
|
|
970
|
+
const firstOfWeek = new Date(firstDate);
|
|
971
|
+
firstOfWeek.setDate(firstDate.getDate() + offset);
|
|
972
|
+
return getSortedWeekDays(firstDayOfWeek, firstOfWeek);
|
|
973
|
+
});
|
|
974
|
+
// check if another row needs to be added (if last dates of month are missing)
|
|
975
|
+
const lastAdded = dateMatrix.slice(-1)[0].slice(-1)[0];
|
|
976
|
+
const lastOfMonth = new Date(lastAdded);
|
|
977
|
+
lastOfMonth.setMonth(month + 1);
|
|
978
|
+
lastOfMonth.setDate(0);
|
|
979
|
+
if (isBefore(lastAdded, lastOfMonth)) {
|
|
980
|
+
// add another week row
|
|
981
|
+
const firstOfWeek = new Date(lastAdded);
|
|
982
|
+
firstOfWeek.setDate(lastAdded.getDate() + 1);
|
|
983
|
+
dateMatrix.push(getSortedWeekDays(firstDayOfWeek, firstOfWeek));
|
|
984
|
+
}
|
|
985
|
+
// return final datematrix
|
|
986
|
+
return dateMatrix;
|
|
987
|
+
};
|
|
988
|
+
/** Returns the first date used in the calendars first button. */
|
|
989
|
+
const firstCalendarDate = (date, firstDayOfWeek) => {
|
|
990
|
+
// sort weekdays according to firstDayOfWeek
|
|
991
|
+
const sortedWeekdays = sortWeekDays(firstDayOfWeek);
|
|
992
|
+
// set date to the first of month
|
|
993
|
+
const firstOfMonth = new Date(date);
|
|
994
|
+
firstOfMonth.setDate(1);
|
|
995
|
+
// get the offset
|
|
996
|
+
const offset = sortedWeekdays.indexOf(firstOfMonth.getDay());
|
|
997
|
+
const firstOfWeek = new Date(firstOfMonth);
|
|
998
|
+
// use offset to set date
|
|
999
|
+
firstOfWeek.setDate(1 - offset);
|
|
1000
|
+
return firstOfWeek;
|
|
1001
|
+
};
|
|
1002
|
+
const getDayOffset = (from, to, firstDayOfWeek, direction) => {
|
|
1003
|
+
const sortedWeekdays = sortWeekDays(firstDayOfWeek);
|
|
1004
|
+
const fromIndex = sortedWeekdays.indexOf(from);
|
|
1005
|
+
const toIndex = sortedWeekdays.indexOf(to);
|
|
1006
|
+
const offset = toIndex - fromIndex;
|
|
1007
|
+
if (direction === 'forward' && offset < 0)
|
|
1008
|
+
return offset + 6;
|
|
1009
|
+
if (direction === 'back' && offset > 0)
|
|
1010
|
+
return offset - 6;
|
|
1011
|
+
return offset;
|
|
1012
|
+
};
|
|
1013
|
+
/** Returns an array of Dates for each of month. */
|
|
1014
|
+
const getMonthArray = () => {
|
|
1015
|
+
const firstDayOfYear = new Date();
|
|
1016
|
+
firstDayOfYear.setMonth(0);
|
|
1017
|
+
firstDayOfYear.setDate(1);
|
|
1018
|
+
// create a new array of length 12,
|
|
1019
|
+
// and fill it with date objects of 1:st of january
|
|
1020
|
+
const monthArray = new Array(12).fill(firstDayOfYear);
|
|
1021
|
+
// map through the array,
|
|
1022
|
+
// and create a new instance of the date,
|
|
1023
|
+
// changing the month based on index (0 - 11)
|
|
1024
|
+
return monthArray.map((d, index) => {
|
|
1025
|
+
const date = new Date(d);
|
|
1026
|
+
date.setMonth(index);
|
|
1027
|
+
return date;
|
|
1028
|
+
});
|
|
1029
|
+
};
|
|
1030
|
+
/** Returns an array of Dates for the current year and the next. */
|
|
1031
|
+
const getYearArray = () => {
|
|
1032
|
+
const currentYear = new Date();
|
|
1033
|
+
currentYear.setMonth(0);
|
|
1034
|
+
currentYear.setDate(1);
|
|
1035
|
+
const nextYear = new Date(currentYear);
|
|
1036
|
+
nextYear.setFullYear(currentYear.getFullYear() + 1);
|
|
1037
|
+
return [currentYear, nextYear];
|
|
1038
|
+
};
|
|
1039
|
+
/** Returns true if the two dates have the same year, month and date values. */
|
|
1040
|
+
const match = (a, b) => {
|
|
1041
|
+
if (!a || !b)
|
|
1042
|
+
return false;
|
|
1043
|
+
if (a.getDate() !== b.getDate())
|
|
1044
|
+
return false;
|
|
1045
|
+
if (a.getMonth() !== b.getMonth())
|
|
1046
|
+
return false;
|
|
1047
|
+
if (a.getFullYear() !== b.getFullYear())
|
|
1048
|
+
return false;
|
|
1049
|
+
return true;
|
|
1050
|
+
};
|
|
1051
|
+
const afterClosingHours = (closingHours) => {
|
|
1052
|
+
if (!closingHours)
|
|
1053
|
+
return false;
|
|
1054
|
+
return Date.now() >= closingHours.getTime();
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Checks if a date is before control date, regardless of time.
|
|
1058
|
+
*
|
|
1059
|
+
* @param date - comparison date
|
|
1060
|
+
* @param controlDate - date to compare against
|
|
1061
|
+
* @returns - true if the comparison date is before the control date
|
|
1062
|
+
*/
|
|
1063
|
+
const isBefore = (date, controlDate) => {
|
|
1064
|
+
// if year values are dissimilar
|
|
1065
|
+
if (date.getFullYear() !== controlDate.getFullYear()) {
|
|
1066
|
+
return date.getFullYear() < controlDate.getFullYear();
|
|
1067
|
+
}
|
|
1068
|
+
// if month values are dissimilar
|
|
1069
|
+
if (date.getMonth() !== controlDate.getMonth()) {
|
|
1070
|
+
return date.getMonth() < controlDate.getMonth();
|
|
1071
|
+
}
|
|
1072
|
+
// if year and month are equal, check the date
|
|
1073
|
+
return date.getDate() < controlDate.getDate();
|
|
1074
|
+
};
|
|
1075
|
+
/**
|
|
1076
|
+
* Checks if a date is after control date, regardless of time.
|
|
1077
|
+
*
|
|
1078
|
+
* @param date - comparison date
|
|
1079
|
+
* @param controlDate - date to compare against
|
|
1080
|
+
* @returns - true if the comparison date is before the control date
|
|
1081
|
+
*/
|
|
1082
|
+
const isAfter = (date, controlDate) => {
|
|
1083
|
+
// if year values are dissimilar
|
|
1084
|
+
if (date.getFullYear() !== controlDate.getFullYear()) {
|
|
1085
|
+
return date.getFullYear() > controlDate.getFullYear();
|
|
1086
|
+
}
|
|
1087
|
+
// if month values are dissimilar
|
|
1088
|
+
if (date.getMonth() !== controlDate.getMonth()) {
|
|
1089
|
+
return date.getMonth() > controlDate.getMonth();
|
|
1090
|
+
}
|
|
1091
|
+
// if year and month are equal, check the date
|
|
1092
|
+
return date.getDate() > controlDate.getDate();
|
|
1093
|
+
};
|
|
1094
|
+
/**
|
|
1095
|
+
* Checks if a value can be used to initiate a new Date object.
|
|
1096
|
+
*
|
|
1097
|
+
* @param value any value
|
|
1098
|
+
* @returns - true if value can be coersed to a Date.
|
|
1099
|
+
*/
|
|
1100
|
+
const isValid = (value) => {
|
|
1101
|
+
// if value is type of string and can be parsed to a Date
|
|
1102
|
+
const date = value && typeof value === 'string' && !isNaN(Date.parse(value))
|
|
1103
|
+
? new Date(value)
|
|
1104
|
+
: null;
|
|
1105
|
+
switch (true) {
|
|
1106
|
+
// if date or value is a valid date object - return valid
|
|
1107
|
+
case typeof value?.getMonth === 'function':
|
|
1108
|
+
case typeof date?.getMonth === 'function':
|
|
1109
|
+
return true;
|
|
1110
|
+
// if date or value is not a valid date object - return invalid
|
|
1111
|
+
case value == null:
|
|
1112
|
+
case date?.toString() === 'Invalid Date':
|
|
1113
|
+
return false;
|
|
1114
|
+
default:
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
|
|
905
1119
|
/**
|
|
906
1120
|
* Helper function to generate InputmaskOptions by requested locale.
|
|
907
1121
|
* @param locale - requested locale. If not given, it'll use the browsers locale
|
|
@@ -1325,7 +1539,7 @@ class DateControlValueAccessorComponent {
|
|
|
1325
1539
|
try {
|
|
1326
1540
|
// if value is type of string,
|
|
1327
1541
|
if (value && typeof value === 'string')
|
|
1328
|
-
value =
|
|
1542
|
+
value = toLocalDate(value);
|
|
1329
1543
|
switch (true) {
|
|
1330
1544
|
// remove instances where the value will not correctly be parsed to a date string
|
|
1331
1545
|
case value == null:
|
|
@@ -1333,8 +1547,7 @@ class DateControlValueAccessorComponent {
|
|
|
1333
1547
|
return null;
|
|
1334
1548
|
// if value-as-date is a valid date object, parse the value to YYYY-MM-DD format
|
|
1335
1549
|
case typeof value?.getMonth === 'function':
|
|
1336
|
-
|
|
1337
|
-
return date.toISOString().split('T')[0];
|
|
1550
|
+
return new Intl.DateTimeFormat('sv-SE').format(value);
|
|
1338
1551
|
default:
|
|
1339
1552
|
return value;
|
|
1340
1553
|
}
|
|
@@ -1595,200 +1808,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
1595
1808
|
type: Output
|
|
1596
1809
|
}] } });
|
|
1597
1810
|
|
|
1598
|
-
const weekdays = [
|
|
1599
|
-
WeekDay.Monday,
|
|
1600
|
-
WeekDay.Tuesday,
|
|
1601
|
-
WeekDay.Wednesday,
|
|
1602
|
-
WeekDay.Thursday,
|
|
1603
|
-
WeekDay.Friday,
|
|
1604
|
-
WeekDay.Saturday,
|
|
1605
|
-
WeekDay.Sunday,
|
|
1606
|
-
];
|
|
1607
|
-
const sortWeekDays = (firstDayOfWeek) => {
|
|
1608
|
-
const firstDayIndex = weekdays.indexOf(firstDayOfWeek);
|
|
1609
|
-
const weekStart = weekdays.slice(firstDayIndex);
|
|
1610
|
-
const weekEnd = weekdays.slice(0, firstDayIndex);
|
|
1611
|
-
return weekStart.concat(weekEnd);
|
|
1612
|
-
};
|
|
1613
|
-
/** Sets labels and sort weekday arrays based off of first day of week. */
|
|
1614
|
-
const getSortedWeekDays = (firstDayOfWeek, startDate) => {
|
|
1615
|
-
if (startDate === undefined)
|
|
1616
|
-
startDate = new Date();
|
|
1617
|
-
// sort weekdays according to firstDayOfWeek
|
|
1618
|
-
const sortedWeekdays = sortWeekDays(firstDayOfWeek);
|
|
1619
|
-
// get the date object for the first day of week
|
|
1620
|
-
const startDayIndex = sortedWeekdays.indexOf(startDate.getDay());
|
|
1621
|
-
const firstOfWeek = new Date(startDate);
|
|
1622
|
-
firstOfWeek.setDate(startDate.getDate() - startDayIndex);
|
|
1623
|
-
// map each day in array to a date object
|
|
1624
|
-
return sortedWeekdays.map((_, offset) => {
|
|
1625
|
-
// set appropriate date
|
|
1626
|
-
const weekdayDate = new Date(firstOfWeek);
|
|
1627
|
-
weekdayDate.setDate(weekdayDate.getDate() + offset);
|
|
1628
|
-
// and return value
|
|
1629
|
-
return weekdayDate;
|
|
1630
|
-
});
|
|
1631
|
-
};
|
|
1632
|
-
/** Generate a matrix of dates used to visualize a calendar month. */
|
|
1633
|
-
const generateDateMatrix = (month, year, minWeeks = 5, firstDayOfWeek) => {
|
|
1634
|
-
// generate a new matrix with 5 or 6 rows (depending on number of days in that month)
|
|
1635
|
-
const matrix = new Array(minWeeks);
|
|
1636
|
-
matrix.fill([]);
|
|
1637
|
-
const date = new Date(year, month, 1);
|
|
1638
|
-
const firstDate = firstCalendarDate(date, firstDayOfWeek);
|
|
1639
|
-
// for each week in that month
|
|
1640
|
-
const dateMatrix = matrix.map((_, weekOffset) => {
|
|
1641
|
-
const offset = weekOffset * 7;
|
|
1642
|
-
// update the date with the offset for that week
|
|
1643
|
-
const firstOfWeek = new Date(firstDate);
|
|
1644
|
-
firstOfWeek.setDate(firstDate.getDate() + offset);
|
|
1645
|
-
return getSortedWeekDays(firstDayOfWeek, firstOfWeek);
|
|
1646
|
-
});
|
|
1647
|
-
// check if another row needs to be added (if last dates of month are missing)
|
|
1648
|
-
const lastAdded = dateMatrix.slice(-1)[0].slice(-1)[0];
|
|
1649
|
-
const lastOfMonth = new Date(lastAdded);
|
|
1650
|
-
lastOfMonth.setMonth(month + 1);
|
|
1651
|
-
lastOfMonth.setDate(0);
|
|
1652
|
-
if (isBefore(lastAdded, lastOfMonth)) {
|
|
1653
|
-
// add another week row
|
|
1654
|
-
const firstOfWeek = new Date(lastAdded);
|
|
1655
|
-
firstOfWeek.setDate(lastAdded.getDate() + 1);
|
|
1656
|
-
dateMatrix.push(getSortedWeekDays(firstDayOfWeek, firstOfWeek));
|
|
1657
|
-
}
|
|
1658
|
-
// return final datematrix
|
|
1659
|
-
return dateMatrix;
|
|
1660
|
-
};
|
|
1661
|
-
/** Returns the first date used in the calendars first button. */
|
|
1662
|
-
const firstCalendarDate = (date, firstDayOfWeek) => {
|
|
1663
|
-
// sort weekdays according to firstDayOfWeek
|
|
1664
|
-
const sortedWeekdays = sortWeekDays(firstDayOfWeek);
|
|
1665
|
-
// set date to the first of month
|
|
1666
|
-
const firstOfMonth = new Date(date);
|
|
1667
|
-
firstOfMonth.setDate(1);
|
|
1668
|
-
// get the offset
|
|
1669
|
-
const offset = sortedWeekdays.indexOf(firstOfMonth.getDay());
|
|
1670
|
-
const firstOfWeek = new Date(firstOfMonth);
|
|
1671
|
-
// use offset to set date
|
|
1672
|
-
firstOfWeek.setDate(1 - offset);
|
|
1673
|
-
return firstOfWeek;
|
|
1674
|
-
};
|
|
1675
|
-
const getDayOffset = (from, to, firstDayOfWeek, direction) => {
|
|
1676
|
-
const sortedWeekdays = sortWeekDays(firstDayOfWeek);
|
|
1677
|
-
const fromIndex = sortedWeekdays.indexOf(from);
|
|
1678
|
-
const toIndex = sortedWeekdays.indexOf(to);
|
|
1679
|
-
const offset = toIndex - fromIndex;
|
|
1680
|
-
if (direction === 'forward' && offset < 0)
|
|
1681
|
-
return offset + 6;
|
|
1682
|
-
if (direction === 'back' && offset > 0)
|
|
1683
|
-
return offset - 6;
|
|
1684
|
-
return offset;
|
|
1685
|
-
};
|
|
1686
|
-
/** Returns an array of Dates for each of month. */
|
|
1687
|
-
const getMonthArray = () => {
|
|
1688
|
-
const firstDayOfYear = new Date();
|
|
1689
|
-
firstDayOfYear.setMonth(0);
|
|
1690
|
-
firstDayOfYear.setDate(1);
|
|
1691
|
-
// create a new array of length 12,
|
|
1692
|
-
// and fill it with date objects of 1:st of january
|
|
1693
|
-
const monthArray = new Array(12).fill(firstDayOfYear);
|
|
1694
|
-
// map through the array,
|
|
1695
|
-
// and create a new instance of the date,
|
|
1696
|
-
// changing the month based on index (0 - 11)
|
|
1697
|
-
return monthArray.map((d, index) => {
|
|
1698
|
-
const date = new Date(d);
|
|
1699
|
-
date.setMonth(index);
|
|
1700
|
-
return date;
|
|
1701
|
-
});
|
|
1702
|
-
};
|
|
1703
|
-
/** Returns an array of Dates for the current year and the next. */
|
|
1704
|
-
const getYearArray = () => {
|
|
1705
|
-
const currentYear = new Date();
|
|
1706
|
-
currentYear.setMonth(0);
|
|
1707
|
-
currentYear.setDate(1);
|
|
1708
|
-
const nextYear = new Date(currentYear);
|
|
1709
|
-
nextYear.setFullYear(currentYear.getFullYear() + 1);
|
|
1710
|
-
return [currentYear, nextYear];
|
|
1711
|
-
};
|
|
1712
|
-
/** Returns true if the two dates have the same year, month and date values. */
|
|
1713
|
-
const match = (a, b) => {
|
|
1714
|
-
if (!a || !b)
|
|
1715
|
-
return false;
|
|
1716
|
-
if (a.getDate() !== b.getDate())
|
|
1717
|
-
return false;
|
|
1718
|
-
if (a.getMonth() !== b.getMonth())
|
|
1719
|
-
return false;
|
|
1720
|
-
if (a.getFullYear() !== b.getFullYear())
|
|
1721
|
-
return false;
|
|
1722
|
-
return true;
|
|
1723
|
-
};
|
|
1724
|
-
const afterClosingHours = (closingHours) => {
|
|
1725
|
-
if (!closingHours)
|
|
1726
|
-
return false;
|
|
1727
|
-
return Date.now() >= closingHours.getTime();
|
|
1728
|
-
};
|
|
1729
|
-
/**
|
|
1730
|
-
* Checks if a date is before control date, regardless of time.
|
|
1731
|
-
*
|
|
1732
|
-
* @param date - comparison date
|
|
1733
|
-
* @param controlDate - date to compare against
|
|
1734
|
-
* @returns - true if the comparison date is before the control date
|
|
1735
|
-
*/
|
|
1736
|
-
const isBefore = (date, controlDate) => {
|
|
1737
|
-
// if year values are dissimilar
|
|
1738
|
-
if (date.getFullYear() !== controlDate.getFullYear()) {
|
|
1739
|
-
return date.getFullYear() < controlDate.getFullYear();
|
|
1740
|
-
}
|
|
1741
|
-
// if month values are dissimilar
|
|
1742
|
-
if (date.getMonth() !== controlDate.getMonth()) {
|
|
1743
|
-
return date.getMonth() < controlDate.getMonth();
|
|
1744
|
-
}
|
|
1745
|
-
// if year and month are equal, check the date
|
|
1746
|
-
return date.getDate() < controlDate.getDate();
|
|
1747
|
-
};
|
|
1748
|
-
/**
|
|
1749
|
-
* Checks if a date is after control date, regardless of time.
|
|
1750
|
-
*
|
|
1751
|
-
* @param date - comparison date
|
|
1752
|
-
* @param controlDate - date to compare against
|
|
1753
|
-
* @returns - true if the comparison date is before the control date
|
|
1754
|
-
*/
|
|
1755
|
-
const isAfter = (date, controlDate) => {
|
|
1756
|
-
// if year values are dissimilar
|
|
1757
|
-
if (date.getFullYear() !== controlDate.getFullYear()) {
|
|
1758
|
-
return date.getFullYear() > controlDate.getFullYear();
|
|
1759
|
-
}
|
|
1760
|
-
// if month values are dissimilar
|
|
1761
|
-
if (date.getMonth() !== controlDate.getMonth()) {
|
|
1762
|
-
return date.getMonth() > controlDate.getMonth();
|
|
1763
|
-
}
|
|
1764
|
-
// if year and month are equal, check the date
|
|
1765
|
-
return date.getDate() > controlDate.getDate();
|
|
1766
|
-
};
|
|
1767
|
-
/**
|
|
1768
|
-
* Checks if a value can be used to initiate a new Date object.
|
|
1769
|
-
*
|
|
1770
|
-
* @param value any value
|
|
1771
|
-
* @returns - true if value can be coersed to a Date.
|
|
1772
|
-
*/
|
|
1773
|
-
const isValid = (value) => {
|
|
1774
|
-
// if value is type of string and can be parsed to a Date
|
|
1775
|
-
const date = value && typeof value === 'string' && !isNaN(Date.parse(value))
|
|
1776
|
-
? new Date(value)
|
|
1777
|
-
: null;
|
|
1778
|
-
switch (true) {
|
|
1779
|
-
// if date or value is a valid date object - return valid
|
|
1780
|
-
case typeof value?.getMonth === 'function':
|
|
1781
|
-
case typeof date?.getMonth === 'function':
|
|
1782
|
-
return true;
|
|
1783
|
-
// if date or value is not a valid date object - return invalid
|
|
1784
|
-
case value == null:
|
|
1785
|
-
case date?.toString() === 'Invalid Date':
|
|
1786
|
-
return false;
|
|
1787
|
-
default:
|
|
1788
|
-
return false;
|
|
1789
|
-
}
|
|
1790
|
-
};
|
|
1791
|
-
|
|
1792
1811
|
class CalendarDateDirective {
|
|
1793
1812
|
get nativeElement() {
|
|
1794
1813
|
return this.elementRef.nativeElement;
|
|
@@ -1946,7 +1965,7 @@ class CalendarComponent {
|
|
|
1946
1965
|
}
|
|
1947
1966
|
ngOnChanges(changes) {
|
|
1948
1967
|
if (changes.selected?.currentValue) {
|
|
1949
|
-
this.selected =
|
|
1968
|
+
this.selected = toLocalDate(changes.selected.currentValue);
|
|
1950
1969
|
}
|
|
1951
1970
|
if (changes.firstDayOfWeek?.currentValue) {
|
|
1952
1971
|
this.lastDayOfWeek = sortWeekDays(changes.firstDayOfWeek.currentValue).pop();
|
|
@@ -2330,7 +2349,7 @@ class DatepickerComponent {
|
|
|
2330
2349
|
!!changes.selected.currentValue &&
|
|
2331
2350
|
!changes.selected.isFirstChange()) {
|
|
2332
2351
|
// set active calendar to match selected date
|
|
2333
|
-
const activeCalendar = new CalendarMonth(
|
|
2352
|
+
const activeCalendar = new CalendarMonth(toLocalDate(changes.selected.currentValue));
|
|
2334
2353
|
this.changeActiveCalendar(activeCalendar);
|
|
2335
2354
|
}
|
|
2336
2355
|
if (changes.disableDates && !changes.disableDates.isFirstChange()) {
|
|
@@ -2380,7 +2399,7 @@ class DatepickerComponent {
|
|
|
2380
2399
|
const withinSameMonth = (a, b) => a.getMonth() === b.getMonth() && a.getFullYear() === b.getFullYear();
|
|
2381
2400
|
// filter out disabled dates for current and adjacent months
|
|
2382
2401
|
return disableDates
|
|
2383
|
-
.map((d) =>
|
|
2402
|
+
.map((d) => toLocalDate(d))
|
|
2384
2403
|
.filter((d) => withinSameMonth(d, previousMonth) ||
|
|
2385
2404
|
withinSameMonth(d, targetMonth) ||
|
|
2386
2405
|
withinSameMonth(d, nextMonth));
|
|
@@ -8296,5 +8315,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
8296
8315
|
* Generated bundle index. Do not edit.
|
|
8297
8316
|
*/
|
|
8298
8317
|
|
|
8299
|
-
export { AccountNumberPipe, AlertComponent, AlertType, ButtonStyle, CalendarComponent, CalendarControlComponent, CalendarDateDirective, CalendarMonth, CharacterCountdownDirective, DateControlValueAccessorComponent, DateInputComponent, DatepickerComponent, DropdownUtils, InputMaskFormatPipe, IsDisabledPipe, MatchesPipe, MessageType, NggvAccountNumberPipeModule, NggvAlertModule, NggvBaseControlValueAccessorComponent, NggvBaseControlValueAccessorModule, NggvBreadcrumbsComponent, NggvBreadcrumbsModule, NggvButtonComponent, NggvButtonModule, NggvCardComponent, NggvCardModule, NggvCharacterCountdownDirectiveModule, NggvCheckboxComponent, NggvCheckboxModule, NggvDatepickerModule, NggvDialogComponent, NggvDragDropComponent, NggvDragDropModule, NggvDropdownComponent, NggvDropdownListComponent, NggvDropdownModule, NggvExternalLinkDirective, NggvExternalLinkDirectiveModule, NggvFoldOutComponent, NggvFoldOutOptionDirective, NggvI18nModule, NggvI18nTestModule, NggvInfoCircleComponent, NggvInfoCircleModule, NggvInputComponent, NggvInputMaskDirective, NggvInputMaskModule, NggvInputModule, NggvMissingHandler, NggvModalModule, NggvModule, NggvPaginationModule, NggvRadioComponent, NggvRadioControlRegistry, NggvRadioGroupComponent, NggvRadioModule, NggvSlideOutComponent, NggvSlugPipeModule, NggvTableModule, NggvTabsModule, NggvTextareaComponent, NggvTextareaModule, NggvToastModule, NggvTooltipDirective, NggvTooltipModule, NggvTypeaheadDirective, NggvTypeaheadDropdownListComponent, NggvTypeaheadHighlightComponent, NggvTypeaheadInputComponent, NggvTypeaheadModule, PaginationComponent, SlugPipe, TabDirective, TableAppendableRowsTemplateDirective, TableComponent, TableDirective, TableFooterTemplateDirective, TableTemplateDirective, TabsComponent, ToastComponent, ToastMessageService, TrThookPipe, TranslocoMockInterceptor, TranslocoMockMissingHandler, TranslocoMockPipe, TranslocoMockStrategy, TranslocoMockTranspiler, ValueImpurePipe, ValuePipe, afterClosingHours, bbanPattern, createMask, firstCalendarDate, formatAccountNumber, generateDateMatrix, getDayOffset, getFormatDateMask, getLocaleDateMask, getLocaleDateString, getMonthArray, getSortedWeekDays, getYearArray, ibanPattern, isAfter, isBefore, isValid, match, setDateFormatCharacters, sortWeekDays };
|
|
8318
|
+
export { AccountNumberPipe, AlertComponent, AlertType, ButtonStyle, CalendarComponent, CalendarControlComponent, CalendarDateDirective, CalendarMonth, CharacterCountdownDirective, DateControlValueAccessorComponent, DateInputComponent, DatepickerComponent, DropdownUtils, InputMaskFormatPipe, IsDisabledPipe, MatchesPipe, MessageType, NggvAccountNumberPipeModule, NggvAlertModule, NggvBaseControlValueAccessorComponent, NggvBaseControlValueAccessorModule, NggvBreadcrumbsComponent, NggvBreadcrumbsModule, NggvButtonComponent, NggvButtonModule, NggvCardComponent, NggvCardModule, NggvCharacterCountdownDirectiveModule, NggvCheckboxComponent, NggvCheckboxModule, NggvDatepickerModule, NggvDialogComponent, NggvDragDropComponent, NggvDragDropModule, NggvDropdownComponent, NggvDropdownListComponent, NggvDropdownModule, NggvExternalLinkDirective, NggvExternalLinkDirectiveModule, NggvFoldOutComponent, NggvFoldOutOptionDirective, NggvI18nModule, NggvI18nTestModule, NggvInfoCircleComponent, NggvInfoCircleModule, NggvInputComponent, NggvInputMaskDirective, NggvInputMaskModule, NggvInputModule, NggvMissingHandler, NggvModalModule, NggvModule, NggvPaginationModule, NggvRadioComponent, NggvRadioControlRegistry, NggvRadioGroupComponent, NggvRadioModule, NggvSlideOutComponent, NggvSlugPipeModule, NggvTableModule, NggvTabsModule, NggvTextareaComponent, NggvTextareaModule, NggvToastModule, NggvTooltipDirective, NggvTooltipModule, NggvTypeaheadDirective, NggvTypeaheadDropdownListComponent, NggvTypeaheadHighlightComponent, NggvTypeaheadInputComponent, NggvTypeaheadModule, PaginationComponent, SlugPipe, TabDirective, TableAppendableRowsTemplateDirective, TableComponent, TableDirective, TableFooterTemplateDirective, TableTemplateDirective, TabsComponent, ToastComponent, ToastMessageService, TrThookPipe, TranslocoMockInterceptor, TranslocoMockMissingHandler, TranslocoMockPipe, TranslocoMockStrategy, TranslocoMockTranspiler, ValueImpurePipe, ValuePipe, afterClosingHours, bbanPattern, createMask, firstCalendarDate, formatAccountNumber, generateDateMatrix, getDayOffset, getFormatDateMask, getLocaleDateMask, getLocaleDateString, getMonthArray, getSortedWeekDays, getYearArray, ibanPattern, isAfter, isBefore, isValid, match, setDateFormatCharacters, sortWeekDays, toLocalDate };
|
|
8300
8319
|
//# sourceMappingURL=sebgroup-green-angular-v-angular.mjs.map
|