@anglr/datetime 8.1.0 → 9.0.0-beta.20241007050425
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 +68 -1
- package/date-fns/src/services/dateFnsDateApi.service.d.ts +62 -130
- package/date-fns/src/services/dateFnsDateApi.service.d.ts.map +1 -1
- package/es2022/date-fns/src/services/dateFnsDateApi.service.js +71 -143
- package/es2022/date-fns/src/services/dateFnsDateApi.service.js.map +1 -1
- package/es2022/moment/src/services/momentDateApi.service.js +64 -140
- package/es2022/moment/src/services/momentDateApi.service.js.map +1 -1
- package/es2022/src/directives/buttonDateTimeInput/buttonDateTimeInput.directive.js +17 -30
- package/es2022/src/directives/buttonDateTimeInput/buttonDateTimeInput.directive.js.map +1 -1
- package/es2022/src/directives/datePickerInput/datePickerInput.directive.js +9 -9
- package/es2022/src/directives/datePickerInput/datePickerInput.directive.js.map +1 -1
- package/es2022/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js +16 -26
- package/es2022/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js.map +1 -1
- package/es2022/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js +8 -8
- package/es2022/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js.map +1 -1
- package/es2022/src/directives/simpleDatePickerInput/simpleDatePickerInput.directive.js +9 -9
- package/es2022/src/directives/simpleDatePickerInput/simpleDatePickerInput.directive.js.map +1 -1
- package/es2022/src/directives/simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive.js +7 -11
- package/es2022/src/directives/simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive.js.map +1 -1
- package/es2022/src/directives/simpleDateTimePickerInput/simpleDateTimePickerInput.directive.js +8 -8
- package/es2022/src/directives/simpleDateTimePickerInput/simpleDateTimePickerInput.directive.js.map +1 -1
- package/es2022/src/directives/withNow/withNow.directive.js +11 -11
- package/es2022/src/directives/withNow/withNow.directive.js.map +1 -1
- package/es2022/src/directives/withTime/withTime.directive.js +10 -10
- package/es2022/src/directives/withTime/withTime.directive.js.map +1 -1
- package/es2022/src/directives/withToday/withToday.directive.js +11 -11
- package/es2022/src/directives/withToday/withToday.directive.js.map +1 -1
- package/es2022/src/interfaces/dateTimeInput/dateTimeInput.interface.js.map +1 -1
- package/es2022/src/misc/enums.js +8 -4
- package/es2022/src/misc/enums.js.map +1 -1
- package/es2022/src/misc/utils.js +7 -6
- package/es2022/src/misc/utils.js.map +1 -1
- package/es2022/src/misc/validators.js.map +1 -1
- package/es2022/src/modules/calendar/components/monthCalendar/monthCalendar.component.js +40 -68
- package/es2022/src/modules/calendar/components/monthCalendar/monthCalendar.component.js.map +1 -1
- package/es2022/src/modules/calendar/directives/calendarDayTemplate/calendarDayTemplate.directive.js +5 -5
- package/es2022/src/modules/calendar/directives/calendarDayTemplate/calendarDayTemplate.directive.js.map +1 -1
- package/es2022/src/modules/calendar/modules/monthCalendar.module.js +7 -11
- package/es2022/src/modules/calendar/modules/monthCalendar.module.js.map +1 -1
- package/es2022/src/modules/calendar/services/eventParser/eventParser.service.js +3 -4
- package/es2022/src/modules/calendar/services/eventParser/eventParser.service.js.map +1 -1
- package/es2022/src/modules/datePipes.module.js +6 -6
- package/es2022/src/modules/datePipes.module.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTime/dateTime.directive.js +41 -72
- package/es2022/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTimeBase.js +21 -25
- package/es2022/src/modules/dateTime/directives/dateTimeBase.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTimeControlValueAccessor/dateTimeControlValueAccessor.directive.js +36 -16
- package/es2022/src/modules/dateTime/directives/dateTimeControlValueAccessor/dateTimeControlValueAccessor.directive.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js +18 -26
- package/es2022/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js +12 -13
- package/es2022/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js +12 -13
- package/es2022/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js.map +1 -1
- package/es2022/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js +12 -13
- package/es2022/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js.map +1 -1
- package/es2022/src/modules/dateTime/modules/dateTime.module.js +27 -27
- package/es2022/src/modules/dateTime/modules/dateTime.module.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.js +39 -58
- package/es2022/src/modules/dateTimePicker/components/dateTimePeriodPickerBase.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js +21 -57
- package/es2022/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.js +17 -20
- package/es2022/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.js +6 -10
- package/es2022/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/components/rollerTimePicker/rollerTimePicker.component.js +31 -29
- package/es2022/src/modules/dateTimePicker/components/rollerTimePicker/rollerTimePicker.component.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/components/yearPicker/yearPicker.component.js +13 -13
- package/es2022/src/modules/dateTimePicker/components/yearPicker/yearPicker.component.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js +11 -40
- package/es2022/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/directives/loopScroll/loopScroll.directive.js +40 -55
- package/es2022/src/modules/dateTimePicker/directives/loopScroll/loopScroll.directive.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/directives/loopScrollData/loopScrollData.directive.js +8 -14
- package/es2022/src/modules/dateTimePicker/directives/loopScrollData/loopScrollData.directive.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/interfaces/periodData/periodData.interface.js.map +1 -1
- package/es2022/src/modules/dateTimePicker/modules/dateTimePicker.module.js +9 -10
- package/es2022/src/modules/dateTimePicker/modules/dateTimePicker.module.js.map +1 -1
- package/es2022/src/pipes/dateConvert.pipe.js +4 -5
- package/es2022/src/pipes/dateConvert.pipe.js.map +1 -1
- package/es2022/src/pipes/dateFormat.pipe.js +4 -6
- package/es2022/src/pipes/dateFormat.pipe.js.map +1 -1
- package/es2022/src/services/dateApi/dateApi.interface.js.map +1 -1
- package/es2022/src/services/datePositionParser/datePositionParser.service.js +16 -17
- package/es2022/src/services/datePositionParser/datePositionParser.service.js.map +1 -1
- package/es2022/src/services/dateTimeRelativeParser/dateTimeRelativeParser.service.js +3 -9
- package/es2022/src/services/dateTimeRelativeParser/dateTimeRelativeParser.service.js.map +1 -1
- package/es2022/src/services/dateValueProvider/dateValueProvider.service.js +3 -5
- package/es2022/src/services/dateValueProvider/dateValueProvider.service.js.map +1 -1
- package/lerna.json +4 -0
- package/moment/src/services/momentDateApi.service.d.ts +63 -132
- package/moment/src/services/momentDateApi.service.d.ts.map +1 -1
- package/package.json +41 -43
- package/src/directives/buttonDateTimeInput/buttonDateTimeInput.directive.d.ts +3 -3
- package/src/directives/buttonDateTimeInput/buttonDateTimeInput.directive.d.ts.map +1 -1
- package/src/directives/datePickerInput/datePickerInput.directive.d.ts +3 -3
- package/src/directives/datePickerInput/datePickerInput.directive.d.ts.map +1 -1
- package/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.d.ts +7 -7
- package/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.d.ts.map +1 -1
- package/src/directives/dateTimePickerInput/dateTimePickerInput.directive.d.ts +3 -3
- package/src/directives/dateTimePickerInput/dateTimePickerInput.directive.d.ts.map +1 -1
- package/src/directives/simpleDatePickerInput/simpleDatePickerInput.directive.d.ts +3 -3
- package/src/directives/simpleDatePickerInput/simpleDatePickerInput.directive.d.ts.map +1 -1
- package/src/directives/simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive.d.ts +7 -7
- package/src/directives/simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive.d.ts.map +1 -1
- package/src/directives/simpleDateTimePickerInput/simpleDateTimePickerInput.directive.d.ts +3 -3
- package/src/directives/simpleDateTimePickerInput/simpleDateTimePickerInput.directive.d.ts.map +1 -1
- package/src/directives/withNow/withNow.directive.d.ts +5 -5
- package/src/directives/withNow/withNow.directive.d.ts.map +1 -1
- package/src/directives/withTime/withTime.directive.d.ts +5 -5
- package/src/directives/withTime/withTime.directive.d.ts.map +1 -1
- package/src/directives/withToday/withToday.directive.d.ts +5 -5
- package/src/directives/withToday/withToday.directive.d.ts.map +1 -1
- package/src/interfaces/dateTimeInput/dateTimeInput.interface.d.ts +1 -1
- package/src/misc/enums.d.ts +8 -4
- package/src/misc/enums.d.ts.map +1 -1
- package/src/misc/utils.d.ts +3 -3
- package/src/misc/utils.d.ts.map +1 -1
- package/src/modules/calendar/components/monthCalendar/monthCalendar.component.d.ts +1 -1
- package/src/modules/calendar/components/monthCalendar/monthCalendar.component.d.ts.map +1 -1
- package/src/modules/calendar/components/monthCalendar/monthCalendar.component.html +17 -9
- package/src/modules/calendar/directives/calendarDayTemplate/calendarDayTemplate.directive.d.ts +1 -1
- package/src/modules/calendar/directives/calendarDayTemplate/calendarDayTemplate.directive.d.ts.map +1 -1
- package/src/modules/calendar/modules/monthCalendar.module.d.ts +3 -4
- package/src/modules/calendar/modules/monthCalendar.module.d.ts.map +1 -1
- package/src/modules/datePipes.module.d.ts +1 -1
- package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts +3 -3
- package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts.map +1 -1
- package/src/modules/dateTime/directives/dateTimeBase.d.ts +3 -3
- package/src/modules/dateTime/directives/dateTimeBase.d.ts.map +1 -1
- package/src/modules/dateTime/directives/dateTimeControlValueAccessor/dateTimeControlValueAccessor.directive.d.ts +6 -4
- package/src/modules/dateTime/directives/dateTimeControlValueAccessor/dateTimeControlValueAccessor.directive.d.ts.map +1 -1
- package/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.d.ts +3 -3
- package/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.d.ts.map +1 -1
- package/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.d.ts +3 -3
- package/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.d.ts.map +1 -1
- package/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.d.ts +3 -3
- package/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.d.ts.map +1 -1
- package/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.d.ts +3 -3
- package/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.d.ts.map +1 -1
- package/src/modules/dateTime/modules/dateTime.module.d.ts +1 -1
- package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.d.ts +4 -4
- package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.html +1 -1
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.d.ts +3 -3
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/dayPicker/dayPicker.component.html +21 -12
- package/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.d.ts +3 -3
- package/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/monthPicker/monthPicker.component.html +7 -5
- package/src/modules/dateTimePicker/components/rollerTimePicker/rollerTimePicker.component.d.ts +3 -3
- package/src/modules/dateTimePicker/components/rollerTimePicker/rollerTimePicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/rollerTimePicker/rollerTimePicker.component.html +41 -29
- package/src/modules/dateTimePicker/components/yearPicker/yearPicker.component.d.ts +3 -3
- package/src/modules/dateTimePicker/components/yearPicker/yearPicker.component.d.ts.map +1 -1
- package/src/modules/dateTimePicker/components/yearPicker/yearPicker.component.html +7 -5
- package/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.d.ts +5 -5
- package/src/modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive.d.ts.map +1 -1
- package/src/modules/dateTimePicker/directives/loopScroll/loopScroll.directive.d.ts +7 -7
- package/src/modules/dateTimePicker/directives/loopScroll/loopScroll.directive.d.ts.map +1 -1
- package/src/modules/dateTimePicker/directives/loopScrollData/loopScrollData.directive.d.ts +3 -3
- package/src/modules/dateTimePicker/directives/loopScrollData/loopScrollData.directive.d.ts.map +1 -1
- package/src/modules/dateTimePicker/interfaces/periodData/periodData.interface.d.ts.map +1 -1
- package/src/modules/dateTimePicker/modules/dateTimePicker.module.d.ts +3 -3
- package/src/modules/dateTimePicker/modules/dateTimePicker.module.d.ts.map +1 -1
- package/src/pipes/dateConvert.pipe.d.ts +1 -1
- package/src/pipes/dateFormat.pipe.d.ts +1 -1
- package/src/services/dateApi/dateApi.interface.d.ts +11 -1
- package/src/services/dateApi/dateApi.interface.d.ts.map +1 -1
- package/src/services/dateValueProvider/dateValueProvider.service.d.ts.map +1 -1
- package/version.bak +1 -1
|
@@ -10,56 +10,42 @@ import * as i0 from "@angular/core";
|
|
|
10
10
|
/**
|
|
11
11
|
* Directive that holds shared data for date time, like formats, restrictions
|
|
12
12
|
*/
|
|
13
|
-
export class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
ɵformat = 'date';
|
|
51
|
-
/**
|
|
52
|
-
* Date api instance, used for date time manipulation
|
|
53
|
-
*/
|
|
54
|
-
dateApi = inject(DATE_API);
|
|
55
|
-
/**
|
|
56
|
-
* Provider for available formats
|
|
57
|
-
*/
|
|
58
|
-
formatProvider = inject(FORMAT_PROVIDER);
|
|
59
|
-
/**
|
|
60
|
-
* Custom format string representation of date
|
|
61
|
-
*/
|
|
62
|
-
ɵcustomFormat = this.dateApi.getFormat(this.formatProvider[this.ɵformat]);
|
|
13
|
+
export class DateTimeDirective {
|
|
14
|
+
constructor() {
|
|
15
|
+
//######################### protected properties #########################
|
|
16
|
+
/**
|
|
17
|
+
* Subject used for emitting changes in max date time value
|
|
18
|
+
*/
|
|
19
|
+
this.maxDateTimeChangesSubject = new Subject();
|
|
20
|
+
/**
|
|
21
|
+
* Subject used for emitting changes in min date time value
|
|
22
|
+
*/
|
|
23
|
+
this.minDateTimeChangesSubject = new Subject();
|
|
24
|
+
/**
|
|
25
|
+
* Subject used for emitting changes in custom format value
|
|
26
|
+
*/
|
|
27
|
+
this.customFormatChangesSubject = new Subject();
|
|
28
|
+
/**
|
|
29
|
+
* Date time value format which is being worked with in this date time
|
|
30
|
+
*/
|
|
31
|
+
this.ɵvalueFormat = DateTimeValueFormat.DateInstance;
|
|
32
|
+
/**
|
|
33
|
+
* Format of string representation of date
|
|
34
|
+
*/
|
|
35
|
+
this.ɵformat = 'date';
|
|
36
|
+
/**
|
|
37
|
+
* Date api instance, used for date time manipulation
|
|
38
|
+
*/
|
|
39
|
+
this.dateApi = inject(DATE_API);
|
|
40
|
+
/**
|
|
41
|
+
* Provider for available formats
|
|
42
|
+
*/
|
|
43
|
+
this.formatProvider = inject(FORMAT_PROVIDER);
|
|
44
|
+
/**
|
|
45
|
+
* Custom format string representation of date
|
|
46
|
+
*/
|
|
47
|
+
this.ɵcustomFormat = this.dateApi.getFormat(this.formatProvider[this.ɵformat]);
|
|
48
|
+
}
|
|
63
49
|
//######################### public properties #########################
|
|
64
50
|
/**
|
|
65
51
|
* Occurs when there are changes in max date time value
|
|
@@ -113,10 +99,6 @@ export class DateTimeSADirective {
|
|
|
113
99
|
this.ɵcustomFormat = value;
|
|
114
100
|
this.customFormatChangesSubject.next();
|
|
115
101
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Represents data format that is used as value of date time when `DateTimeValueFormat.DataString` is set to `valueFormat`
|
|
118
|
-
*/
|
|
119
|
-
dataFormat;
|
|
120
102
|
/**
|
|
121
103
|
* Gets or sets max allowed date for date time
|
|
122
104
|
*/
|
|
@@ -238,35 +220,22 @@ export class DateTimeSADirective {
|
|
|
238
220
|
*/
|
|
239
221
|
onMinDateTimeChange() {
|
|
240
222
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
* Custom input type for `valueFormat` input
|
|
244
|
-
*/
|
|
245
|
-
static ngAcceptInputType_valueFormat;
|
|
246
|
-
/**
|
|
247
|
-
* Custom input type for `maxDateTime` input
|
|
248
|
-
*/
|
|
249
|
-
static ngAcceptInputType_maxDateTime;
|
|
250
|
-
/**
|
|
251
|
-
* Custom input type for `minDateTime` input
|
|
252
|
-
*/
|
|
253
|
-
static ngAcceptInputType_minDateTime;
|
|
254
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DateTimeSADirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
255
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.1", type: DateTimeSADirective, isStandalone: true, selector: "[dateTime]", inputs: { valueFormat: "valueFormat", format: "format", customFormat: "customFormat", dataFormat: "dataFormat", maxDateTime: "maxDateTime", minDateTime: "minDateTime" }, ngImport: i0 });
|
|
223
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
224
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: DateTimeDirective, isStandalone: true, selector: "[dateTime]", inputs: { valueFormat: "valueFormat", format: "format", customFormat: "customFormat", dataFormat: "dataFormat", maxDateTime: "maxDateTime", minDateTime: "minDateTime" }, ngImport: i0 }); }
|
|
256
225
|
}
|
|
257
226
|
__decorate([
|
|
258
227
|
BindThis,
|
|
259
228
|
__metadata("design:type", Function),
|
|
260
229
|
__metadata("design:paramtypes", [Object]),
|
|
261
230
|
__metadata("design:returntype", void 0)
|
|
262
|
-
],
|
|
231
|
+
], DateTimeDirective.prototype, "minDateSet", null);
|
|
263
232
|
__decorate([
|
|
264
233
|
BindThis,
|
|
265
234
|
__metadata("design:type", Function),
|
|
266
235
|
__metadata("design:paramtypes", [Object]),
|
|
267
236
|
__metadata("design:returntype", void 0)
|
|
268
|
-
],
|
|
269
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
237
|
+
], DateTimeDirective.prototype, "maxDateSet", null);
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeDirective, decorators: [{
|
|
270
239
|
type: Directive,
|
|
271
240
|
args: [{
|
|
272
241
|
selector: '[dateTime]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTime.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTime/dateTime.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAClE,OAAO,EAAU,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAC,YAAY,EAAE,KAAK,EAAc,OAAO,EAAe,MAAM,MAAM,CAAC;AAG5E,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;;AAE7C;;GAEG;AAMH,MAAM,OAAO,mBAAmB;IAE5B,0EAA0E;IAE1E;;OAEG;IACO,yBAAyB,GAAkB,IAAI,OAAO,EAAQ,CAAC;IAEzE;;OAEG;IACO,yBAAyB,GAAkB,IAAI,OAAO,EAAQ,CAAC;IAEzE;;OAEG;IACO,0BAA0B,GAAkB,IAAI,OAAO,EAAQ,CAAC;IAE1E;;OAEG;IACO,qBAAqB,CAA8B;IAE7D;;OAEG;IACO,qBAAqB,CAA8B;IAE7D;;OAEG;IACO,YAAY,CAAuB;IAE7C;;OAEG;IACO,YAAY,CAAuB;IAE7C;;OAEG;IACO,YAAY,GAAwB,mBAAmB,CAAC,YAAY,CAAC;IAE/E;;OAEG;IACO,OAAO,GAAyB,MAAM,CAAC;IAEjD;;OAEG;IACO,OAAO,GAAmB,MAAM,CAAC,QAAQ,CAAmB,CAAC;IAEvE;;OAEG;IACO,cAAc,GAAmB,MAAM,CAAC,eAAe,CAAC,CAAC;IAEnE;;OAEG;IACO,aAAa,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAA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sBADtB,KAAK;gBAeC,UAAU;sBADhB,KAAK;gBAOK,WAAW;sBADrB,KAAK;gBAwDK,WAAW;sBADrB,KAAK;gBAyEI,UAAU,MAYV,UAAU","sourcesContent":["import {Directive, inject, Input, OnDestroy} from '@angular/core';\nimport {Action1, BindThis, isBlank, isString} from '@jscrpt/common';\nimport {debounceTime, merge, Observable, Subject, Subscription} from 'rxjs';\n\nimport {FormatProvider} from '../../../../interfaces';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue} from '../../../../misc/types';\nimport {getSingleDateTimeValue} from '../../../../misc/utils';\nimport {DateApi, DateValue} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n/**\n * Directive that holds shared data for date time, like formats, restrictions\n */\n@Directive(\n{\n selector: '[dateTime]',\n standalone: true,\n})\nexport class DateTimeSADirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subject used for emitting changes in max date time value\n */\n protected maxDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in min date time value\n */\n protected minDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in custom format value\n */\n protected customFormatChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subscription for max date instance value changes\n */\n protected maxDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Subscription for min date instance value changes\n */\n protected minDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Max allowed value of date time\n */\n protected ɵmaxDateTime: TDate|undefined|null;\n\n /**\n * Min allowed value of date time\n */\n protected ɵminDateTime: TDate|undefined|null;\n\n /**\n * Date time value format which is being worked with in this date time\n */\n protected ɵvalueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Format of string representation of date\n */\n protected ɵformat: keyof FormatProvider = 'date';\n\n /**\n * Date api instance, used for date time manipulation\n */\n protected dateApi: DateApi<TDate> = inject(DATE_API) as DateApi<TDate>;\n\n /**\n * Provider for available formats\n */\n protected formatProvider: FormatProvider = inject(FORMAT_PROVIDER);\n\n /**\n * Custom format string representation of date\n */\n protected ɵcustomFormat: string = this.dateApi.getFormat(this.formatProvider[this.ɵformat]);\n\n //######################### public properties #########################\n\n /**\n * Occurs when there are changes in max date time value\n */\n public get maxDateTimeChanges(): Observable<void>\n {\n return this.maxDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in min date time value\n */\n public get minDateTimeChanges(): Observable<void>\n {\n return this.minDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in custom format value\n */\n public get customFormatChanges(): Observable<void>\n {\n return this.customFormatChangesSubject.asObservable();\n }\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets date time value format which is being worked with in this date time\n */\n @Input()\n public get valueFormat(): DateTimeValueFormat\n {\n return this.ɵvalueFormat;\n }\n public set valueFormat(value: DateTimeValueFormat)\n {\n if(isString(value))\n {\n this.ɵvalueFormat = DateTimeValueFormat[value] as unknown as DateTimeValueFormat;\n\n return;\n }\n\n this.ɵvalueFormat = value;\n }\n\n /**\n * Gets or sets format of string representation of date\n */\n @Input()\n public get format(): keyof FormatProvider\n {\n return this.ɵformat;\n }\n public set format(value: keyof FormatProvider)\n {\n this.ɵformat = value;\n this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);\n }\n\n /**\n * Gets or sets custom format string representation of date\n */\n @Input()\n public get customFormat(): string\n {\n return this.ɵcustomFormat;\n }\n public set customFormat(value: string)\n {\n this.ɵcustomFormat = value;\n this.customFormatChangesSubject.next();\n }\n\n /**\n * Represents data format that is used as value of date time when `DateTimeValueFormat.DataString` is set to `valueFormat`\n */\n @Input()\n public dataFormat: string|undefined|null;\n\n /**\n * Gets or sets max allowed date for date time\n */\n @Input()\n public get maxDateTime(): TDate|undefined|null\n {\n return this.ɵmaxDateTime;\n }\n public set maxDateTime(value: TDate|undefined|null)\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.maxDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase)\n {\n this.maxDateInstanceChange = merge(value.valueChange, value.valueSet)\n .pipe(debounceTime(10))\n .subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.maxDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n val = v;\n }\n \n this.setMinMaxValue(val, this.maxDateSet);\n }\n\n /**\n * Gets or sets min allowed date for date time\n */\n @Input()\n public get minDateTime(): TDate|undefined|null\n {\n return this.ɵminDateTime;\n }\n public set minDateTime(value: TDate|undefined|null)\n {\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.minDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase)\n {\n this.minDateInstanceChange = merge(value.valueChange, value.valueSet)\n .pipe(debounceTime(10))\n .subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.minDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.minDateSet(null);\n\n return;\n }\n\n val = v;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets min date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected minDateSet(value: TDate|undefined|null): void\n {\n this.ɵminDateTime = value;\n this.minDateTimeChangesSubject.next();\n this.onMinDateTimeChange();\n }\n\n /**\n * Sets max date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected maxDateSet(value: TDate|undefined|null): void\n {\n this.ɵmaxDateTime = value;\n this.maxDateTimeChangesSubject.next();\n this.onMaxDateTimeChange();\n }\n\n /**\n * Sets min or max date time value\n * @param value - Value to be set\n * @param setter - Action used for setting value\n */\n protected setMinMaxValue(value: DateValue|TDate, setter: Action1<TDate|undefined|null>): void\n {\n const val = this.dateApi.getValue(value, this.dataFormat ?? this.customFormat);\n\n if(val.isValid())\n {\n setter(val.value);\n }\n else\n {\n setter(null);\n }\n }\n\n /**\n * Called whenever max date time restriction changes\n */\n protected onMaxDateTimeChange(): void\n {\n }\n\n /**\n * Called whenever min date time restriction changes\n */\n protected onMinDateTimeChange(): void\n {\n }\n\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\n\n /**\n * Custom input type for `maxDateTime` input\n */\n public static ngAcceptInputType_maxDateTime: DateValue|DateTimeBase;\n\n /**\n * Custom input type for `minDateTime` input\n */\n public static ngAcceptInputType_minDateTime: DateValue|DateTimeBase;\n}"]}
|
|
1
|
+
{"version":3,"file":"dateTime.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTime/dateTime.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAClE,OAAO,EAAU,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAC,YAAY,EAAE,KAAK,EAAc,OAAO,EAAe,MAAM,MAAM,CAAC;AAG5E,OAAO,EAAC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E,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACO,cAAc,CAAC,KAAsB,EAAE,MAAqC;QAElF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QAE/E,IAAG,GAAG,CAAC,OAAO,EAAE,EAChB,CAAC;YACG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;aAED,CAAC;YACG,MAAM,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACL,CAAC;IAED;;OAEG;IACO,mBAAmB;IAE7B,CAAC;IAED;;OAEG;IACO,mBAAmB;IAE7B,CAAC;8GAvUQ,iBAAiB;kGAAjB,iBAAiB;;AAqRhB;IADT,QAAQ;;;;mDAMR;AAOS;IADT,QAAQ;;;;mDAMR;2FAtSQ,iBAAiB;kBAL7B,SAAS;mBACV;oBACI,QAAQ,EAAE,YAAY;oBACtB,UAAU,EAAE,IAAI;iBACnB;8BAiGc,WAAW;sBADrB,KAAK;gBAqBK,MAAM;sBADhB,KAAK;gBAeK,YAAY;sBADtB,KAAK;gBAeC,UAAU;sBADhB,KAAK;gBAOK,WAAW;sBADrB,KAAK;gBAwDK,WAAW;sBADrB,KAAK;gBAyEI,UAAU,MAYV,UAAU","sourcesContent":["import {Directive, inject, Input, OnDestroy} from '@angular/core';\nimport {Action1, BindThis, isBlank, isString} from '@jscrpt/common';\nimport {debounceTime, merge, Observable, Subject, Subscription} from 'rxjs';\n\nimport {FormatProvider} from '../../../../interfaces';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue} from '../../../../misc/types';\nimport {getSingleDateTimeValue} from '../../../../misc/utils';\nimport {DateApi, DateValue} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n/**\n * Directive that holds shared data for date time, like formats, restrictions\n */\n@Directive(\n{\n selector: '[dateTime]',\n standalone: true,\n})\nexport class DateTimeDirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subject used for emitting changes in max date time value\n */\n protected maxDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in min date time value\n */\n protected minDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in custom format value\n */\n protected customFormatChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subscription for max date instance value changes\n */\n protected maxDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Subscription for min date instance value changes\n */\n protected minDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Max allowed value of date time\n */\n protected ɵmaxDateTime: TDate|undefined|null;\n\n /**\n * Min allowed value of date time\n */\n protected ɵminDateTime: TDate|undefined|null;\n\n /**\n * Date time value format which is being worked with in this date time\n */\n protected ɵvalueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Format of string representation of date\n */\n protected ɵformat: keyof FormatProvider = 'date';\n\n /**\n * Date api instance, used for date time manipulation\n */\n protected dateApi: DateApi<TDate> = inject(DATE_API) as DateApi<TDate>;\n\n /**\n * Provider for available formats\n */\n protected formatProvider: FormatProvider = inject(FORMAT_PROVIDER);\n\n /**\n * Custom format string representation of date\n */\n protected ɵcustomFormat: string = this.dateApi.getFormat(this.formatProvider[this.ɵformat]);\n\n //######################### public properties #########################\n\n /**\n * Occurs when there are changes in max date time value\n */\n public get maxDateTimeChanges(): Observable<void>\n {\n return this.maxDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in min date time value\n */\n public get minDateTimeChanges(): Observable<void>\n {\n return this.minDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in custom format value\n */\n public get customFormatChanges(): Observable<void>\n {\n return this.customFormatChangesSubject.asObservable();\n }\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets date time value format which is being worked with in this date time\n */\n @Input()\n public get valueFormat(): DateTimeValueFormat\n {\n return this.ɵvalueFormat;\n }\n public set valueFormat(value: DateTimeValueFormat)\n {\n if(isString(value))\n {\n this.ɵvalueFormat = DateTimeValueFormat[value] as unknown as DateTimeValueFormat;\n\n return;\n }\n\n this.ɵvalueFormat = value;\n }\n\n /**\n * Gets or sets format of string representation of date\n */\n @Input()\n public get format(): keyof FormatProvider\n {\n return this.ɵformat;\n }\n public set format(value: keyof FormatProvider)\n {\n this.ɵformat = value;\n this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);\n }\n\n /**\n * Gets or sets custom format string representation of date\n */\n @Input()\n public get customFormat(): string\n {\n return this.ɵcustomFormat;\n }\n public set customFormat(value: string)\n {\n this.ɵcustomFormat = value;\n this.customFormatChangesSubject.next();\n }\n\n /**\n * Represents data format that is used as value of date time when `DateTimeValueFormat.DataString` is set to `valueFormat`\n */\n @Input()\n public dataFormat: string|undefined|null;\n\n /**\n * Gets or sets max allowed date for date time\n */\n @Input()\n public get maxDateTime(): TDate|undefined|null\n {\n return this.ɵmaxDateTime;\n }\n public set maxDateTime(value: TDate|undefined|null)\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.maxDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase)\n {\n this.maxDateInstanceChange = merge(value.valueChange, value.valueSet)\n .pipe(debounceTime(10))\n .subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.maxDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n val = v;\n }\n \n this.setMinMaxValue(val, this.maxDateSet);\n }\n\n /**\n * Gets or sets min allowed date for date time\n */\n @Input()\n public get minDateTime(): TDate|undefined|null\n {\n return this.ɵminDateTime;\n }\n public set minDateTime(value: TDate|undefined|null)\n {\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.minDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase)\n {\n this.minDateInstanceChange = merge(value.valueChange, value.valueSet)\n .pipe(debounceTime(10))\n .subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.minDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.minDateSet(null);\n\n return;\n }\n\n val = v;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets min date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected minDateSet(value: TDate|undefined|null): void\n {\n this.ɵminDateTime = value;\n this.minDateTimeChangesSubject.next();\n this.onMinDateTimeChange();\n }\n\n /**\n * Sets max date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected maxDateSet(value: TDate|undefined|null): void\n {\n this.ɵmaxDateTime = value;\n this.maxDateTimeChangesSubject.next();\n this.onMaxDateTimeChange();\n }\n\n /**\n * Sets min or max date time value\n * @param value - Value to be set\n * @param setter - Action used for setting value\n */\n protected setMinMaxValue(value: DateValue|TDate, setter: Action1<TDate|undefined|null>): void\n {\n const val = this.dateApi.getValue(value, this.dataFormat ?? this.customFormat);\n\n if(val.isValid())\n {\n setter(val.value);\n }\n else\n {\n setter(null);\n }\n }\n\n /**\n * Called whenever max date time restriction changes\n */\n protected onMaxDateTimeChange(): void\n {\n }\n\n /**\n * Called whenever min date time restriction changes\n */\n protected onMinDateTimeChange(): void\n {\n }\n\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\n\n /**\n * Custom input type for `maxDateTime` input\n */\n public static ngAcceptInputType_maxDateTime: DateValue|DateTimeBase;\n\n /**\n * Custom input type for `minDateTime` input\n */\n public static ngAcceptInputType_minDateTime: DateValue|DateTimeBase;\n}"]}
|
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { Directive, EventEmitter, inject } from '@angular/core';
|
|
2
2
|
import { Subscription } from 'rxjs';
|
|
3
|
-
import {
|
|
3
|
+
import { DateTimeDirective } from './dateTime/dateTime.directive';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
/**
|
|
6
6
|
* Base class for date time directives, contains basic shared data
|
|
7
7
|
*/
|
|
8
8
|
export class DateTimeBase {
|
|
9
|
-
//######################### protected properties #########################
|
|
10
|
-
/**
|
|
11
|
-
* Subscriptions created during initialization
|
|
12
|
-
*/
|
|
13
|
-
initSubscriptions = new Subscription();
|
|
14
|
-
/**
|
|
15
|
-
* Current value of date time, could be string, unix timestamp, Date, TDate object, or ranged DateTimeValue
|
|
16
|
-
*/
|
|
17
|
-
ɵValue;
|
|
18
|
-
/**
|
|
19
|
-
* Instance of date time shared data, like formats and restrictions
|
|
20
|
-
*/
|
|
21
|
-
dateTimeData = inject((DateTimeSADirective));
|
|
22
9
|
//######################### public properties - implementation of DateTimeInputValue #########################
|
|
23
10
|
/**
|
|
24
11
|
* @inheritdoc
|
|
@@ -29,16 +16,25 @@ export class DateTimeBase {
|
|
|
29
16
|
set value(value) {
|
|
30
17
|
this.ɵValue = value;
|
|
31
18
|
}
|
|
32
|
-
/**
|
|
33
|
-
* @inheritdoc
|
|
34
|
-
*/
|
|
35
|
-
valueChange = new EventEmitter();
|
|
36
|
-
/**
|
|
37
|
-
* @inheritdoc
|
|
38
|
-
*/
|
|
39
|
-
valueSet = new EventEmitter();
|
|
40
19
|
//######################### constructor #########################
|
|
41
20
|
constructor() {
|
|
21
|
+
//######################### protected properties #########################
|
|
22
|
+
/**
|
|
23
|
+
* Subscriptions created during initialization
|
|
24
|
+
*/
|
|
25
|
+
this.initSubscriptions = new Subscription();
|
|
26
|
+
/**
|
|
27
|
+
* Instance of date time shared data, like formats and restrictions
|
|
28
|
+
*/
|
|
29
|
+
this.dateTimeData = inject((DateTimeDirective));
|
|
30
|
+
/**
|
|
31
|
+
* @inheritdoc
|
|
32
|
+
*/
|
|
33
|
+
this.valueChange = new EventEmitter();
|
|
34
|
+
/**
|
|
35
|
+
* @inheritdoc
|
|
36
|
+
*/
|
|
37
|
+
this.valueSet = new EventEmitter();
|
|
42
38
|
this.initSubscriptions.add(this.dateTimeData.maxDateTimeChanges.subscribe(() => this.onMaxDateTimeChange()));
|
|
43
39
|
this.initSubscriptions.add(this.dateTimeData.minDateTimeChanges.subscribe(() => this.onMinDateTimeChange()));
|
|
44
40
|
}
|
|
@@ -60,10 +56,10 @@ export class DateTimeBase {
|
|
|
60
56
|
*/
|
|
61
57
|
onMinDateTimeChange() {
|
|
62
58
|
}
|
|
63
|
-
static
|
|
64
|
-
static
|
|
59
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
60
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: DateTimeBase, ngImport: i0 }); }
|
|
65
61
|
}
|
|
66
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeBase, decorators: [{
|
|
67
63
|
type: Directive
|
|
68
64
|
}], ctorParameters: () => [] });
|
|
69
65
|
//# sourceMappingURL=dateTimeBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTimeBase.js","sourceRoot":"","sources":["../../../../../src/modules/dateTime/directives/dateTimeBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAIlC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"dateTimeBase.js","sourceRoot":"","sources":["../../../../../src/modules/dateTime/directives/dateTimeBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAIlC,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;;AAEhE;;GAEG;AAEH,MAAM,OAAO,YAAY;IAmBrB,8GAA8G;IAE9G;;OAEG;IACH,IAAW,KAAK;QAEZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,IAAW,KAAK,CAAC,KAAqD;QAElE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAYD,iEAAiE;IACjE;QA1CA,0EAA0E;QAE1E;;WAEG;QACO,sBAAiB,GAAiB,IAAI,YAAY,EAAE,CAAC;QAO/D;;WAEG;QACO,iBAAY,GAA6B,MAAM,CAAC,CAAA,iBAAwB,CAAA,CAAC,CAAC;QAgBpF;;WAEG;QACI,gBAAW,GAAuB,IAAI,YAAY,EAAQ,CAAC;QAElE;;WAEG;QACI,aAAQ,GAAuB,IAAI,YAAY,EAAQ,CAAC;QAK3D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;IACjH,CAAC;IAED,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAED,uEAAuE;IAEvE;;OAEG;IACO,mBAAmB;IAE7B,CAAC;IAED;;OAEG;IACO,mBAAmB;IAE7B,CAAC;8GA1EQ,YAAY;kGAAZ,YAAY;;2FAAZ,YAAY;kBADxB,SAAS","sourcesContent":["import {Directive, EventEmitter, inject, OnDestroy} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeInputValue} from '../../../interfaces';\nimport {DateTimeInputOutputValue} from '../../../misc/types';\nimport {DateTimeDirective} from './dateTime/dateTime.directive';\n\n/**\n * Base class for date time directives, contains basic shared data\n */\n@Directive()\nexport class DateTimeBase<TDate = unknown> implements DateTimeInputValue<TDate>, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n /**\n * Current value of date time, could be string, timestamp, Date, TDate object, or ranged DateTimeValue\n */\n protected ɵValue: DateTimeInputOutputValue<TDate>|undefined|null;\n\n /**\n * Instance of date time shared data, like formats and restrictions\n */\n protected dateTimeData: DateTimeDirective<TDate> = inject(DateTimeDirective<TDate>);\n\n //######################### public properties - implementation of DateTimeInputValue #########################\n\n /**\n * @inheritdoc\n */\n public get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n this.ɵValue = value;\n }\n\n /**\n * @inheritdoc\n */\n public valueChange: EventEmitter<void> = new EventEmitter<void>();\n\n /**\n * @inheritdoc\n */\n public valueSet: EventEmitter<void> = new EventEmitter<void>();\n\n //######################### constructor #########################\n constructor()\n {\n this.initSubscriptions.add(this.dateTimeData.maxDateTimeChanges.subscribe(() => this.onMaxDateTimeChange()));\n this.initSubscriptions.add(this.dateTimeData.minDateTimeChanges.subscribe(() => this.onMinDateTimeChange()));\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.initSubscriptions.unsubscribe();\n }\n\n //######################### protected methods #########################\n\n /**\n * Called whenever max date time restriction changes\n */\n protected onMaxDateTimeChange(): void\n {\n }\n\n /**\n * Called whenever min date time restriction changes\n */\n protected onMinDateTimeChange(): void\n {\n }\n}\n"]}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { Directive, forwardRef, Inject } from '@angular/core';
|
|
2
2
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import { isNumber } from '@jscrpt/common';
|
|
3
4
|
import { Subscription } from 'rxjs';
|
|
4
5
|
import { DATE_TIME_INPUT } from '../../../../misc/tokens';
|
|
6
|
+
import { DateTimeDirective } from '../dateTime/dateTime.directive';
|
|
7
|
+
import { DateTimeValueFormat } from '../../../../misc/enums';
|
|
5
8
|
import * as i0 from "@angular/core";
|
|
9
|
+
import * as i1 from "../dateTime/dateTime.directive";
|
|
6
10
|
/**
|
|
7
11
|
* Control value accessor that is used for getting and setting value for date time
|
|
8
12
|
*/
|
|
9
|
-
export class
|
|
10
|
-
input;
|
|
11
|
-
//######################### protected properties #########################
|
|
12
|
-
/**
|
|
13
|
-
* Subscriptions created during initialization
|
|
14
|
-
*/
|
|
15
|
-
initSubscriptions = new Subscription();
|
|
13
|
+
export class DateTimeControlValueAccessorDirective {
|
|
16
14
|
//######################### constructor #########################
|
|
17
|
-
constructor(input) {
|
|
15
|
+
constructor(input, dateTime) {
|
|
18
16
|
this.input = input;
|
|
17
|
+
this.dateTime = dateTime;
|
|
18
|
+
//######################### protected properties #########################
|
|
19
|
+
/**
|
|
20
|
+
* Subscriptions created during initialization
|
|
21
|
+
*/
|
|
22
|
+
this.initSubscriptions = new Subscription();
|
|
19
23
|
}
|
|
20
24
|
//######################### public methods - implementation of OnDestroy #########################
|
|
21
25
|
/**
|
|
@@ -29,13 +33,29 @@ export class DateTimeControlValueAccessorSADirective {
|
|
|
29
33
|
* @inheritdoc
|
|
30
34
|
*/
|
|
31
35
|
writeValue(value) {
|
|
36
|
+
if (this.dateTime.valueFormat == DateTimeValueFormat.UnixTimestamp) {
|
|
37
|
+
if (!isNumber(value)) {
|
|
38
|
+
throw new Error('DateTimeControlValueAccessorDirective: value is not a number!');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
value = value * 1000;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
32
44
|
this.input.value = value;
|
|
33
45
|
}
|
|
34
46
|
/**
|
|
35
47
|
* @inheritdoc
|
|
36
48
|
*/
|
|
37
49
|
registerOnChange(fn) {
|
|
38
|
-
this.initSubscriptions.add(this.input.valueChange.subscribe(() =>
|
|
50
|
+
this.initSubscriptions.add(this.input.valueChange.subscribe(() => {
|
|
51
|
+
const value = this.input.value;
|
|
52
|
+
if (this.dateTime.valueFormat == DateTimeValueFormat.UnixTimestamp && isNumber(value)) {
|
|
53
|
+
fn(value / 1000);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
fn(this.input.value);
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
39
59
|
}
|
|
40
60
|
/**
|
|
41
61
|
* @inheritdoc
|
|
@@ -49,23 +69,23 @@ export class DateTimeControlValueAccessorSADirective {
|
|
|
49
69
|
setDisabledState(isDisabled) {
|
|
50
70
|
this.input.disabled = isDisabled;
|
|
51
71
|
}
|
|
52
|
-
static
|
|
53
|
-
static
|
|
72
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeControlValueAccessorDirective, deps: [{ token: DATE_TIME_INPUT }, { token: i1.DateTimeDirective }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
73
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: DateTimeControlValueAccessorDirective, isStandalone: true, selector: "[dateTime][formControlName],[dateTime][formControl],[dateTime][ngModel]", providers: [
|
|
54
74
|
{
|
|
55
75
|
provide: NG_VALUE_ACCESSOR,
|
|
56
|
-
useExisting: forwardRef(() =>
|
|
76
|
+
useExisting: forwardRef(() => DateTimeControlValueAccessorDirective),
|
|
57
77
|
multi: true,
|
|
58
78
|
},
|
|
59
|
-
], ngImport: i0 });
|
|
79
|
+
], ngImport: i0 }); }
|
|
60
80
|
}
|
|
61
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
81
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeControlValueAccessorDirective, decorators: [{
|
|
62
82
|
type: Directive,
|
|
63
83
|
args: [{
|
|
64
84
|
selector: '[dateTime][formControlName],[dateTime][formControl],[dateTime][ngModel]',
|
|
65
85
|
providers: [
|
|
66
86
|
{
|
|
67
87
|
provide: NG_VALUE_ACCESSOR,
|
|
68
|
-
useExisting: forwardRef(() =>
|
|
88
|
+
useExisting: forwardRef(() => DateTimeControlValueAccessorDirective),
|
|
69
89
|
multi: true,
|
|
70
90
|
},
|
|
71
91
|
],
|
|
@@ -74,5 +94,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImpor
|
|
|
74
94
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
75
95
|
type: Inject,
|
|
76
96
|
args: [DATE_TIME_INPUT]
|
|
77
|
-
}] }] });
|
|
97
|
+
}] }, { type: i1.DateTimeDirective }] });
|
|
78
98
|
//# sourceMappingURL=dateTimeControlValueAccessor.directive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTimeControlValueAccessor.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeControlValueAccessor/dateTimeControlValueAccessor.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,UAAU,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AACzF,OAAO,EAAuB,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC
|
|
1
|
+
{"version":3,"file":"dateTimeControlValueAccessor.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeControlValueAccessor/dateTimeControlValueAccessor.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,UAAU,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AACzF,OAAO,EAAuB,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;;;AAE3D;;GAEG;AAeH,MAAM,OAAO,qCAAqC;IAS9C,iEAAiE;IACjE,YAA+C,KAA2B,EACpD,QAAkC;QADT,UAAK,GAAL,KAAK,CAAsB;QACpD,aAAQ,GAAR,QAAQ,CAA0B;QATxD,0EAA0E;QAE1E;;WAEG;QACO,sBAAiB,GAAiB,IAAI,YAAY,EAAE,CAAC;IAM/D,CAAC;IAED,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;I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V1B,qCAAqC,sHAV9C;YAEI;gBACI,OAAO,EAAE,iBAAiB;gBAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,qCAAqC,CAAC;gBACpE,KAAK,EAAE,IAAI;aACd;SACJ;;2FAGQ,qCAAqC;kBAdjD,SAAS;mBACV;oBACI,QAAQ,EAAE,yEAAyE;oBACnF,SAAS,EACT;wBAEI;4BACI,OAAO,EAAE,iBAAiB;4BAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,sCAAsC,CAAC;4BACpE,KAAK,EAAE,IAAI;yBACd;qBACJ;oBACD,UAAU,EAAE,IAAI;iBACnB;;0BAWgB,MAAM;2BAAC,eAAe","sourcesContent":["import {Directive, ExistingProvider, forwardRef, Inject, OnDestroy} from '@angular/core';\nimport {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';\nimport {isNumber} from '@jscrpt/common';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeInput} from '../../../../interfaces';\nimport {DATE_TIME_INPUT} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue} from '../../../../misc/types';\nimport {DateTimeDirective} from '../dateTime/dateTime.directive';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\n\n/**\n * Control value accessor that is used for getting and setting value for date time\n */\n@Directive(\n{\n selector: '[dateTime][formControlName],[dateTime][formControl],[dateTime][ngModel]',\n providers:\n [\n <ExistingProvider>\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => DateTimeControlValueAccessorDirective),\n multi: true,\n },\n ],\n standalone: true,\n})\nexport class DateTimeControlValueAccessorDirective<TDate = unknown> implements ControlValueAccessor, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n //######################### constructor #########################\n constructor(@Inject(DATE_TIME_INPUT) protected input: DateTimeInput<TDate>,\n protected dateTime: DateTimeDirective<TDate>,)\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.initSubscriptions.unsubscribe();\n }\n\n //######################### public methods - implementation of ControlValueAccessor #########################\n\n /**\n * @inheritdoc\n */\n public writeValue(value: DateTimeInputOutputValue<TDate>|undefined|null): void\n {\n if(this.dateTime.valueFormat == DateTimeValueFormat.UnixTimestamp)\n {\n if(!isNumber(value))\n {\n throw new Error('DateTimeControlValueAccessorDirective: value is not a number!');\n }\n else\n {\n value = value * 1000;\n }\n }\n\n this.input.value = value;\n }\n\n /**\n * @inheritdoc\n */\n public registerOnChange(fn: (data: DateTimeInputOutputValue<TDate>|undefined|null) => void): void\n {\n this.initSubscriptions.add(this.input.valueChange.subscribe(() =>\n {\n const value = this.input.value;\n\n if(this.dateTime.valueFormat == DateTimeValueFormat.UnixTimestamp && isNumber(value))\n {\n fn(value / 1000);\n }\n else\n {\n fn(this.input.value);\n }\n }));\n }\n\n /**\n * @inheritdoc\n */\n public registerOnTouched(fn: () => void): void\n {\n this.initSubscriptions.add(this.input.focus.subscribe(() => fn()));\n }\n\n /**\n * @inheritdoc\n */\n public setDisabledState(isDisabled: boolean): void\n {\n this.input.disabled = isDisabled;\n }\n}"]}
|
|
@@ -12,15 +12,7 @@ import * as i1 from "../../../../services";
|
|
|
12
12
|
/**
|
|
13
13
|
* Directive that is used for setting up date time input
|
|
14
14
|
*/
|
|
15
|
-
export class
|
|
16
|
-
elementRef;
|
|
17
|
-
dateApi;
|
|
18
|
-
valueProvider;
|
|
19
|
-
//######################### protected properties #########################
|
|
20
|
-
/**
|
|
21
|
-
* Internal representation of current date time value
|
|
22
|
-
*/
|
|
23
|
-
internalValue;
|
|
15
|
+
export class DateTimeInputDirective extends DateTimeBase {
|
|
24
16
|
//######################### public properties - implementation of DateTimeInput #########################
|
|
25
17
|
/**
|
|
26
18
|
* @inheritdoc
|
|
@@ -65,20 +57,20 @@ export class DateTimeInputSADirective extends DateTimeBase {
|
|
|
65
57
|
get element() {
|
|
66
58
|
return this.elementRef.nativeElement;
|
|
67
59
|
}
|
|
68
|
-
/**
|
|
69
|
-
* @inheritdoc
|
|
70
|
-
*/
|
|
71
|
-
focus = new EventEmitter();
|
|
72
|
-
/**
|
|
73
|
-
* @inheritdoc
|
|
74
|
-
*/
|
|
75
|
-
blur = new EventEmitter();
|
|
76
60
|
//######################### constructors #########################
|
|
77
61
|
constructor(elementRef, dateApi, valueProvider) {
|
|
78
62
|
super();
|
|
79
63
|
this.elementRef = elementRef;
|
|
80
64
|
this.dateApi = dateApi;
|
|
81
65
|
this.valueProvider = valueProvider;
|
|
66
|
+
/**
|
|
67
|
+
* @inheritdoc
|
|
68
|
+
*/
|
|
69
|
+
this.focus = new EventEmitter();
|
|
70
|
+
/**
|
|
71
|
+
* @inheritdoc
|
|
72
|
+
*/
|
|
73
|
+
this.blur = new EventEmitter();
|
|
82
74
|
this.elementRef.nativeElement.addEventListener('input', this.handleInput);
|
|
83
75
|
this.elementRef.nativeElement.addEventListener('focus', this.handleFocus);
|
|
84
76
|
this.elementRef.nativeElement.addEventListener('blur', this.handleBlur);
|
|
@@ -132,40 +124,40 @@ export class DateTimeInputSADirective extends DateTimeBase {
|
|
|
132
124
|
handleBlur(event) {
|
|
133
125
|
this.blur.emit(event);
|
|
134
126
|
}
|
|
135
|
-
static
|
|
136
|
-
static
|
|
127
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeInputDirective, deps: [{ token: i0.ElementRef }, { token: DATE_API }, { token: i1.DateValueProvider }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
128
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.7", type: DateTimeInputDirective, isStandalone: true, selector: "input[dateTime][dateTimeInput]", providers: [
|
|
137
129
|
{
|
|
138
130
|
provide: DATE_TIME_INPUT,
|
|
139
|
-
useExisting: forwardRef(() =>
|
|
131
|
+
useExisting: forwardRef(() => DateTimeInputDirective),
|
|
140
132
|
},
|
|
141
|
-
], exportAs: ["dateTime"], usesInheritance: true, ngImport: i0 });
|
|
133
|
+
], exportAs: ["dateTime"], usesInheritance: true, ngImport: i0 }); }
|
|
142
134
|
}
|
|
143
135
|
__decorate([
|
|
144
136
|
BindThis,
|
|
145
137
|
__metadata("design:type", Function),
|
|
146
138
|
__metadata("design:paramtypes", []),
|
|
147
139
|
__metadata("design:returntype", void 0)
|
|
148
|
-
],
|
|
140
|
+
], DateTimeInputDirective.prototype, "handleInput", null);
|
|
149
141
|
__decorate([
|
|
150
142
|
BindThis,
|
|
151
143
|
__metadata("design:type", Function),
|
|
152
144
|
__metadata("design:paramtypes", [FocusEvent]),
|
|
153
145
|
__metadata("design:returntype", void 0)
|
|
154
|
-
],
|
|
146
|
+
], DateTimeInputDirective.prototype, "handleFocus", null);
|
|
155
147
|
__decorate([
|
|
156
148
|
BindThis,
|
|
157
149
|
__metadata("design:type", Function),
|
|
158
150
|
__metadata("design:paramtypes", [FocusEvent]),
|
|
159
151
|
__metadata("design:returntype", void 0)
|
|
160
|
-
],
|
|
161
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
152
|
+
], DateTimeInputDirective.prototype, "handleBlur", null);
|
|
153
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: DateTimeInputDirective, decorators: [{
|
|
162
154
|
type: Directive,
|
|
163
155
|
args: [{
|
|
164
156
|
selector: 'input[dateTime][dateTimeInput]',
|
|
165
157
|
providers: [
|
|
166
158
|
{
|
|
167
159
|
provide: DATE_TIME_INPUT,
|
|
168
|
-
useExisting: forwardRef(() =>
|
|
160
|
+
useExisting: forwardRef(() => DateTimeInputDirective),
|
|
169
161
|
},
|
|
170
162
|
],
|
|
171
163
|
standalone: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateTimeInput.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/date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CAAC;IAED;;;OAGG;IAEO,WAAW,CAAC,KAAiB;QAEnC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IAEO,UAAU,CAAC,KAAiB;QAElC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;uGAhKQ,wBAAwB,4CAiFb,QAAQ;2FAjFnB,wBAAwB,6EAVjC;YAEI;gBACI,OAAO,EAAE,eAAe;gBACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC;aAC1D;SACJ;;AA8HS;IADT,QAAQ;;;;2DAmBR;AAOS;IADT,QAAQ;;qCACoB,UAAU;;2DAGtC;AAOS;IADT,QAAQ;;qCACmB,UAAU;;0DAGrC;2FAhKQ,wBAAwB;kBAdpC,SAAS;mBACV;oBACI,QAAQ,EAAE,gCAAgC;oBAC1C,SAAS,EACT;wBAEI;4BACI,OAAO,EAAE,eAAe;4BACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,yBAAyB,CAAC;yBAC1D;qBACJ;oBACD,UAAU,EAAE,IAAI;oBAChB,QAAQ,EAAE,UAAU;iBACvB;;0BAkFgB,MAAM;2BAAC,QAAQ;yEAyClB,WAAW,MAyBX,WAAW,MAUX,UAAU","sourcesContent":["import {Directive, ElementRef, EventEmitter, ExistingProvider, forwardRef, Inject, OnDestroy} from '@angular/core';\nimport {BindThis} from '@jscrpt/common';\n\nimport {DateTimeInput} from '../../../../interfaces';\nimport {DATE_API, DATE_TIME_INPUT} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue, DateTimeObjectValue} from '../../../../misc/types';\nimport {formatDateTime, getInternalValue} from '../../../../misc/utils';\nimport {DateApi, DateValueProvider} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\n\n//TODO: range is unimplemented\n\n/**\n * Directive that is used for setting up date time input\n */\n@Directive(\n{\n selector: 'input[dateTime][dateTimeInput]',\n providers:\n [\n <ExistingProvider>\n {\n provide: DATE_TIME_INPUT,\n useExisting: forwardRef(() => DateTimeInputSADirective),\n },\n ],\n standalone: true,\n exportAs: 'dateTime',\n})\nexport class DateTimeInputSADirective<TDate = unknown> extends DateTimeBase<TDate> implements DateTimeInput, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Internal representation of current date time value\n */\n protected internalValue: DateTimeObjectValue<TDate>|undefined|null;\n\n //######################### public properties - implementation of DateTimeInput #########################\n\n /**\n * @inheritdoc\n */\n public get rawValue(): string|undefined|null\n {\n return this.elementRef.nativeElement.value;\n }\n public set rawValue(value: string|undefined|null)\n {\n this.elementRef.nativeElement.value = value ?? '';\n }\n\n /**\n * @inheritdoc\n */\n public override get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public override set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n //accepts all available formats\n this.setInternalValue(value);\n this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat, this.dateTimeData.dataFormat);\n \n //not range value\n if(!Array.isArray(this.internalValue))\n {\n this.rawValue = this.internalValue?.format(this.dateTimeData.customFormat);\n }\n else\n {\n //TODO: add support for ranges\n }\n\n this.valueSet.next();\n }\n\n /**\n * @inheritdoc\n */\n public get disabled(): boolean\n {\n return this.elementRef.nativeElement.disabled;\n }\n public set disabled(value: boolean)\n {\n this.elementRef.nativeElement.disabled = value;\n }\n\n /**\n * Html element that represents input itself\n */\n public get element(): HTMLElement\n {\n return this.elementRef.nativeElement;\n }\n\n /**\n * @inheritdoc\n */\n public focus: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n /**\n * @inheritdoc\n */\n public blur: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n //######################### constructors #########################\n constructor(protected elementRef: ElementRef<HTMLInputElement>,\n @Inject(DATE_API) protected dateApi: DateApi<TDate>,\n protected valueProvider: DateValueProvider<TDate>,)\n {\n super();\n\n this.elementRef.nativeElement.addEventListener('input', this.handleInput);\n this.elementRef.nativeElement.addEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.addEventListener('blur', this.handleBlur);\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.elementRef.nativeElement.removeEventListener('input', this.handleInput);\n this.elementRef.nativeElement.removeEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.removeEventListener('blur', this.handleBlur);\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets internal value and fix lowest time difference\n * @param value - Value to be set\n * @param dateTimeFormat - Date time format type, optional, if not specified autodetection of format will be used, used when obtaining value from users input\n */\n protected setInternalValue(value: DateTimeInputOutputValue<TDate>|undefined|null,\n dateTimeFormat: DateTimeValueFormat|undefined|null = null,): void\n {\n this.internalValue = getInternalValue(value, this.dateApi, this.dateTimeData, this.valueProvider, dateTimeFormat);\n }\n\n /**\n * Handles input event on input\n */\n @BindThis\n protected handleInput(): void\n {\n if(!this.rawValue)\n {\n this.internalValue = null;\n this.ɵValue = null;\n\n this.valueSet.next();\n this.valueChange.next();\n\n return;\n }\n\n this.setInternalValue(this.rawValue, DateTimeValueFormat.FormattedString);\n this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat, this.dateTimeData.dataFormat);\n\n this.valueSet.next();\n this.valueChange.next();\n }\n\n /**\n * Handles focus event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleFocus(event: FocusEvent): void\n {\n this.focus.emit(event);\n }\n\n /**\n * Handles blur event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleBlur(event: FocusEvent): void\n {\n this.blur.emit(event);\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"dateTimeInput.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeInput/dateTime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,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IAEO,UAAU,CAAC,KAAiB;QAElC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;8GAhKQ,sBAAsB,4CAiFX,QAAQ;kGAjFnB,sBAAsB,6EAV/B;YAEI;gBACI,OAAO,EAAE,eAAe;gBACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;aACxD;SACJ;;AA8HS;IADT,QAAQ;;;;yDAmBR;AAOS;IADT,QAAQ;;qCACoB,UAAU;;yDAGtC;AAOS;IADT,QAAQ;;qCACmB,UAAU;;wDAGrC;2FAhKQ,sBAAsB;kBAdlC,SAAS;mBACV;oBACI,QAAQ,EAAE,gCAAgC;oBAC1C,SAAS,EACT;wBAEI;4BACI,OAAO,EAAE,eAAe;4BACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,uBAAuB,CAAC;yBACxD;qBACJ;oBACD,UAAU,EAAE,IAAI;oBAChB,QAAQ,EAAE,UAAU;iBACvB;;0BAkFgB,MAAM;2BAAC,QAAQ;yEAyClB,WAAW,MAyBX,WAAW,MAUX,UAAU","sourcesContent":["import {Directive, ElementRef, EventEmitter, ExistingProvider, forwardRef, Inject, OnDestroy} from '@angular/core';\nimport {BindThis} from '@jscrpt/common';\n\nimport {DateTimeInput} from '../../../../interfaces';\nimport {DATE_API, DATE_TIME_INPUT} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue, DateTimeObjectValue} from '../../../../misc/types';\nimport {formatDateTime, getInternalValue} from '../../../../misc/utils';\nimport {DateApi, DateValueProvider} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\n\n//TODO: range is unimplemented\n\n/**\n * Directive that is used for setting up date time input\n */\n@Directive(\n{\n selector: 'input[dateTime][dateTimeInput]',\n providers:\n [\n <ExistingProvider>\n {\n provide: DATE_TIME_INPUT,\n useExisting: forwardRef(() => DateTimeInputDirective),\n },\n ],\n standalone: true,\n exportAs: 'dateTime',\n})\nexport class DateTimeInputDirective<TDate = unknown> extends DateTimeBase<TDate> implements DateTimeInput, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Internal representation of current date time value\n */\n protected internalValue: DateTimeObjectValue<TDate>|undefined|null;\n\n //######################### public properties - implementation of DateTimeInput #########################\n\n /**\n * @inheritdoc\n */\n public get rawValue(): string|undefined|null\n {\n return this.elementRef.nativeElement.value;\n }\n public set rawValue(value: string|undefined|null)\n {\n this.elementRef.nativeElement.value = value ?? '';\n }\n\n /**\n * @inheritdoc\n */\n public override get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public override set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n //accepts all available formats\n this.setInternalValue(value);\n this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat, this.dateTimeData.dataFormat);\n \n //not range value\n if(!Array.isArray(this.internalValue))\n {\n this.rawValue = this.internalValue?.format(this.dateTimeData.customFormat);\n }\n else\n {\n //TODO: add support for ranges\n }\n\n this.valueSet.next();\n }\n\n /**\n * @inheritdoc\n */\n public get disabled(): boolean\n {\n return this.elementRef.nativeElement.disabled;\n }\n public set disabled(value: boolean)\n {\n this.elementRef.nativeElement.disabled = value;\n }\n\n /**\n * Html element that represents input itself\n */\n public get element(): HTMLElement\n {\n return this.elementRef.nativeElement;\n }\n\n /**\n * @inheritdoc\n */\n public focus: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n /**\n * @inheritdoc\n */\n public blur: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n //######################### constructors #########################\n constructor(protected elementRef: ElementRef<HTMLInputElement>,\n @Inject(DATE_API) protected dateApi: DateApi<TDate>,\n protected valueProvider: DateValueProvider<TDate>,)\n {\n super();\n\n this.elementRef.nativeElement.addEventListener('input', this.handleInput);\n this.elementRef.nativeElement.addEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.addEventListener('blur', this.handleBlur);\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.elementRef.nativeElement.removeEventListener('input', this.handleInput);\n this.elementRef.nativeElement.removeEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.removeEventListener('blur', this.handleBlur);\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets internal value and fix lowest time difference\n * @param value - Value to be set\n * @param dateTimeFormat - Date time format type, optional, if not specified autodetection of format will be used, used when obtaining value from users input\n */\n protected setInternalValue(value: DateTimeInputOutputValue<TDate>|undefined|null,\n dateTimeFormat: DateTimeValueFormat|undefined|null = null,): void\n {\n this.internalValue = getInternalValue(value, this.dateApi, this.dateTimeData, this.valueProvider, dateTimeFormat);\n }\n\n /**\n * Handles input event on input\n */\n @BindThis\n protected handleInput(): void\n {\n if(!this.rawValue)\n {\n this.internalValue = null;\n this.ɵValue = null;\n\n this.valueSet.next();\n this.valueChange.next();\n\n return;\n }\n\n this.setInternalValue(this.rawValue, DateTimeValueFormat.FormattedString);\n this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat, this.dateTimeData.dataFormat);\n\n this.valueSet.next();\n this.valueChange.next();\n }\n\n /**\n * Handles focus event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleFocus(event: FocusEvent): void\n {\n this.focus.emit(event);\n }\n\n /**\n * Handles blur event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleBlur(event: FocusEvent): void\n {\n this.blur.emit(event);\n }\n}"]}
|