@anglr/datetime 5.0.0-beta.20221020045240 → 5.0.0-beta.20221020124055
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/changelog.md +15 -2
- package/es2015/src/legacy/picker/components/dayPicker/dayPicker.component.js +2 -1
- package/es2015/src/legacy/picker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2015/src/legacy/picker/components/monthPicker/monthPicker.component.js +2 -1
- package/es2015/src/legacy/picker/components/monthPicker/monthPicker.component.js.map +1 -1
- package/es2015/src/legacy/picker/components/yearPicker/yearPicker.component.js +2 -1
- package/es2015/src/legacy/picker/components/yearPicker/yearPicker.component.js.map +1 -1
- package/es2015/src/legacy/picker/misc/datetimePicker.interface.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.js +110 -0
- package/es2015/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js +141 -28
- package/es2015/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.js +103 -29
- package/es2015/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/components/index.js +1 -0
- package/es2015/src/modules/dateTimePicker/components/index.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.js +120 -0
- package/es2015/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.js.map +1 -0
- package/es2015/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js +69 -15
- package/es2015/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.interface.js.map +1 -1
- package/es2015/src/modules/dateTimePicker/interfaces/dateTimePicker/dateTimePicker.interface.js.map +1 -1
- package/es2020/src/legacy/picker/components/dayPicker/dayPicker.component.js +2 -1
- package/es2020/src/legacy/picker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2020/src/legacy/picker/components/monthPicker/monthPicker.component.js +2 -1
- package/es2020/src/legacy/picker/components/monthPicker/monthPicker.component.js.map +1 -1
- package/es2020/src/legacy/picker/components/yearPicker/yearPicker.component.js +2 -1
- package/es2020/src/legacy/picker/components/yearPicker/yearPicker.component.js.map +1 -1
- package/es2020/src/legacy/picker/misc/datetimePicker.interface.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.js +105 -0
- package/es2020/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js +138 -27
- package/es2020/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.js +101 -28
- package/es2020/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/components/index.js +1 -0
- package/es2020/src/modules/dateTimePicker/components/index.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.js +116 -0
- package/es2020/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.js.map +1 -0
- package/es2020/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js +65 -11
- package/es2020/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.interface.js.map +1 -1
- package/es2020/src/modules/dateTimePicker/interfaces/dateTimePicker/dateTimePicker.interface.js.map +1 -1
- package/package.json +1 -1
- package/src/legacy/picker/components/dayPicker/dayPicker.component.d.ts.map +1 -1
- package/src/legacy/picker/components/monthPicker/monthPicker.component.d.ts.map +1 -1
- package/src/legacy/picker/components/yearPicker/yearPicker.component.d.ts.map +1 -1
- package/src/legacy/picker/misc/datetimePicker.interface.d.ts +4 -0
- package/src/legacy/picker/misc/datetimePicker.interface.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.d.ts +55 -8
- package/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.d.ts +38 -6
- package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.d.ts +26 -12
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.html +5 -5
- package/src/modules/dateTimePicker/components/index.d.ts +1 -0
- package/src/modules/dateTimePicker/components/index.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.d.ts +43 -0
- package/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.d.ts.map +1 -0
- package/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.html +13 -0
- package/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.d.ts +21 -6
- package/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.d.ts.map +1 -1
- package/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.interface.d.ts +8 -0
- package/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.interface.d.ts.map +1 -1
- package/src/modules/dateTimePicker/interfaces/dateTimePicker/dateTimePicker.interface.d.ts +2 -5
- package/src/modules/dateTimePicker/interfaces/dateTimePicker/dateTimePicker.interface.d.ts.map +1 -1
- package/styles/components/_date-time-picker.scss +137 -0
- package/version.bak +1 -1
- package/es2015/src/modules/dateTimePicker/components/dayPicker/dayPicker.interfaces.js +0 -2
- package/es2015/src/modules/dateTimePicker/components/dayPicker/dayPicker.interfaces.js.map +0 -1
- package/es2020/src/modules/dateTimePicker/components/dayPicker/dayPicker.interfaces.js +0 -2
- package/es2020/src/modules/dateTimePicker/components/dayPicker/dayPicker.interfaces.js.map +0 -1
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.css +0 -27
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.interfaces.d.ts +0 -11
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.interfaces.d.ts.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Component, ChangeDetectionStrategy
|
|
1
|
+
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import { DateTimePeriodPickerBase } from '../dateTimePeriodPickerBase';
|
|
4
4
|
import { DatePipesModule } from '../../../datePipes.module';
|
|
5
|
-
import { DATE_API } from '../../../../misc/tokens';
|
|
6
5
|
import * as i0 from "@angular/core";
|
|
7
6
|
import * as i1 from "@angular/common";
|
|
8
7
|
import * as i2 from "../../../../pipes/dateFormat.pipe";
|
|
@@ -11,55 +10,132 @@ import * as i2 from "../../../../pipes/dateFormat.pipe";
|
|
|
11
10
|
*/
|
|
12
11
|
export class DayPickerSAComponent extends DateTimePeriodPickerBase {
|
|
13
12
|
//######################### constructor #########################
|
|
14
|
-
constructor(
|
|
13
|
+
constructor() {
|
|
15
14
|
super();
|
|
16
|
-
|
|
15
|
+
//######################### protected properties #########################
|
|
16
|
+
/**
|
|
17
|
+
* Stored this picker month data
|
|
18
|
+
*/
|
|
19
|
+
this.thisMonthData = [];
|
|
17
20
|
//######################### protected properties - template bindings #########################
|
|
18
21
|
/**
|
|
19
22
|
* Names of days
|
|
20
23
|
*/
|
|
21
24
|
this.weekdays = [];
|
|
22
|
-
|
|
23
|
-
* Array of period data to be displayed
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
this.periodData = [];
|
|
25
|
+
this.weekdays = this.dateApi.weekdaysShort();
|
|
27
26
|
}
|
|
28
27
|
//######################### protected methods - template bindings #########################
|
|
28
|
+
/**
|
|
29
|
+
* Selects day as value of date time picker
|
|
30
|
+
* @param dayData - Day data that were selected
|
|
31
|
+
*/
|
|
29
32
|
selectDay(dayData) {
|
|
33
|
+
if (dayData.disabled) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
//no value selected yet
|
|
30
37
|
if (!this.value) {
|
|
31
38
|
this.value = this.displayDate?.clone() ?? this.dateApi.getValue(this.display ?? new Date());
|
|
32
39
|
}
|
|
33
40
|
//single value
|
|
34
41
|
if (!Array.isArray(this.value)) {
|
|
42
|
+
this.value.year(dayData.dateObj.year());
|
|
43
|
+
this.value.month(dayData.dateObj.month());
|
|
35
44
|
this.value.dayOfMonth(dayData.day);
|
|
45
|
+
//other month was selected
|
|
46
|
+
if (dayData.otherMonth) {
|
|
47
|
+
this.value.month(dayData.dateObj.month());
|
|
48
|
+
this.displayDate?.month(dayData.dateObj.month());
|
|
49
|
+
}
|
|
36
50
|
this.value.updateOriginal();
|
|
37
51
|
this.valueChangeSubject.next();
|
|
38
52
|
}
|
|
53
|
+
else {
|
|
54
|
+
//TODO: range
|
|
55
|
+
}
|
|
56
|
+
this.render();
|
|
57
|
+
this.changeDetector.detectChanges();
|
|
39
58
|
}
|
|
40
59
|
/**
|
|
41
60
|
* Changes displayed month to next month
|
|
42
|
-
* @param event - Event that occured
|
|
43
61
|
*/
|
|
44
|
-
nextMonth(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.displayDate?.addMonths(1);
|
|
48
|
-
// this.display(this.displayDate);
|
|
62
|
+
nextMonth() {
|
|
63
|
+
this.displayDate?.addMonths(1).updateOriginal();
|
|
64
|
+
this.render();
|
|
49
65
|
}
|
|
50
66
|
/**
|
|
51
67
|
* Changes displayed month to previous month
|
|
52
|
-
* @param event - Event that occured
|
|
53
68
|
*/
|
|
54
|
-
previousMonth(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
previousMonth() {
|
|
70
|
+
this.displayDate?.subtractMonths(1).updateOriginal();
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
//######################### protected methods #########################
|
|
74
|
+
/**
|
|
75
|
+
* Renders current day picker data
|
|
76
|
+
*/
|
|
77
|
+
render() {
|
|
78
|
+
//same month only data change
|
|
79
|
+
if (this.displayedDate && this.displayDate?.isSameMonth(this.displayedDate)) {
|
|
80
|
+
this.setActive();
|
|
81
|
+
this.updateMinMax();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.displayedDate = this.displayDate?.value;
|
|
85
|
+
this.periodData = [];
|
|
86
|
+
this.thisMonthData = [];
|
|
87
|
+
if (!this.displayDate) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const currentMonthDate = this.displayDate.value;
|
|
91
|
+
const today = this.dateApi.now().value;
|
|
92
|
+
this.displayDate
|
|
93
|
+
.startOfMonth()
|
|
94
|
+
.updateOriginal()
|
|
95
|
+
.startOfWeek();
|
|
96
|
+
do {
|
|
97
|
+
for (let x = 0; x < 7; x++) {
|
|
98
|
+
const day = this.displayDate.dayOfMonth();
|
|
99
|
+
const otherMonth = !this.displayDate.isSameMonth(currentMonthDate);
|
|
100
|
+
const data = {
|
|
101
|
+
active: false,
|
|
102
|
+
disabled: false,
|
|
103
|
+
date: this.displayDate.value,
|
|
104
|
+
otherMonth: otherMonth,
|
|
105
|
+
today: this.displayDate.isSameDay(today),
|
|
106
|
+
weekend: this.displayDate.isWeekend(),
|
|
107
|
+
day: day,
|
|
108
|
+
dateObj: this.displayDate.clone(),
|
|
109
|
+
};
|
|
110
|
+
this.periodData.push(data);
|
|
111
|
+
if (!otherMonth) {
|
|
112
|
+
this.thisMonthData.push(data);
|
|
113
|
+
}
|
|
114
|
+
this.displayDate.addDays(1);
|
|
115
|
+
}
|
|
116
|
+
} while (this.displayDate.isSameMonth(currentMonthDate));
|
|
117
|
+
this.displayDate.resetOriginal();
|
|
118
|
+
this.setActive();
|
|
119
|
+
this.updateMinMax();
|
|
120
|
+
}
|
|
121
|
+
//######################### protected methods - overrides #########################
|
|
122
|
+
/**
|
|
123
|
+
* @inheritdoc
|
|
124
|
+
*/
|
|
125
|
+
onRender() {
|
|
126
|
+
this.render();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Tests whether provided value is in same period target value
|
|
130
|
+
* @param val - Tested value
|
|
131
|
+
* @param target - Target value to be tested against
|
|
132
|
+
*/
|
|
133
|
+
isSamePeriod(val, target) {
|
|
134
|
+
return val.isSameDay(target);
|
|
59
135
|
}
|
|
60
136
|
}
|
|
61
|
-
DayPickerSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DayPickerSAComponent, deps: [
|
|
62
|
-
DayPickerSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: DayPickerSAComponent, isStandalone: true, selector: "day-picker", host: { properties: { "class.date-time-period": "true" } }, usesInheritance: true, ngImport: i0, template: "<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousMonth(
|
|
137
|
+
DayPickerSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DayPickerSAComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
138
|
+
DayPickerSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: DayPickerSAComponent, isStandalone: true, selector: "day-picker", host: { properties: { "class.date-time-period": "true" } }, usesInheritance: true, ngImport: i0, template: "<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousMonth()\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"displayDate && canScaleUp ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'monthName'}} {{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextMonth()\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div class=\"weekday\" *ngFor=\"let weekday of weekdays\">{{weekday}}</div>\r\n <div *ngFor=\"let day of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.other-month]=\"day.otherMonth\"\r\n [class.today]=\"day.today\"\r\n [class.weekend]=\"day.weekend\"\r\n [class.active]=\"day.active\"\r\n [class.disabled]=\"day.disabled\"\r\n (mousedown)=\"selectDay(day)\">{{day.day}}</div>\r\n</div>\r\n\r\n<div class=\"go-down-button\" style=\"justify-content: center; border-top: 1px solid #FFF;\" *ngIf=\"canScaleDown\">\r\n <!-- <div [class.clickable]=\"canScaleDown\" (mousedown)=\"displayDate ? goDownSubject.next(displayDate.value) : undefined\">{{timeValue?.from | dateFormat: 'time'}}</div> -->\r\n</div>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: DatePipesModule }, { kind: "pipe", type: i2.DateFormatPipe, name: "dateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
63
139
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DayPickerSAComponent, decorators: [{
|
|
64
140
|
type: Component,
|
|
65
141
|
args: [{ selector: 'day-picker', host: {
|
|
@@ -67,9 +143,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
67
143
|
}, standalone: true, imports: [
|
|
68
144
|
CommonModule,
|
|
69
145
|
DatePipesModule,
|
|
70
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousMonth(
|
|
71
|
-
}], ctorParameters: function () { return [
|
|
72
|
-
type: Inject,
|
|
73
|
-
args: [DATE_API]
|
|
74
|
-
}] }]; } });
|
|
146
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousMonth()\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"displayDate && canScaleUp ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'monthName'}} {{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextMonth()\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div class=\"weekday\" *ngFor=\"let weekday of weekdays\">{{weekday}}</div>\r\n <div *ngFor=\"let day of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.other-month]=\"day.otherMonth\"\r\n [class.today]=\"day.today\"\r\n [class.weekend]=\"day.weekend\"\r\n [class.active]=\"day.active\"\r\n [class.disabled]=\"day.disabled\"\r\n (mousedown)=\"selectDay(day)\">{{day.day}}</div>\r\n</div>\r\n\r\n<div class=\"go-down-button\" style=\"justify-content: center; border-top: 1px solid #FFF;\" *ngIf=\"canScaleDown\">\r\n <!-- <div [class.clickable]=\"canScaleDown\" (mousedown)=\"displayDate ? goDownSubject.next(displayDate.value) : undefined\">{{timeValue?.from | dateFormat: 'time'}}</div> -->\r\n</div>" }]
|
|
147
|
+
}], ctorParameters: function () { return []; } });
|
|
75
148
|
//# sourceMappingURL=dayPicker.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dayPicker.component.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTimePicker/components/dayPicker/dayPicker.component.ts","../../../../../../src/modules/dateTimePicker/components/dayPicker/dayPicker.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,MAAM,EAAC,MAAM,eAAe,C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C,KAAY;QAEhC,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;QAEpC,mCAAmC;IACvC,CAAC;;iHAhEQ,oBAAoB,kBAgBT,QAAQ;qGAhBnB,oBAAoB,yJC7BjC,65CAoBM,2CDIE,YAAY,+PACZ,eAAe;2FAIV,oBAAoB;kBAhBhC,SAAS;+BAEI,YAAY,QAGtB;wBACI,0BAA0B,EAAE,MAAM;qBACrC,cACW,IAAI,WAEhB;wBACI,YAAY;wBACZ,eAAe;qBAClB,mBACgB,uBAAuB,CAAC,MAAM;;0BAkBlC,MAAM;2BAAC,QAAQ","sourcesContent":["import {Component, ChangeDetectionStrategy, Inject} from '@angular/core';\nimport {CommonModule} from '@angular/common';\n\nimport {DateTimePicker} from '../../interfaces';\nimport {DateTimePeriodPickerBase} from '../dateTimePeriodPickerBase';\nimport {DatePipesModule} from '../../../datePipes.module';\nimport {DayData} from '../../../../legacy/picker/interfaces';\nimport {DATE_API} from '../../../../misc/tokens';\nimport {DateApi} from '../../../../services';\n\n/**\n * Component used for displaying day picker\n */\n@Component(\n{\n selector: 'day-picker',\n templateUrl: 'dayPicker.component.html',\n host:\n {\n '[class.date-time-period]': 'true',\n },\n standalone: true,\n imports:\n [\n CommonModule,\n DatePipesModule,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class DayPickerSAComponent<TDate = unknown> extends DateTimePeriodPickerBase<TDate> implements DateTimePicker<TDate>\n{\n //######################### protected properties - template bindings #########################\n\n /**\n * Names of days\n */\n protected weekdays: string[] = [];\n\n /**\n * Array of period data to be displayed\n * @internal\n */\n public periodData: DayData<TDate>[] = [];\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected dateApi: DateApi<TDate>,)\n {\n super();\n }\n\n //######################### protected methods - template bindings #########################\n\n protected selectDay(dayData: DayData): void\n {\n if(!this.value)\n {\n this.value = this.displayDate?.clone() ?? this.dateApi.getValue(this.display ?? new Date());\n }\n\n //single value\n if(!Array.isArray(this.value))\n {\n this.value.dayOfMonth(dayData.day);\n this.value.updateOriginal();\n\n this.valueChangeSubject.next();\n }\n }\n\n /**\n * Changes displayed month to next month\n * @param event - Event that occured\n */\n protected nextMonth(event: Event): void\n {\n event.preventDefault();\n event.stopPropagation();\n this.displayDate?.addMonths(1);\n\n // this.display(this.displayDate);\n }\n\n /**\n * Changes displayed month to previous month\n * @param event - Event that occured\n */\n protected previousMonth(event: Event): void\n {\n event.preventDefault();\n event.stopPropagation();\n this.displayDate?.subtractMonths(1);\n\n // this.display(this.displayDate!);\n }\n}","<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousMonth($event)\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"$event.stopPropagation(); $event.preventDefault(); displayDate ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'monthName'}} {{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextMonth($event)\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div class=\"weekday\" *ngFor=\"let weekday of weekdays\">{{weekday}}</div>\r\n <div *ngFor=\"let day of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.other-month]=\"day.otherMonth\"\r\n [class.today]=\"day.today\"\r\n [class.weekend]=\"day.weekend\"\r\n [class.active]=\"day.active\"\r\n [class.disabled]=\"day.disabled\"\r\n (click)=\"$event.stopPropagation(); $event.preventDefault(); selectDay(day)\">{{day.day}}</div>\r\n</div>\r\n\r\n<div class=\"go-down-button\" style=\"justify-content: center; border-top: 1px solid #FFF;\" *ngIf=\"canScaleDown\">\r\n <!-- <div [class.clickable]=\"canScaleDown\" (mousedown)=\"$event.stopPropagation(); $event.preventDefault(); displayDate ? goDownSubject.next(displayDate.value) : undefined\">{{timeValue?.from | dateFormat: 'time'}}</div> -->\r\n</div>"]}
|
|
1
|
+
{"version":3,"file":"dayPicker.component.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTimePicker/components/dayPicker/dayPicker.component.ts","../../../../../../src/modules/dateTimePicker/components/dayPicker/dayPicker.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAC,wBAAwB,EAAC,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;;;;AAI1D;;GAEG;AAiBH,MAAM,OAAO,oBAAsC,SAAQ,wBAA+C;IAgBtG,iEAAiE;IACjE;QAEI,KAAK,EAAE,CAAC;QAjBZ,0EAA0E;QAE1E;;WAEG;QACO,kBAAa,GAAqB,EAAE,CAAC;QAE/C,8FAA8F;QAE9F;;WAEG;QACO,aAAQ,GAAa,EAAE,CAAC;QAO9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IACjD,CAAC;IAED,2FAA2F;IAE3F;;;OAGG;IACO,SAAS,CAAC,OAAuB;QAEvC,IAAG,OAAO,CAAC,QAAQ,EACnB;YACI,OAAO;SACV;QAED,uBAAuB;QACvB,IAAG,CAAC,IAAI,CAAC,KAAK,EACd;YACI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;SAC/F;QAED,cAAc;QACd,IAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAC7B;YACI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACxC,I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AAW,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE;QAEtD,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC;QAEjC,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,mFAAmF;IAEnF;;OAEG;IACO,QAAQ;QAEd,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACO,YAAY,CAAC,GAAyB,EAAE,MAAa;QAE3D,OAAO,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;;iHAlLQ,oBAAoB;qGAApB,oBAAoB,yJC5BjC,0wCAoBM,2CDGE,YAAY,+PACZ,eAAe;2FAIV,oBAAoB;kBAhBhC,SAAS;+BAEI,YAAY,QAGtB;wBACI,0BAA0B,EAAE,MAAM;qBACrC,cACW,IAAI,WAEhB;wBACI,YAAY;wBACZ,eAAe;qBAClB,mBACgB,uBAAuB,CAAC,MAAM","sourcesContent":["import {Component, ChangeDetectionStrategy} from '@angular/core';\nimport {CommonModule} from '@angular/common';\n\nimport {DateTimePicker} from '../../interfaces';\nimport {DateTimePeriodPickerBase} from '../dateTimePeriodPickerBase';\nimport {DatePipesModule} from '../../../datePipes.module';\nimport {DayData} from '../../../../legacy/picker/interfaces';\nimport {DateApiObject} from '../../../../services';\n\n/**\n * Component used for displaying day picker\n */\n@Component(\n{\n selector: 'day-picker',\n templateUrl: 'dayPicker.component.html',\n host:\n {\n '[class.date-time-period]': 'true',\n },\n standalone: true,\n imports:\n [\n CommonModule,\n DatePipesModule,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class DayPickerSAComponent<TDate = unknown> extends DateTimePeriodPickerBase<DayData<TDate>, TDate> implements DateTimePicker<TDate>\n{\n //######################### protected properties #########################\n\n /**\n * Stored this picker month data\n */\n protected thisMonthData: DayData<TDate>[] = [];\n\n //######################### protected properties - template bindings #########################\n\n /**\n * Names of days\n */\n protected weekdays: string[] = [];\n\n //######################### constructor #########################\n constructor()\n {\n super();\n\n this.weekdays = this.dateApi.weekdaysShort();\n }\n\n //######################### protected methods - template bindings #########################\n\n /**\n * Selects day as value of date time picker\n * @param dayData - Day data that were selected\n */\n protected selectDay(dayData: DayData<TDate>): void\n {\n if(dayData.disabled)\n {\n return;\n }\n\n //no value selected yet\n if(!this.value)\n {\n this.value = this.displayDate?.clone() ?? this.dateApi.getValue(this.display ?? new Date());\n }\n\n //single value\n if(!Array.isArray(this.value))\n {\n this.value.year(dayData.dateObj.year());\n this.value.month(dayData.dateObj.month());\n this.value.dayOfMonth(dayData.day);\n\n //other month was selected\n if(dayData.otherMonth)\n {\n this.value.month(dayData.dateObj.month());\n this.displayDate?.month(dayData.dateObj.month());\n }\n\n this.value.updateOriginal();\n\n this.valueChangeSubject.next();\n }\n else\n {\n //TODO: range\n }\n\n this.render();\n this.changeDetector.detectChanges();\n }\n\n /**\n * Changes displayed month to next month\n */\n protected nextMonth(): void\n {\n this.displayDate?.addMonths(1).updateOriginal();\n\n this.render();\n }\n\n /**\n * Changes displayed month to previous month\n */\n protected previousMonth(): void\n {\n this.displayDate?.subtractMonths(1).updateOriginal();\n\n this.render();\n }\n\n //######################### protected methods #########################\n\n /**\n * Renders current day picker data\n */\n protected render(): void\n {\n //same month only data change\n if(this.displayedDate && this.displayDate?.isSameMonth(this.displayedDate))\n {\n this.setActive();\n this.updateMinMax();\n\n return;\n }\n\n this.displayedDate = this.displayDate?.value;\n this.periodData = [];\n this.thisMonthData = [];\n\n if(!this.displayDate)\n {\n return;\n }\n\n const currentMonthDate = this.displayDate.value;\n const today = this.dateApi.now().value;\n\n this.displayDate\n .startOfMonth()\n .updateOriginal()\n .startOfWeek();\n\n do\n {\n for(let x = 0; x < 7; x++)\n {\n const day = this.displayDate.dayOfMonth();\n const otherMonth = !this.displayDate.isSameMonth(currentMonthDate);\n\n const data: DayData<TDate> = \n {\n active: false,\n disabled: false,\n date: this.displayDate.value,\n otherMonth: otherMonth,\n today: this.displayDate.isSameDay(today),\n weekend: this.displayDate.isWeekend(),\n day: day,\n dateObj: this.displayDate.clone(),\n };\n\n this.periodData.push(data);\n\n if(!otherMonth)\n {\n this.thisMonthData.push(data);\n }\n\n this.displayDate.addDays(1);\n }\n }\n while(this.displayDate.isSameMonth(currentMonthDate));\n\n this.displayDate.resetOriginal();\n\n this.setActive();\n this.updateMinMax();\n }\n\n //######################### protected methods - overrides #########################\n\n /**\n * @inheritdoc\n */\n protected onRender(): void\n {\n this.render();\n }\n\n /**\n * Tests whether provided value is in same period target value\n * @param val - Tested value\n * @param target - Target value to be tested against\n */\n protected isSamePeriod(val: DateApiObject<TDate>, target: TDate): boolean\n {\n return val.isSameDay(target);\n }\n}","<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousMonth()\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"displayDate && canScaleUp ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'monthName'}} {{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextMonth()\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div class=\"weekday\" *ngFor=\"let weekday of weekdays\">{{weekday}}</div>\r\n <div *ngFor=\"let day of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.other-month]=\"day.otherMonth\"\r\n [class.today]=\"day.today\"\r\n [class.weekend]=\"day.weekend\"\r\n [class.active]=\"day.active\"\r\n [class.disabled]=\"day.disabled\"\r\n (mousedown)=\"selectDay(day)\">{{day.day}}</div>\r\n</div>\r\n\r\n<div class=\"go-down-button\" style=\"justify-content: center; border-top: 1px solid #FFF;\" *ngIf=\"canScaleDown\">\r\n <!-- <div [class.clickable]=\"canScaleDown\" (mousedown)=\"displayDate ? goDownSubject.next(displayDate.value) : undefined\">{{timeValue?.from | dateFormat: 'time'}}</div> -->\r\n</div>"]}
|
|
@@ -2,4 +2,5 @@ export * from './dateTimePeriodPickerBase';
|
|
|
2
2
|
export * from './dateTimePicker/dateTimePicker.component';
|
|
3
3
|
export * from './dateTimePicker/dateTimePicker.interface';
|
|
4
4
|
export * from './dayPicker/dayPicker.component';
|
|
5
|
+
export * from './monthPicker/monthPicker.component';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/dateTimePicker/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './dateTimePeriodPickerBase';\nexport * from './dateTimePicker/dateTimePicker.component';\nexport * from './dateTimePicker/dateTimePicker.interface';\nexport * from './dayPicker/dayPicker.component';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/dateTimePicker/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC","sourcesContent":["export * from './dateTimePeriodPickerBase';\nexport * from './dateTimePicker/dateTimePicker.component';\nexport * from './dateTimePicker/dateTimePicker.interface';\nexport * from './dayPicker/dayPicker.component';\nexport * from './monthPicker/monthPicker.component';\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Component, ChangeDetectionStrategy, Inject } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { DateTimePeriodPickerBase } from '../dateTimePeriodPickerBase';
|
|
4
|
+
import { DatePipesModule } from '../../../datePipes.module';
|
|
5
|
+
import { FORMAT_PROVIDER } from '../../../../misc/tokens';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
import * as i1 from "@angular/common";
|
|
8
|
+
import * as i2 from "../../../../pipes/dateFormat.pipe";
|
|
9
|
+
/**
|
|
10
|
+
* Component used for displaying month picker
|
|
11
|
+
*/
|
|
12
|
+
export class MonthPickerSAComponent extends DateTimePeriodPickerBase {
|
|
13
|
+
constructor(formatProvider) {
|
|
14
|
+
super();
|
|
15
|
+
this.formatProvider = formatProvider;
|
|
16
|
+
}
|
|
17
|
+
//######################### protected methods - template bindings #########################
|
|
18
|
+
/**
|
|
19
|
+
* Selects month as value of day time picker
|
|
20
|
+
* @param monthData - Month data that were selected
|
|
21
|
+
*/
|
|
22
|
+
selectMonth(monthData) {
|
|
23
|
+
if (monthData.disabled) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!this.value) {
|
|
27
|
+
this.value = this.displayDate?.clone() ?? this.dateApi.getValue(this.display ?? new Date());
|
|
28
|
+
}
|
|
29
|
+
//single value
|
|
30
|
+
if (!Array.isArray(this.value)) {
|
|
31
|
+
this.value.month(monthData.dateObj.month());
|
|
32
|
+
this.value.updateOriginal();
|
|
33
|
+
this.valueChangeSubject.next();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
//TODO: range
|
|
37
|
+
}
|
|
38
|
+
this.render();
|
|
39
|
+
this.changeDetector.detectChanges();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Changes displayed year to next year
|
|
43
|
+
*/
|
|
44
|
+
nextYear() {
|
|
45
|
+
this.displayDate?.addYears(1).updateOriginal();
|
|
46
|
+
this.render();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Changes displayed year to previous year
|
|
50
|
+
*/
|
|
51
|
+
previousYear() {
|
|
52
|
+
this.displayDate?.subtractYears(1).updateOriginal();
|
|
53
|
+
this.render();
|
|
54
|
+
}
|
|
55
|
+
//######################### protected methods #########################
|
|
56
|
+
/**
|
|
57
|
+
* Renders current day picker data
|
|
58
|
+
*/
|
|
59
|
+
render() {
|
|
60
|
+
//same year only data change
|
|
61
|
+
if (this.displayedDate && this.displayDate?.isSameYear(this.displayedDate)) {
|
|
62
|
+
this.setActive();
|
|
63
|
+
this.updateMinMax();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.displayedDate = this.displayDate?.value;
|
|
67
|
+
this.periodData = [];
|
|
68
|
+
if (!this.displayDate) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const monthOfYear = this.displayDate.startOfYear().updateOriginal();
|
|
72
|
+
for (let x = 0; x < 12; x++) {
|
|
73
|
+
this.periodData.push({
|
|
74
|
+
active: false,
|
|
75
|
+
disabled: false,
|
|
76
|
+
date: monthOfYear.value,
|
|
77
|
+
name: monthOfYear.format(this.dateApi.getFormat(this.formatProvider.monthNameShort)),
|
|
78
|
+
dateObj: monthOfYear.clone(),
|
|
79
|
+
});
|
|
80
|
+
monthOfYear.addMonths(1);
|
|
81
|
+
}
|
|
82
|
+
this.displayDate.resetOriginal();
|
|
83
|
+
this.setActive();
|
|
84
|
+
this.updateMinMax();
|
|
85
|
+
}
|
|
86
|
+
//######################### protected methods - overrides #########################
|
|
87
|
+
/**
|
|
88
|
+
* @inheritdoc
|
|
89
|
+
*/
|
|
90
|
+
onRender() {
|
|
91
|
+
this.render();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Tests whether provided value is in same period target value
|
|
95
|
+
* @param val - Tested value
|
|
96
|
+
* @param target - Target value to be tested against
|
|
97
|
+
*/
|
|
98
|
+
isSamePeriod(val, target) {
|
|
99
|
+
return val.isSameMonth(target);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
MonthPickerSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: MonthPickerSAComponent, deps: [{ token: FORMAT_PROVIDER }], target: i0.ɵɵFactoryTarget.Component });
|
|
103
|
+
MonthPickerSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: MonthPickerSAComponent, isStandalone: true, selector: "month-picker", host: { properties: { "class.date-time-period": "true" } }, usesInheritance: true, ngImport: i0, template: "<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousYear()\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"displayDate && canScaleUp ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextYear()\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div *ngFor=\"let month of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.active]=\"month.active\"\r\n [class.disabled]=\"month.disabled\"\r\n (mousedown)=\"canScaleDown && displayDate ? scaleDownSubject.next(month.dateObj.value) : selectMonth(month)\">{{month.name}}</div>\r\n</div>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "ngmodule", type: DatePipesModule }, { kind: "pipe", type: i2.DateFormatPipe, name: "dateFormat" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
104
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: MonthPickerSAComponent, decorators: [{
|
|
105
|
+
type: Component,
|
|
106
|
+
args: [{ selector: 'month-picker', host: {
|
|
107
|
+
'[class.date-time-period]': 'true',
|
|
108
|
+
}, standalone: true, imports: [
|
|
109
|
+
CommonModule,
|
|
110
|
+
DatePipesModule,
|
|
111
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousYear()\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"displayDate && canScaleUp ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextYear()\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div *ngFor=\"let month of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.active]=\"month.active\"\r\n [class.disabled]=\"month.disabled\"\r\n (mousedown)=\"canScaleDown && displayDate ? scaleDownSubject.next(month.dateObj.value) : selectMonth(month)\">{{month.name}}</div>\r\n</div>" }]
|
|
112
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
113
|
+
type: Inject,
|
|
114
|
+
args: [FORMAT_PROVIDER]
|
|
115
|
+
}] }]; } });
|
|
116
|
+
//# sourceMappingURL=monthPicker.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monthPicker.component.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTimePicker/components/monthPicker/monthPicker.component.ts","../../../../../../src/modules/dateTimePicker/components/monthPicker/monthPicker.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAC,wBAAwB,EAAC,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAG1D,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;;;;AAGxD;;GAEG;AAiBH,MAAM,OAAO,sBAAwC,SAAQ,wBAAiD;IAE1G,YAA+C,cAA8B;QAEzE,KAAK,EAAE,CAAC;QAFmC,mBAAc,GAAd,cAAc,CAAgB;IAG7E,CAAC;IAED,2FAA2F;IAE3F;;;OAGG;IACO,WAAW,CAAC,SAA2B;QAE7C,IAAG,SAAS,CAAC,QAAQ,EACrB;YACI,OAAO;SACV;QAED,IAAG,CAAC,IAAI,CAAC,KAAK,E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DetectionStrategy, Inject} from '@angular/core';\nimport {CommonModule} from '@angular/common';\n\nimport {DateTimePicker} from '../../interfaces';\nimport {DateTimePeriodPickerBase} from '../dateTimePeriodPickerBase';\nimport {DatePipesModule} from '../../../datePipes.module';\nimport {MonthData} from '../../../../legacy/picker/interfaces';\nimport {DateApiObject} from '../../../../services';\nimport {FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {FormatProvider} from '../../../../interfaces';\n\n/**\n * Component used for displaying month picker\n */\n@Component(\n{\n selector: 'month-picker',\n templateUrl: 'monthPicker.component.html',\n host:\n {\n '[class.date-time-period]': 'true',\n },\n standalone: true,\n imports:\n [\n CommonModule,\n DatePipesModule,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class MonthPickerSAComponent<TDate = unknown> extends DateTimePeriodPickerBase<MonthData<TDate>, TDate> implements DateTimePicker<TDate>\n{\n constructor(@Inject(FORMAT_PROVIDER) protected formatProvider: FormatProvider,)\n {\n super();\n }\n\n //######################### protected methods - template bindings #########################\n\n /**\n * Selects month as value of day time picker\n * @param monthData - Month data that were selected\n */\n protected selectMonth(monthData: MonthData<TDate>): void\n {\n if(monthData.disabled)\n {\n return;\n }\n\n if(!this.value)\n {\n this.value = this.displayDate?.clone() ?? this.dateApi.getValue(this.display ?? new Date());\n }\n\n //single value\n if(!Array.isArray(this.value))\n {\n this.value.month(monthData.dateObj.month());\n this.value.updateOriginal();\n\n this.valueChangeSubject.next();\n }\n else\n {\n //TODO: range\n }\n\n this.render();\n this.changeDetector.detectChanges();\n }\n\n /**\n * Changes displayed year to next year\n */\n protected nextYear(): void\n {\n this.displayDate?.addYears(1).updateOriginal();\n\n this.render();\n }\n\n /**\n * Changes displayed year to previous year\n */\n protected previousYear(): void\n {\n this.displayDate?.subtractYears(1).updateOriginal();\n\n this.render();\n }\n\n //######################### protected methods #########################\n\n /**\n * Renders current day picker data\n */\n protected render(): void\n {\n //same year only data change\n if(this.displayedDate && this.displayDate?.isSameYear(this.displayedDate))\n {\n this.setActive();\n this.updateMinMax();\n\n return;\n }\n\n this.displayedDate = this.displayDate?.value;\n this.periodData = [];\n\n if(!this.displayDate)\n {\n return;\n }\n\n const monthOfYear = this.displayDate.startOfYear().updateOriginal();\n\n for(let x = 0; x < 12; x++)\n {\n this.periodData.push(\n {\n active: false,\n disabled: false,\n date: monthOfYear.value,\n name: monthOfYear.format(this.dateApi.getFormat(this.formatProvider.monthNameShort)),\n dateObj: monthOfYear.clone(),\n });\n\n monthOfYear.addMonths(1);\n }\n\n this.displayDate.resetOriginal();\n \n this.setActive();\n this.updateMinMax();\n }\n\n //######################### protected methods - overrides #########################\n\n /**\n * @inheritdoc\n */\n protected onRender(): void\n {\n this.render();\n }\n\n /**\n * Tests whether provided value is in same period target value\n * @param val - Tested value\n * @param target - Target value to be tested against\n */\n protected isSamePeriod(val: DateApiObject<TDate>, target: TDate): boolean\n {\n return val.isSameMonth(target);\n }\n}","<div class=\"period\">\r\n <div class=\"fas fa-angle-left clickable\" (mousedown)=\"previousYear()\"></div>\r\n <div class=\"period-value\" [class.clickable]=\"canScaleUp\" (mousedown)=\"displayDate && canScaleUp ? scaleUpSubject.next(displayDate.value) : undefined\">{{displayDate?.value | dateFormat: 'year'}}</div>\r\n <div class=\"fas fa-angle-right clickable\" (mousedown)=\"nextYear()\"></div>\r\n</div>\r\n\r\n<div class=\"period-data\">\r\n <div *ngFor=\"let month of periodData\"\r\n class=\"period-datum clickable\"\r\n [class.active]=\"month.active\"\r\n [class.disabled]=\"month.disabled\"\r\n (mousedown)=\"canScaleDown && displayDate ? scaleDownSubject.next(month.dateObj.value) : selectMonth(month)\">{{month.name}}</div>\r\n</div>"]}
|
package/es2020/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js
CHANGED
|
@@ -3,10 +3,11 @@ import { Directive, ElementRef, Inject, Input, Optional, ViewContainerRef } from
|
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import { POSITION, applyPositionResult, PositionPlacement } from '@anglr/common';
|
|
5
5
|
import { extend, nameof, isDescendant, BindThis } from '@jscrpt/common';
|
|
6
|
-
import { lastValueFrom
|
|
6
|
+
import { lastValueFrom } from 'rxjs';
|
|
7
7
|
import { DATE_TIME_INPUT } from '../../../../misc/tokens';
|
|
8
8
|
import { DateTimePickerComponent } from '../../components';
|
|
9
9
|
import { DATE_TIME_PICKER_DIRECTIVE_OPTIONS } from '../../misc/tokens';
|
|
10
|
+
import { DateTimeBase } from '../../../dateTime/directives';
|
|
10
11
|
import * as i0 from "@angular/core";
|
|
11
12
|
/**
|
|
12
13
|
* Default options for date time picker directive
|
|
@@ -15,16 +16,19 @@ const defaultOptions = {
|
|
|
15
16
|
absolute: true,
|
|
16
17
|
alwaysVisible: false,
|
|
17
18
|
closeOnValueSelect: true,
|
|
19
|
+
closeOnBlur: true,
|
|
18
20
|
disabled: false,
|
|
19
21
|
positionOptions: PositionPlacement.BottomStart,
|
|
20
22
|
showOnFocus: true,
|
|
23
|
+
pickerCssClass: null,
|
|
21
24
|
};
|
|
22
25
|
/**
|
|
23
26
|
* Directive that is used for displaying and attaching date time picker
|
|
24
27
|
*/
|
|
25
|
-
export class DateTimePickerDirective {
|
|
28
|
+
export class DateTimePickerDirective extends DateTimeBase {
|
|
26
29
|
//######################### constructor #########################
|
|
27
30
|
constructor(viewContainer, element, input, document, position, options) {
|
|
31
|
+
super();
|
|
28
32
|
this.viewContainer = viewContainer;
|
|
29
33
|
this.element = element;
|
|
30
34
|
this.input = input;
|
|
@@ -35,10 +39,6 @@ export class DateTimePickerDirective {
|
|
|
35
39
|
* Indication whether is value changes disabled
|
|
36
40
|
*/
|
|
37
41
|
this.valueChangeDisabled = false;
|
|
38
|
-
/**
|
|
39
|
-
* Subscriptions created during initialization
|
|
40
|
-
*/
|
|
41
|
-
this.initSubscriptions = new Subscription();
|
|
42
42
|
this.ɵWithPickerOptions = extend(true, {}, defaultOptions, options);
|
|
43
43
|
}
|
|
44
44
|
//######################### public properties - inputs #########################
|
|
@@ -68,12 +68,18 @@ export class DateTimePickerDirective {
|
|
|
68
68
|
this.showPicker();
|
|
69
69
|
}
|
|
70
70
|
}));
|
|
71
|
+
this.initSubscriptions.add(this.input.blur.subscribe(() => {
|
|
72
|
+
if (this.withPickerOptions.closeOnBlur) {
|
|
73
|
+
this.hidePicker();
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
71
76
|
}
|
|
72
77
|
//######################### public methods - implementation of OnDestroy #########################
|
|
73
78
|
/**
|
|
74
79
|
* Called when component is destroyed
|
|
75
80
|
*/
|
|
76
81
|
ngOnDestroy() {
|
|
82
|
+
super.ngOnDestroy();
|
|
77
83
|
this.hidePicker();
|
|
78
84
|
this.initSubscriptions.unsubscribe();
|
|
79
85
|
}
|
|
@@ -97,17 +103,27 @@ export class DateTimePickerDirective {
|
|
|
97
103
|
this.input.value = this.component.value;
|
|
98
104
|
this.input.valueChange.emit();
|
|
99
105
|
this.valueChangeDisabled = false;
|
|
106
|
+
if (this.ɵWithPickerOptions.closeOnValueSelect) {
|
|
107
|
+
this.hidePicker();
|
|
108
|
+
}
|
|
100
109
|
}
|
|
101
110
|
});
|
|
102
111
|
this.document.addEventListener('click', this.handleClickOutside);
|
|
112
|
+
this.componentElement.addEventListener('mousedown', this.handleClickInside);
|
|
113
|
+
if (this.ɵWithPickerOptions.pickerCssClass) {
|
|
114
|
+
this.componentElement.classList.add(this.ɵWithPickerOptions.pickerCssClass);
|
|
115
|
+
}
|
|
103
116
|
const result = await lastValueFrom(this.position.placeElement(this.componentElement, this.element.nativeElement, {
|
|
104
117
|
placement: this.withPickerOptions.positionOptions,
|
|
105
118
|
}));
|
|
106
119
|
applyPositionResult(result);
|
|
107
120
|
this.setPickerValue();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
this.componentRef.setInput(nameof('options'), this.pickerOptions);
|
|
122
|
+
this.componentRef.setInput(nameof('valueFormat'), this.dateTimeData.valueFormat);
|
|
123
|
+
this.componentRef.setInput(nameof('format'), this.dateTimeData.format);
|
|
124
|
+
this.componentRef.setInput(nameof('customFormat'), this.dateTimeData.customFormat);
|
|
125
|
+
this.componentRef.setInput(nameof('minDateTime'), this.dateTimeData.minDateTime);
|
|
126
|
+
this.componentRef.setInput(nameof('maxDateTime'), this.dateTimeData.maxDateTime);
|
|
111
127
|
this.componentRef.changeDetectorRef.detectChanges();
|
|
112
128
|
}
|
|
113
129
|
/**
|
|
@@ -117,6 +133,7 @@ export class DateTimePickerDirective {
|
|
|
117
133
|
if (this.withPickerOptions.alwaysVisible) {
|
|
118
134
|
return;
|
|
119
135
|
}
|
|
136
|
+
this.componentElement?.removeEventListener('mousedown', this.handleClickInside);
|
|
120
137
|
this.valueChangeSubscription?.unsubscribe();
|
|
121
138
|
this.valueChangeSubscription = null;
|
|
122
139
|
this.component = null;
|
|
@@ -153,15 +170,50 @@ export class DateTimePickerDirective {
|
|
|
153
170
|
this.hidePicker();
|
|
154
171
|
}
|
|
155
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Handles clicking inside of picker element
|
|
175
|
+
* @param event - Event that occured
|
|
176
|
+
*/
|
|
177
|
+
handleClickInside(event) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
event.stopPropagation();
|
|
180
|
+
}
|
|
181
|
+
//######################### protected methods - overrides #########################
|
|
182
|
+
/**
|
|
183
|
+
* @inheritdoc
|
|
184
|
+
*/
|
|
185
|
+
onMaxDateTimeChange() {
|
|
186
|
+
if (!this.componentRef) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.componentRef.setInput(nameof('maxDateTime'), this.dateTimeData.maxDateTime);
|
|
190
|
+
this.componentRef.changeDetectorRef.detectChanges();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @inheritdoc
|
|
194
|
+
*/
|
|
195
|
+
onMinDateTimeChange() {
|
|
196
|
+
if (!this.componentRef) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.componentRef.setInput(nameof('minDateTime'), this.dateTimeData.minDateTime);
|
|
200
|
+
this.componentRef.changeDetectorRef.detectChanges();
|
|
201
|
+
}
|
|
156
202
|
}
|
|
157
203
|
DateTimePickerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimePickerDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.ElementRef }, { token: DATE_TIME_INPUT }, { token: DOCUMENT }, { token: POSITION }, { token: DATE_TIME_PICKER_DIRECTIVE_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
158
|
-
DateTimePickerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimePickerDirective, selector: "[dateTime][withPicker]", inputs: { withPickerOptions: "withPickerOptions" }, exportAs: ["dateTimePicker"], ngImport: i0 });
|
|
204
|
+
DateTimePickerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimePickerDirective, selector: "[dateTime][withPicker]", inputs: { withPickerOptions: "withPickerOptions", pickerOptions: "pickerOptions" }, exportAs: ["dateTimePicker"], usesInheritance: true, ngImport: i0 });
|
|
159
205
|
__decorate([
|
|
160
206
|
BindThis,
|
|
161
207
|
__metadata("design:type", Function),
|
|
162
208
|
__metadata("design:paramtypes", [MouseEvent]),
|
|
163
209
|
__metadata("design:returntype", void 0)
|
|
164
210
|
], DateTimePickerDirective.prototype, "handleClickOutside", null);
|
|
211
|
+
__decorate([
|
|
212
|
+
BindThis,
|
|
213
|
+
__metadata("design:type", Function),
|
|
214
|
+
__metadata("design:paramtypes", [MouseEvent]),
|
|
215
|
+
__metadata("design:returntype", void 0)
|
|
216
|
+
], DateTimePickerDirective.prototype, "handleClickInside", null);
|
|
165
217
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimePickerDirective, decorators: [{
|
|
166
218
|
type: Directive,
|
|
167
219
|
args: [{
|
|
@@ -184,5 +236,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
184
236
|
type: Optional
|
|
185
237
|
}] }]; }, propDecorators: { withPickerOptions: [{
|
|
186
238
|
type: Input
|
|
187
|
-
}],
|
|
239
|
+
}], pickerOptions: [{
|
|
240
|
+
type: Input
|
|
241
|
+
}], handleClickOutside: [], handleClickInside: [] } });
|
|
188
242
|
//# sourceMappingURL=dateTimePicker.directive.js.map
|
package/es2020/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTimePicker.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAe,SAAS,EAAE,UAAU,EAAmB,MAAM,EAAE,KAAK,EAAqB,QAAQ,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACjJ,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAW,QAAQ,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,MAAM,CAAC;AAGjD,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAC,kCAAkC,EAAC,MAAM,mBAAmB,CAAC;;AAErE;;GAEG;AACH,MAAM,cAAc,GACpB;IACI,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,KAAK;IACpB,kBAAkB,EAAE,IAAI;IACxB,QAAQ,EAAE,KAAK;IACf,eAAe,EAAE,iBAAiB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pB;YACI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAA0B,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1F;IACL,CAAC;IAED;;;OAGG;IAEO,kBAAkB,CAAC,KAAiB;QAE1C,IAAG,CAAC,IAAI,CAAC,gBAAgB,EACzB;YACI,OAAO;SACV;QAED,IAAG,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,MAAM;YACrC,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,MAAqB,CAAC;YACjE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM;gBAClC,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAqB,CAAC,CAAC,CAAC,EAC5F;YACI,IAAI,CAAC,UAAU,EAAE,CAAC;SACrB;IACL,CAAC;;oHAnNQ,uBAAuB,4EAyDZ,eAAe,aACf,QAAQ,aACR,QAAQ,aACR,kCAAkC;wGA5D7C,uBAAuB;;IAoM/B,QAAQ;;qCAC2B,UAAU;;iEAc7C;2FAnNQ,uBAAuB;kBALnC,SAAS;mBACV;oBACI,QAAQ,EAAE,wBAAwB;oBAClC,QAAQ,EAAE,gBAAgB;iBAC7B;;0BA0DgB,MAAM;2BAAC,eAAe;;0BACtB,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,kCAAkC;;0BAAG,QAAQ;4CAftD,iBAAiB;sBAD3B,KAAK;gBAyJI,kBAAkB","sourcesContent":["import {ComponentRef, Directive, ElementRef, EmbeddedViewRef, Inject, Input, OnDestroy, OnInit, Optional, ViewContainerRef} from '@angular/core';\nimport {DOCUMENT} from '@angular/common';\nimport {Position, POSITION, applyPositionResult, PositionPlacement} from '@anglr/common';\nimport {extend, nameof, isDescendant, BindThis} from '@jscrpt/common';\nimport {lastValueFrom, Subscription} from 'rxjs';\n\nimport {DateTimeInput} from '../../../../interfaces';\nimport {DATE_TIME_INPUT} from '../../../../misc/tokens';\nimport {DateTimePickerComponent} from '../../components';\nimport {DateTimePickerDirectiveOptions} from './dateTimePicker.interface';\nimport {DATE_TIME_PICKER_DIRECTIVE_OPTIONS} from '../../misc/tokens';\n\n/**\n * Default options for date time picker directive\n */\nconst defaultOptions: DateTimePickerDirectiveOptions =\n{\n absolute: true,\n alwaysVisible: false,\n closeOnValueSelect: true,\n disabled: false,\n positionOptions: PositionPlacement.BottomStart,\n showOnFocus: true,\n};\n\n/**\n * Directive that is used for displaying and attaching date time picker\n */\n@Directive(\n{\n selector: '[dateTime][withPicker]',\n exportAs: 'dateTimePicker'\n})\nexport class DateTimePickerDirective<TDate = unknown> implements OnInit, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Indication whether is value changes disabled\n */\n protected valueChangeDisabled: boolean = false;\n\n /**\n * Options for date time picker directive\n */\n protected ɵWithPickerOptions: DateTimePickerDirectiveOptions;\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n /**\n * Date time picker component reference\n */\n protected componentRef: ComponentRef<DateTimePickerComponent<TDate>>|undefined|null;\n\n /**\n * Instance of date time picker component\n */\n protected component: DateTimePickerComponent<TDate>|undefined|null;\n\n /**\n * Instance of date time picker element\n */\n protected componentElement: HTMLElement|undefined|null;\n\n /**\n * Subscription for value changes in picker\n */\n protected valueChangeSubscription: Subscription|undefined|null;\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets options for date time picker directive\n */\n @Input()\n public get withPickerOptions(): Partial<DateTimePickerDirectiveOptions>\n {\n return this.ɵWithPickerOptions;\n }\n public set withPickerOptions(value: Partial<DateTimePickerDirectiveOptions>)\n {\n this.ɵWithPickerOptions = extend(true, {}, this.ɵWithPickerOptions, value);\n }\n\n //######################### constructor #########################\n constructor(protected viewContainer: ViewContainerRef,\n protected element: ElementRef<HTMLElement>,\n @Inject(DATE_TIME_INPUT) protected input: DateTimeInput<TDate>,\n @Inject(DOCUMENT) protected document: Document,\n @Inject(POSITION) protected position: Position,\n @Inject(DATE_TIME_PICKER_DIRECTIVE_OPTIONS) @Optional() options?: DateTimePickerDirectiveOptions,)\n {\n this.ɵWithPickerOptions = extend(true, {}, defaultOptions, options);\n }\n\n //######################### public methods - implementation of OnInit #########################\n\n /**\n * Initialize component\n */\n public async ngOnInit(): Promise<void>\n {\n if(this.withPickerOptions.alwaysVisible)\n {\n this.showPicker();\n }\n\n this.initSubscriptions.add(this.input.valueChange.subscribe(() =>\n {\n this.setPickerValue();\n this.componentRef?.changeDetectorRef.detectChanges();\n }));\n\n this.initSubscriptions.add(this.input.focus.subscribe(() =>\n {\n if(this.withPickerOptions.showOnFocus)\n {\n this.showPicker();\n }\n }));\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n\n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.hidePicker();\n this.initSubscriptions.unsubscribe();\n }\n\n //######################### public methods #########################\n\n /**\n * Hides date time picker\n */\n public async showPicker(): Promise<void>\n {\n if(this.withPickerOptions.disabled || this.componentRef)\n {\n return;\n }\n\n this.componentRef = this.viewContainer.createComponent(DateTimePickerComponent<TDate>);\n this.componentElement = (this.componentRef?.hostView as EmbeddedViewRef<DateTimePickerComponent<TDate>>).rootNodes[0] as HTMLElement;\n this.component = this.componentRef.instance;\n\n if(this.withPickerOptions.absolute)\n {\n this.document.body.append(this.componentElement);\n }\n\n this.valueChangeSubscription = this.component.valueChange.subscribe(() =>\n {\n if(this.component)\n {\n this.valueChangeDisabled = true;\n this.input.value = this.component.value;\n this.input.valueChange.emit();\n this.valueChangeDisabled = false;\n }\n });\n\n this.document.addEventListener('click', this.handleClickOutside);\n\n const result = await lastValueFrom(this.position.placeElement(this.componentElement, this.element.nativeElement,\n {\n placement: this.withPickerOptions.positionOptions,\n }));\n\n applyPositionResult(result);\n this.setPickerValue();\n // this.componentRef.setInput(nameof<DateTimePickerComponent>('valueFormat'), this.input.);\n // this.componentRef.setInput(nameof<DateTimePickerComponent>('value'), this.input.value);\n // this.componentRef.setInput(nameof<DateTimePickerComponent>('value'), this.input.value);\n this.componentRef.changeDetectorRef.detectChanges();\n }\n\n /**\n * Shows date time picker\n */\n public hidePicker(): void\n {\n if(this.withPickerOptions.alwaysVisible)\n {\n return;\n }\n\n this.valueChangeSubscription?.unsubscribe();\n this.valueChangeSubscription = null;\n\n this.component = null;\n\n this.componentRef?.destroy();\n this.componentRef = null;\n\n this.componentElement?.remove();\n this.componentElement = null;\n\n this.document.removeEventListener('click', this.handleClickOutside);\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets all picker value\n */\n protected setPickerValue(): void\n {\n if(this.valueChangeDisabled)\n {\n return;\n }\n\n if(this.componentRef)\n {\n this.componentRef.setInput(nameof<DateTimePickerComponent>('value'), this.input.value);\n }\n }\n\n /**\n * Handles clicking outside of picker\n * @param event - Event that occured\n */\n @BindThis\n protected handleClickOutside(event: MouseEvent): void\n {\n if(!this.componentElement)\n {\n return;\n }\n\n if(this.componentElement != event.target &&\n !isDescendant(this.componentElement, event.target as HTMLElement) &&\n (!this.input.element || (this.input.element != event.target &&\n !isDescendant(this.input.element, event.target as HTMLElement))))\n {\n this.hidePicker();\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"dateTimePicker.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAe,SAAS,EAAE,UAAU,EAAmB,MAAM,EAAE,KAAK,EAAqB,QAAQ,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACjJ,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAW,QAAQ,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO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kB,MAqBlB,iBAAiB","sourcesContent":["import {ComponentRef, Directive, ElementRef, EmbeddedViewRef, Inject, Input, OnDestroy, OnInit, Optional, ViewContainerRef} from '@angular/core';\nimport {DOCUMENT} from '@angular/common';\nimport {Position, POSITION, applyPositionResult, PositionPlacement} from '@anglr/common';\nimport {extend, nameof, isDescendant, BindThis} from '@jscrpt/common';\nimport {lastValueFrom, Subscription} from 'rxjs';\n\nimport {DateTimeInput} from '../../../../interfaces';\nimport {DATE_TIME_INPUT} from '../../../../misc/tokens';\nimport {DateTimePickerComponent} from '../../components';\nimport {DateTimePickerOptions} from '../../components/dateTimePicker/dateTimePicker.interface';\nimport {DateTimePickerDirectiveOptions} from './dateTimePicker.interface';\nimport {DATE_TIME_PICKER_DIRECTIVE_OPTIONS} from '../../misc/tokens';\nimport {DateTimeBase} from '../../../dateTime/directives';\n\n/**\n * Default options for date time picker directive\n */\nconst defaultOptions: DateTimePickerDirectiveOptions =\n{\n absolute: true,\n alwaysVisible: false,\n closeOnValueSelect: true,\n closeOnBlur: true,\n disabled: false,\n positionOptions: PositionPlacement.BottomStart,\n showOnFocus: true,\n pickerCssClass: null,\n};\n\n/**\n * Directive that is used for displaying and attaching date time picker\n */\n@Directive(\n{\n selector: '[dateTime][withPicker]',\n exportAs: 'dateTimePicker'\n})\nexport class DateTimePickerDirective<TDate = unknown> extends DateTimeBase<TDate> implements OnInit, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Indication whether is value changes disabled\n */\n protected valueChangeDisabled: boolean = false;\n\n /**\n * Options for date time picker directive\n */\n protected ɵWithPickerOptions: DateTimePickerDirectiveOptions;\n\n /**\n * Date time picker component reference\n */\n protected componentRef: ComponentRef<DateTimePickerComponent<TDate>>|undefined|null;\n\n /**\n * Instance of date time picker component\n */\n protected component: DateTimePickerComponent<TDate>|undefined|null;\n\n /**\n * Instance of date time picker element\n */\n protected componentElement: HTMLElement|undefined|null;\n\n /**\n * Subscription for value changes in picker\n */\n protected valueChangeSubscription: Subscription|undefined|null;\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets options for date time picker directive\n */\n @Input()\n public get withPickerOptions(): Partial<DateTimePickerDirectiveOptions>\n {\n return this.ɵWithPickerOptions;\n }\n public set withPickerOptions(value: Partial<DateTimePickerDirectiveOptions>)\n {\n this.ɵWithPickerOptions = extend(true, {}, this.ɵWithPickerOptions, value);\n }\n\n /**\n * Options for date time picker component\n */\n @Input()\n public pickerOptions: Partial<DateTimePickerOptions<TDate>>|undefined|null;\n\n //######################### constructor #########################\n constructor(protected viewContainer: ViewContainerRef,\n protected element: ElementRef<HTMLElement>,\n @Inject(DATE_TIME_INPUT) protected input: DateTimeInput<TDate>,\n @Inject(DOCUMENT) protected document: Document,\n @Inject(POSITION) protected position: Position,\n\n @Inject(DATE_TIME_PICKER_DIRECTIVE_OPTIONS) @Optional() options?: DateTimePickerDirectiveOptions,)\n {\n super();\n\n this.ɵWithPickerOptions = extend(true, {}, defaultOptions, options);\n }\n\n //######################### public methods - implementation of OnInit #########################\n\n /**\n * Initialize component\n */\n public async ngOnInit(): Promise<void>\n {\n if(this.withPickerOptions.alwaysVisible)\n {\n this.showPicker();\n }\n\n this.initSubscriptions.add(this.input.valueChange.subscribe(() =>\n {\n this.setPickerValue();\n this.componentRef?.changeDetectorRef.detectChanges();\n }));\n\n this.initSubscriptions.add(this.input.focus.subscribe(() =>\n {\n if(this.withPickerOptions.showOnFocus)\n {\n this.showPicker();\n }\n }));\n\n this.initSubscriptions.add(this.input.blur.subscribe(() =>\n {\n if(this.withPickerOptions.closeOnBlur)\n {\n this.hidePicker();\n }\n }));\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n\n /**\n * Called when component is destroyed\n */\n public override ngOnDestroy(): void\n {\n super.ngOnDestroy();\n\n this.hidePicker();\n this.initSubscriptions.unsubscribe();\n }\n\n //######################### public methods #########################\n\n /**\n * Hides date time picker\n */\n public async showPicker(): Promise<void>\n {\n if(this.withPickerOptions.disabled || this.componentRef)\n {\n return;\n }\n\n this.componentRef = this.viewContainer.createComponent(DateTimePickerComponent<TDate>);\n this.componentElement = (this.componentRef?.hostView as EmbeddedViewRef<DateTimePickerComponent<TDate>>).rootNodes[0] as HTMLElement;\n this.component = this.componentRef.instance;\n\n if(this.withPickerOptions.absolute)\n {\n this.document.body.append(this.componentElement);\n }\n\n this.valueChangeSubscription = this.component.valueChange.subscribe(() =>\n {\n if(this.component)\n {\n this.valueChangeDisabled = true;\n this.input.value = this.component.value;\n this.input.valueChange.emit();\n this.valueChangeDisabled = false;\n\n if(this.ɵWithPickerOptions.closeOnValueSelect)\n {\n this.hidePicker();\n }\n }\n });\n\n this.document.addEventListener('click', this.handleClickOutside);\n this.componentElement.addEventListener('mousedown', this.handleClickInside);\n\n if(this.ɵWithPickerOptions.pickerCssClass)\n {\n this.componentElement.classList.add(this.ɵWithPickerOptions.pickerCssClass);\n }\n\n const result = await lastValueFrom(this.position.placeElement(this.componentElement, this.element.nativeElement,\n {\n placement: this.withPickerOptions.positionOptions,\n }));\n\n applyPositionResult(result);\n this.setPickerValue();\n this.componentRef.setInput(nameof<DateTimePickerComponent>('options'), this.pickerOptions);\n this.componentRef.setInput(nameof<DateTimePickerComponent>('valueFormat'), this.dateTimeData.valueFormat);\n this.componentRef.setInput(nameof<DateTimePickerComponent>('format'), this.dateTimeData.format);\n this.componentRef.setInput(nameof<DateTimePickerComponent>('customFormat'), this.dateTimeData.customFormat);\n this.componentRef.setInput(nameof<DateTimePickerComponent>('minDateTime'), this.dateTimeData.minDateTime);\n this.componentRef.setInput(nameof<DateTimePickerComponent>('maxDateTime'), this.dateTimeData.maxDateTime);\n this.componentRef.changeDetectorRef.detectChanges();\n }\n\n /**\n * Shows date time picker\n */\n public hidePicker(): void\n {\n if(this.withPickerOptions.alwaysVisible)\n {\n return;\n }\n \n this.componentElement?.removeEventListener('mousedown', this.handleClickInside);\n \n this.valueChangeSubscription?.unsubscribe();\n this.valueChangeSubscription = null;\n \n this.component = null;\n\n this.componentRef?.destroy();\n this.componentRef = null;\n\n this.componentElement?.remove();\n this.componentElement = null;\n\n this.document.removeEventListener('click', this.handleClickOutside);\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets all picker value\n */\n protected setPickerValue(): void\n {\n if(this.valueChangeDisabled)\n {\n return;\n }\n\n if(this.componentRef)\n {\n this.componentRef.setInput(nameof<DateTimePickerComponent>('value'), this.input.value);\n }\n }\n\n /**\n * Handles clicking outside of picker\n * @param event - Event that occured\n */\n @BindThis\n protected handleClickOutside(event: MouseEvent): void\n {\n if(!this.componentElement)\n {\n return;\n }\n\n if(this.componentElement != event.target &&\n !isDescendant(this.componentElement, event.target as HTMLElement) &&\n (!this.input.element || (this.input.element != event.target &&\n !isDescendant(this.input.element, event.target as HTMLElement))))\n {\n this.hidePicker();\n }\n }\n\n /**\n * Handles clicking inside of picker element\n * @param event - Event that occured\n */\n @BindThis\n protected handleClickInside(event: MouseEvent): void\n {\n event.preventDefault();\n event.stopPropagation();\n }\n\n //######################### protected methods - overrides #########################\n\n /**\n * @inheritdoc\n */\n protected override onMaxDateTimeChange(): void\n {\n if(!this.componentRef)\n {\n return;\n }\n\n this.componentRef.setInput(nameof<DateTimePickerComponent>('maxDateTime'), this.dateTimeData.maxDateTime);\n this.componentRef.changeDetectorRef.detectChanges();\n }\n\n /**\n * @inheritdoc\n */\n protected override onMinDateTimeChange(): void\n {\n if(!this.componentRef)\n {\n return;\n }\n\n this.componentRef.setInput(nameof<DateTimePickerComponent>('minDateTime'), this.dateTimeData.minDateTime);\n this.componentRef.changeDetectorRef.detectChanges();\n }\n}"]}
|