nexheal-lib 0.0.14 → 0.0.15
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/nexheal-lib.mjs +97 -8
- package/fesm2022/nexheal-lib.mjs.map +1 -1
- package/index.d.ts +5 -1
- package/package.json +1 -1
package/fesm2022/nexheal-lib.mjs
CHANGED
|
@@ -427,6 +427,7 @@ class CalendarControl {
|
|
|
427
427
|
timeOnly = false;
|
|
428
428
|
dateFormat = "dd/MM/yyyy";
|
|
429
429
|
placeholder = "dd-mm-yyyy";
|
|
430
|
+
viewMode = "date";
|
|
430
431
|
_disabled = false;
|
|
431
432
|
get disabled() {
|
|
432
433
|
return this._disabled;
|
|
@@ -450,6 +451,22 @@ class CalendarControl {
|
|
|
450
451
|
selectionCleared = new EventEmitter();
|
|
451
452
|
blurEvent = new EventEmitter();
|
|
452
453
|
dateSelected = new EventEmitter();
|
|
454
|
+
_defaultDate;
|
|
455
|
+
get defaultDate() {
|
|
456
|
+
return this._defaultDate;
|
|
457
|
+
}
|
|
458
|
+
set defaultDate(value) {
|
|
459
|
+
this._defaultDate = value;
|
|
460
|
+
if (value && !this.selectedDate) {
|
|
461
|
+
const parsed = new Date(value);
|
|
462
|
+
if (!isNaN(parsed.getTime())) {
|
|
463
|
+
this.displayMonth = parsed.getMonth();
|
|
464
|
+
this.displayYear = parsed.getFullYear();
|
|
465
|
+
this.selectedHour = parsed.getHours();
|
|
466
|
+
this.selectedMinute = parsed.getMinutes();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
453
470
|
_minDate;
|
|
454
471
|
_maxDate;
|
|
455
472
|
get minDate() {
|
|
@@ -826,6 +843,15 @@ class CalendarControl {
|
|
|
826
843
|
}
|
|
827
844
|
parseDate(val) {
|
|
828
845
|
if (typeof val === "string") {
|
|
846
|
+
if (this.viewMode === "month") {
|
|
847
|
+
const mIndex = this.months.findIndex(m => m.toLowerCase() === val.trim().toLowerCase());
|
|
848
|
+
if (mIndex !== -1) {
|
|
849
|
+
return new Date(this.todayYear, mIndex, 1);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (this.viewMode === "date" && val.length <= 2 && !isNaN(+val)) {
|
|
853
|
+
return new Date(this.todayYear, this.todayMonth, +val);
|
|
854
|
+
}
|
|
829
855
|
const m = val.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
830
856
|
if (m) {
|
|
831
857
|
const d = +m[1], mo = +m[2] - 1, y = +m[3];
|
|
@@ -834,7 +860,13 @@ class CalendarControl {
|
|
|
834
860
|
}
|
|
835
861
|
// fallback
|
|
836
862
|
const date = new Date(val);
|
|
837
|
-
|
|
863
|
+
if (!isNaN(date.getTime()))
|
|
864
|
+
return date;
|
|
865
|
+
// final fallback for weird year parsing
|
|
866
|
+
if (this.viewMode === "year" && !isNaN(+val)) {
|
|
867
|
+
return new Date(+val, 0, 1);
|
|
868
|
+
}
|
|
869
|
+
return null;
|
|
838
870
|
}
|
|
839
871
|
formatOutput(date) {
|
|
840
872
|
const datePart = this.datePipe.transform(date, this.dateFormat);
|
|
@@ -883,7 +915,21 @@ class CalendarControl {
|
|
|
883
915
|
];
|
|
884
916
|
selectMonth(index) {
|
|
885
917
|
this.displayMonth = index;
|
|
886
|
-
this.
|
|
918
|
+
if (this.viewMode === "month") {
|
|
919
|
+
const picked = new Date(this.displayYear, this.displayMonth, 1);
|
|
920
|
+
if (this.isDateDisabled(picked))
|
|
921
|
+
return;
|
|
922
|
+
this.selectedDate = picked;
|
|
923
|
+
const out = this.formatOutput(picked);
|
|
924
|
+
this.inputControl.setValue(out, { emitEvent: false });
|
|
925
|
+
this.onChangeFn(out);
|
|
926
|
+
this.onTouchedFn();
|
|
927
|
+
this.dateSelected.emit(picked);
|
|
928
|
+
this.isOpen = false;
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
this.currentView = "day";
|
|
932
|
+
}
|
|
887
933
|
}
|
|
888
934
|
get displayMonthName() {
|
|
889
935
|
return this.months[this.displayMonth];
|
|
@@ -924,7 +970,21 @@ class CalendarControl {
|
|
|
924
970
|
}
|
|
925
971
|
selectYear(year) {
|
|
926
972
|
this.displayYear = year;
|
|
927
|
-
this.
|
|
973
|
+
if (this.viewMode === "year") {
|
|
974
|
+
const picked = new Date(this.displayYear, 0, 1);
|
|
975
|
+
if (this.isDateDisabled(picked))
|
|
976
|
+
return;
|
|
977
|
+
this.selectedDate = picked;
|
|
978
|
+
const out = this.formatOutput(picked);
|
|
979
|
+
this.inputControl.setValue(out, { emitEvent: false });
|
|
980
|
+
this.onChangeFn(out);
|
|
981
|
+
this.onTouchedFn();
|
|
982
|
+
this.dateSelected.emit(picked);
|
|
983
|
+
this.isOpen = false;
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
this.currentView = "month";
|
|
987
|
+
}
|
|
928
988
|
}
|
|
929
989
|
prevYearRange() {
|
|
930
990
|
this.displayYear -= this.yearRangeSize;
|
|
@@ -1035,12 +1095,28 @@ class CalendarControl {
|
|
|
1035
1095
|
if (this.isOpen) {
|
|
1036
1096
|
// mark this one as current
|
|
1037
1097
|
CalendarControl._currentlyOpen = this;
|
|
1038
|
-
|
|
1039
|
-
|
|
1098
|
+
if (this.viewMode === "month") {
|
|
1099
|
+
this.currentView = "month";
|
|
1100
|
+
}
|
|
1101
|
+
else if (this.viewMode === "year") {
|
|
1102
|
+
this.currentView = "yearRange";
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
this.currentView = "day";
|
|
1106
|
+
}
|
|
1040
1107
|
if (this.selectedDate) {
|
|
1041
1108
|
this.displayMonth = this.selectedDate.getMonth();
|
|
1042
1109
|
this.displayYear = this.selectedDate.getFullYear();
|
|
1043
1110
|
}
|
|
1111
|
+
else if (this._defaultDate) {
|
|
1112
|
+
const parsed = new Date(this._defaultDate);
|
|
1113
|
+
if (!isNaN(parsed.getTime())) {
|
|
1114
|
+
this.displayMonth = parsed.getMonth();
|
|
1115
|
+
this.displayYear = parsed.getFullYear();
|
|
1116
|
+
this.selectedHour = parsed.getHours();
|
|
1117
|
+
this.selectedMinute = parsed.getMinutes();
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1044
1120
|
else {
|
|
1045
1121
|
const now = new Date();
|
|
1046
1122
|
this.displayMonth = now.getMonth();
|
|
@@ -1088,15 +1164,24 @@ class CalendarControl {
|
|
|
1088
1164
|
this.selectionCleared.emit();
|
|
1089
1165
|
event.stopPropagation();
|
|
1090
1166
|
this.selectedDate = null;
|
|
1091
|
-
|
|
1092
|
-
|
|
1167
|
+
if (this._defaultDate) {
|
|
1168
|
+
const parsed = new Date(this._defaultDate);
|
|
1169
|
+
if (!isNaN(parsed.getTime())) {
|
|
1170
|
+
this.selectedHour = parsed.getHours();
|
|
1171
|
+
this.selectedMinute = parsed.getMinutes();
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
else {
|
|
1175
|
+
this.selectedHour = this.today.getHours();
|
|
1176
|
+
this.selectedMinute = this.today.getMinutes();
|
|
1177
|
+
}
|
|
1093
1178
|
this.inputControl.setValue("", { emitEvent: false });
|
|
1094
1179
|
this.onChangeFn(null);
|
|
1095
1180
|
this.onTouchedFn();
|
|
1096
1181
|
this.dateSelected.emit(null);
|
|
1097
1182
|
}
|
|
1098
1183
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: CalendarControl, deps: [{ token: i1.DatePipe }], target: i0.ɵɵFactoryTarget.Component });
|
|
1099
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.3", type: CalendarControl, isStandalone: true, selector: "calendar-control", inputs: { title: "title", required: "required", customClass: "customClass", clearVal: "clearVal", deFocus: "deFocus", error: "error", errorMessage: "errorMessage", inputLoader: "inputLoader", hourFormat: "hourFormat", selectionMode: "selectionMode", timeOnly: "timeOnly", dateFormat: "dateFormat", placeholder: "placeholder", disabled: "disabled", readonly: "readonly", submitted: "submitted", inputPlaceholder: "inputPlaceholder", closeVal: ["close-val", "closeVal"], showTime: "showTime", minDate: "minDate", maxDate: "maxDate" }, outputs: { selectionCleared: "selectionCleared", blurEvent: "blurEvent", dateSelected: "dateSelected" }, host: { listeners: { "document:click": "clickOutside($event)" } }, providers: [
|
|
1184
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.3", type: CalendarControl, isStandalone: true, selector: "calendar-control", inputs: { title: "title", required: "required", customClass: "customClass", clearVal: "clearVal", deFocus: "deFocus", error: "error", errorMessage: "errorMessage", inputLoader: "inputLoader", hourFormat: "hourFormat", selectionMode: "selectionMode", timeOnly: "timeOnly", dateFormat: "dateFormat", placeholder: "placeholder", viewMode: "viewMode", disabled: "disabled", readonly: "readonly", submitted: "submitted", inputPlaceholder: "inputPlaceholder", closeVal: ["close-val", "closeVal"], showTime: "showTime", defaultDate: "defaultDate", minDate: "minDate", maxDate: "maxDate" }, outputs: { selectionCleared: "selectionCleared", blurEvent: "blurEvent", dateSelected: "dateSelected" }, host: { listeners: { "document:click": "clickOutside($event)" } }, providers: [
|
|
1100
1185
|
DatePipe,
|
|
1101
1186
|
{
|
|
1102
1187
|
provide: NG_VALUE_ACCESSOR,
|
|
@@ -1145,6 +1230,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
|
|
|
1145
1230
|
type: Input
|
|
1146
1231
|
}], placeholder: [{
|
|
1147
1232
|
type: Input
|
|
1233
|
+
}], viewMode: [{
|
|
1234
|
+
type: Input
|
|
1148
1235
|
}], disabled: [{
|
|
1149
1236
|
type: Input
|
|
1150
1237
|
}], readonly: [{
|
|
@@ -1164,6 +1251,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImpor
|
|
|
1164
1251
|
type: Output
|
|
1165
1252
|
}], dateSelected: [{
|
|
1166
1253
|
type: Output
|
|
1254
|
+
}], defaultDate: [{
|
|
1255
|
+
type: Input
|
|
1167
1256
|
}], minDate: [{
|
|
1168
1257
|
type: Input
|
|
1169
1258
|
}], maxDate: [{
|