@anglr/datetime 6.0.0 → 6.1.0-beta.20230104111018

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.
Files changed (67) hide show
  1. package/changelog.md +19 -0
  2. package/es2015/src/directives/datePickerInput/datePickerInput.directive.js +37 -0
  3. package/es2015/src/directives/datePickerInput/datePickerInput.directive.js.map +1 -0
  4. package/es2015/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js +325 -0
  5. package/es2015/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js.map +1 -0
  6. package/es2015/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js +29 -0
  7. package/es2015/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js.map +1 -0
  8. package/es2015/src/directives/index.js +4 -0
  9. package/es2015/src/directives/index.js.map +1 -1
  10. package/es2015/src/directives/withNow/withNow.directive.js +44 -0
  11. package/es2015/src/directives/withNow/withNow.directive.js.map +1 -0
  12. package/es2015/src/directives/withToday/withToday.directive.js +6 -6
  13. package/es2015/src/directives/withToday/withToday.directive.js.map +1 -1
  14. package/es2015/src/misc/utils.js +52 -0
  15. package/es2015/src/misc/utils.js.map +1 -1
  16. package/es2015/src/modules/dateTime/directives/dateTime/dateTime.directive.js +32 -12
  17. package/es2015/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -1
  18. package/es2020/src/directives/datePickerInput/datePickerInput.directive.js +37 -0
  19. package/es2020/src/directives/datePickerInput/datePickerInput.directive.js.map +1 -0
  20. package/es2020/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js +322 -0
  21. package/es2020/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.js.map +1 -0
  22. package/es2020/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js +29 -0
  23. package/es2020/src/directives/dateTimePickerInput/dateTimePickerInput.directive.js.map +1 -0
  24. package/es2020/src/directives/index.js +4 -0
  25. package/es2020/src/directives/index.js.map +1 -1
  26. package/es2020/src/directives/withNow/withNow.directive.js +44 -0
  27. package/es2020/src/directives/withNow/withNow.directive.js.map +1 -0
  28. package/es2020/src/directives/withToday/withToday.directive.js +6 -6
  29. package/es2020/src/directives/withToday/withToday.directive.js.map +1 -1
  30. package/es2020/src/misc/utils.js +52 -0
  31. package/es2020/src/misc/utils.js.map +1 -1
  32. package/es2020/src/modules/dateTime/directives/dateTime/dateTime.directive.js +32 -12
  33. package/es2020/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/directives/datePickerInput/datePickerInput.directive.d.ts +12 -0
  36. package/src/directives/datePickerInput/datePickerInput.directive.d.ts.map +1 -0
  37. package/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.d.ts +86 -0
  38. package/src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.d.ts.map +1 -0
  39. package/src/directives/dateTimePickerInput/dateTimePickerInput.directive.d.ts +11 -0
  40. package/src/directives/dateTimePickerInput/dateTimePickerInput.directive.d.ts.map +1 -0
  41. package/src/directives/index.d.ts +4 -0
  42. package/src/directives/index.d.ts.map +1 -1
  43. package/src/directives/withNow/withNow.directive.d.ts +22 -0
  44. package/src/directives/withNow/withNow.directive.d.ts.map +1 -0
  45. package/src/directives/withToday/withToday.directive.d.ts +3 -2
  46. package/src/directives/withToday/withToday.directive.d.ts.map +1 -1
  47. package/src/misc/utils.d.ts +18 -1
  48. package/src/misc/utils.d.ts.map +1 -1
  49. package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts +19 -6
  50. package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts.map +1 -1
  51. package/version.bak +1 -1
  52. package/es2015/src/legacy/selector/components/inputDateTime/inputDateTime.component.js +0 -488
  53. package/es2015/src/legacy/selector/components/inputDateTime/inputDateTime.component.js.map +0 -1
  54. package/es2015/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +0 -367
  55. package/es2015/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +0 -1
  56. package/es2020/src/legacy/selector/components/inputDateTime/inputDateTime.component.js +0 -488
  57. package/es2020/src/legacy/selector/components/inputDateTime/inputDateTime.component.js.map +0 -1
  58. package/es2020/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +0 -367
  59. package/es2020/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +0 -1
  60. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.css +0 -9
  61. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.d.ts +0 -1
  62. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.d.ts.map +0 -1
  63. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.html +0 -10
  64. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.css +0 -9
  65. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts +0 -1
  66. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts.map +0 -1
  67. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.html +0 -9
package/changelog.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 6.1.0 (2023-01-04)
4
+
5
+ ### Bug Fixes
6
+
7
+ - fixed `WithTodaySADirective`
8
+ - now correctly sets value of date time to start of a current day
9
+
10
+ ### Features
11
+
12
+ - new `WithNowSADirective` directive, that sets current date and time as day and time for empty date time on focus
13
+ - new `DateTimeInputHandlerSADirective` directive, that adds handler for date time input, which allows navigation using keyboard and checking restriction of value
14
+ - new `DatePickerInputSADirective` directive, that combines date picker with date input
15
+ - new `DateTimePickerInputSADirective` directive, that combines date time picker with date time input
16
+ - new `parseRawInput` function, that parses raw value into internal value and value
17
+ - new `getInternalValue` function, gets internal value and fix lowest time difference
18
+ - updated `DateTimeSADirective` directive
19
+ - **new properties**
20
+ - `customFormatChanges` occurs when there are changes in custom format value
21
+
3
22
  ## Version 6.0.0 (2022-12-23)
4
23
 
5
24
  ### Features
@@ -0,0 +1,37 @@
1
+ import { Directive } from '@angular/core';
2
+ import { DateTimeInputSADirective, DateTimePickerSADirective } from '../../modules';
3
+ import { DateTimeInputHandlerSADirective } from '../dateTimeInputHandler/dateTimeInputHandler.directive';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "../../modules/dateTimePicker/directives/dateTimePicker/dateTimePicker.directive";
6
+ import * as i2 from "../../modules/dateTime/directives/dateTimeInput/dateTimeInput.directive";
7
+ import * as i3 from "../dateTimeInputHandler/dateTimeInputHandler.directive";
8
+ /**
9
+ * Directive that combines date picker with date input
10
+ */
11
+ export class DatePickerInputSADirective {
12
+ }
13
+ DatePickerInputSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DatePickerInputSADirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
14
+ DatePickerInputSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: DatePickerInputSADirective, isStandalone: true, selector: "input[dateTime][datePickerInput]", hostDirectives: [{ directive: i1.DateTimePickerSADirective, inputs: ["withPickerOptions", "withPickerOptions", "pickerOptions", "pickerOptions"] }, { directive: i2.DateTimeInputSADirective }, { directive: i3.DateTimeInputHandlerSADirective }], ngImport: i0 });
15
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DatePickerInputSADirective, decorators: [{
16
+ type: Directive,
17
+ args: [{
18
+ selector: 'input[dateTime][datePickerInput]',
19
+ standalone: true,
20
+ hostDirectives: [
21
+ {
22
+ directive: DateTimePickerSADirective,
23
+ inputs: [
24
+ 'withPickerOptions',
25
+ 'pickerOptions',
26
+ ]
27
+ },
28
+ {
29
+ directive: DateTimeInputSADirective,
30
+ },
31
+ {
32
+ directive: DateTimeInputHandlerSADirective,
33
+ },
34
+ ],
35
+ }]
36
+ }] });
37
+ //# sourceMappingURL=datePickerInput.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datePickerInput.directive.js","sourceRoot":"","sources":["../../../../src/directives/datePickerInput/datePickerInput.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EAAC,wBAAwB,EAAE,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAClF,OAAO,EAAC,+BAA+B,EAAC,MAAM,wDAAwD,CAAC;;;;;AAEvG;;GAEG;AAuBH,MAAM,OAAO,0BAA0B;;uHAA1B,0BAA0B;2GAA1B,0BAA0B;2FAA1B,0BAA0B;kBAtBtC,SAAS;mBACV;oBACI,QAAQ,EAAE,kCAAkC;oBAC5C,UAAU,EAAE,IAAI;oBAChB,cAAc,EACd;wBACI;4BACI,SAAS,EAAE,yBAAyB;4BACpC,MAAM,EACN;gCACI,mBAAmB;gCACnB,eAAe;6BAClB;yBACJ;wBACD;4BACI,SAAS,EAAE,wBAAwB;yBACtC;wBACD;4BACI,SAAS,EAAE,+BAA+B;yBAC7C;qBACJ;iBACJ","sourcesContent":["import {Directive} from '@angular/core';\n\nimport {DateTimeInputSADirective, DateTimePickerSADirective} from '../../modules';\nimport {DateTimeInputHandlerSADirective} from '../dateTimeInputHandler/dateTimeInputHandler.directive';\n\n/**\n * Directive that combines date picker with date input\n */\n@Directive(\n{\n selector: 'input[dateTime][datePickerInput]',\n standalone: true,\n hostDirectives:\n [\n {\n directive: DateTimePickerSADirective,\n inputs:\n [\n 'withPickerOptions',\n 'pickerOptions',\n ]\n },\n {\n directive: DateTimeInputSADirective,\n },\n {\n directive: DateTimeInputHandlerSADirective,\n },\n ],\n})\nexport class DatePickerInputSADirective\n{\n}"]}
@@ -0,0 +1,325 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Directive, Inject, Optional } from '@angular/core';
3
+ import { BindThis } from '@jscrpt/common';
4
+ import { Subscription } from 'rxjs';
5
+ import { DATE_API, DATE_TIME_INPUT } from '../../misc/tokens';
6
+ import { parseDateTime, parseRawInput } from '../../misc/utils';
7
+ import { DateTimePickerSADirective, DateTimeSADirective } from '../../modules';
8
+ import { DatePositionParserService, DateValueProvider } from '../../services';
9
+ import * as i0 from "@angular/core";
10
+ import * as i1 from "../../modules";
11
+ import * as i2 from "../../services";
12
+ /**
13
+ * Directive that adds handler for date time input, which allows navigation using keyboard and checking restriction of value
14
+ */
15
+ export class DateTimeInputHandlerSADirective {
16
+ //######################### constructor #########################
17
+ constructor(input, dateApi, dateTimeData, parserSvc, valueProvider, picker) {
18
+ this.input = input;
19
+ this.dateApi = dateApi;
20
+ this.dateTimeData = dateTimeData;
21
+ this.parserSvc = parserSvc;
22
+ this.valueProvider = valueProvider;
23
+ this.picker = picker;
24
+ //######################### protected properties #########################
25
+ /**
26
+ * Subscriptions created during initialization
27
+ */
28
+ this.initSubscriptions = new Subscription();
29
+ this.parser = parserSvc.createParser(this.dateTimeData.customFormat);
30
+ this.initSubscriptions.add(this.dateTimeData.customFormatChanges.subscribe(() => this.parser = parserSvc.createParser(this.dateTimeData.customFormat)));
31
+ }
32
+ /**
33
+ * Gets input element as html input
34
+ */
35
+ get inputElement() {
36
+ if (this.input.element.nodeName == 'INPUT') {
37
+ return this.input.element;
38
+ }
39
+ throw new Error('You cant use DateTimeInputHandlerSADirective without input element!');
40
+ }
41
+ //######################### public methods - implementation of OnInit #########################
42
+ /**
43
+ * Initialize component
44
+ */
45
+ ngOnInit() {
46
+ this.input.element.addEventListener('keydown', this.handleKeyboard);
47
+ this.input.element.addEventListener('keypress', this.handleKeypress);
48
+ this.input.element.addEventListener('select', this.handleSelect);
49
+ this.input.element.addEventListener('click', this.handleClick);
50
+ }
51
+ //######################### public methods - implementation of OnDestroy #########################
52
+ /**
53
+ * Called when component is destroyed
54
+ */
55
+ ngOnDestroy() {
56
+ this.initSubscriptions.unsubscribe();
57
+ this.input.element.removeEventListener('keydown', this.handleKeyboard);
58
+ this.input.element.removeEventListener('keypress', this.handleKeypress);
59
+ this.input.element.removeEventListener('select', this.handleSelect);
60
+ this.input.element.removeEventListener('click', this.handleClick);
61
+ }
62
+ //######################### protected methods #########################
63
+ /**
64
+ * Handles selection of text inside of input
65
+ */
66
+ handleSelect() {
67
+ this.runWithValue(() => {
68
+ //handles when all text is selected
69
+ if (this.inputElement.selectionStart == 0 && this.inputElement.selectionEnd == this.inputElement.value.length) {
70
+ const result = this.parser.parse(this.inputElement.value, this.inputElement.selectionStart);
71
+ this.inputElement.selectionStart = result.positionFrom;
72
+ this.inputElement.selectionEnd = result.positionTo;
73
+ }
74
+ }, () => {
75
+ //TODO: add support for ranges
76
+ });
77
+ }
78
+ /**
79
+ * Handles click event inside of input
80
+ */
81
+ handleClick() {
82
+ this.runWithValue(() => {
83
+ var _a;
84
+ const result = this.parser.parse(this.inputElement.value, (_a = this.inputElement.selectionStart) !== null && _a !== void 0 ? _a : 0);
85
+ this.inputElement.selectionStart = result.positionFrom;
86
+ this.inputElement.selectionEnd = result.positionTo;
87
+ }, () => {
88
+ //TODO: add support for ranges
89
+ });
90
+ }
91
+ /**
92
+ * Handles keyboard events
93
+ * @param event - Keyboard event that occured
94
+ */
95
+ handleKeypress(event) {
96
+ var _a, _b;
97
+ const selectionStart = (_a = this.inputElement.selectionStart) !== null && _a !== void 0 ? _a : 0;
98
+ const selectionEnd = (_b = this.inputElement.selectionEnd) !== null && _b !== void 0 ? _b : 0;
99
+ const newRawValueArray = this.inputElement.value.split('');
100
+ newRawValueArray.splice(selectionStart, selectionEnd - selectionStart);
101
+ newRawValueArray.splice(selectionStart, 0, ...event.key);
102
+ const newRawValue = newRawValueArray.join('');
103
+ const [parsedValue] = parseRawInput(newRawValue, this.dateApi, this.dateTimeData, this.valueProvider);
104
+ this.runWithValue(parsedValue => {
105
+ if (this.minMaxConstraintTest(parsedValue)) {
106
+ event.preventDefault();
107
+ event.stopPropagation();
108
+ }
109
+ }, () => {
110
+ //TODO: add support for ranges
111
+ }, parsedValue);
112
+ }
113
+ /**
114
+ * Handles keyboard events
115
+ * @param event - Keyboard event that occured
116
+ */
117
+ handleKeyboard(event) {
118
+ this.runWithValue(parsedValue => {
119
+ var _a, _b, _c;
120
+ const selectionStart = (_a = this.inputElement.selectionStart) !== null && _a !== void 0 ? _a : 0;
121
+ switch (event.key) {
122
+ case 'ArrowRight':
123
+ case 'ArrowLeft':
124
+ {
125
+ event.preventDefault();
126
+ event.stopPropagation();
127
+ const result = event.key == 'ArrowLeft' ? this.parser.previous(this.inputElement.value, selectionStart) : this.parser.next(this.inputElement.value, selectionStart);
128
+ if (result) {
129
+ this.inputElement.selectionStart = result.positionFrom;
130
+ this.inputElement.selectionEnd = result.positionTo;
131
+ }
132
+ break;
133
+ }
134
+ case 'ArrowUp':
135
+ case 'ArrowDown':
136
+ {
137
+ event.preventDefault();
138
+ event.stopPropagation();
139
+ let result = this.parser.parse(this.inputElement.value, selectionStart);
140
+ const selectionStartNew = result.positionFrom;
141
+ this.stepChangeValue(parsedValue, result.part, event.key == 'ArrowUp');
142
+ result = this.parser.parse(this.inputElement.value, selectionStartNew);
143
+ this.inputElement.selectionStart = result.positionFrom;
144
+ this.inputElement.selectionEnd = result.positionTo;
145
+ break;
146
+ }
147
+ case 'Tab':
148
+ {
149
+ const result = event.shiftKey ? this.parser.previous(this.inputElement.value, selectionStart) : this.parser.next(this.inputElement.value, selectionStart);
150
+ if (result) {
151
+ event.preventDefault();
152
+ event.stopPropagation();
153
+ this.inputElement.selectionStart = result.positionFrom;
154
+ this.inputElement.selectionEnd = result.positionTo;
155
+ }
156
+ break;
157
+ }
158
+ case 'a':
159
+ {
160
+ if (event.ctrlKey) {
161
+ event.preventDefault();
162
+ event.stopPropagation();
163
+ }
164
+ break;
165
+ }
166
+ case 'Backspace':
167
+ {
168
+ this.input.value = null;
169
+ this.input.valueChange.next();
170
+ break;
171
+ }
172
+ case 'Escape':
173
+ {
174
+ (_b = this.picker) === null || _b === void 0 ? void 0 : _b.hidePicker();
175
+ break;
176
+ }
177
+ case ' ':
178
+ {
179
+ if (event.ctrlKey) {
180
+ (_c = this.picker) === null || _c === void 0 ? void 0 : _c.showPicker();
181
+ }
182
+ break;
183
+ }
184
+ }
185
+ }, () => {
186
+ //TODO: add support for ranges
187
+ });
188
+ }
189
+ /**
190
+ * Tests whether are min or max constraint broken, returns true if constraint is broken
191
+ * @param value - Value to be tested
192
+ */
193
+ minMaxConstraintTest(value) {
194
+ return (!!this.dateTimeData.minDateTime && value.isBefore(this.dateTimeData.minDateTime)) ||
195
+ (!!this.dateTimeData.maxDateTime && value.isAfter(this.dateTimeData.maxDateTime));
196
+ }
197
+ /**
198
+ * Runs code with check whether min max constrains was broken
199
+ * @param value - Value to be used checked for constrains
200
+ * @param code - Code that should be executed which can change current value
201
+ */
202
+ withMinMaxConstraint(value, code) {
203
+ value.updateOriginal();
204
+ code();
205
+ //min value constraint failure
206
+ if (this.minMaxConstraintTest(value)) {
207
+ value.resetOriginal();
208
+ }
209
+ //value has changed, change input value
210
+ if (!value.isSame(value.originalValue)) {
211
+ this.input.value = value.value;
212
+ this.input.valueChange.next();
213
+ }
214
+ }
215
+ /**
216
+ * Runs code for existing and valid value of date time
217
+ * @param singleValueCode - Code to be run when only single value can be inside of date time
218
+ * @param rangeValueCode - Code to be run when range value can be inside of date time
219
+ * @param parsedValueDefault - Default parsed value to be used
220
+ */
221
+ runWithValue(singleValueCode, rangeValueCode, parsedValueDefault) {
222
+ const parsedValue = parsedValueDefault !== null && parsedValueDefault !== void 0 ? parsedValueDefault : parseDateTime(this.input.value, this.dateApi, null, this.dateTimeData.customFormat);
223
+ if (!parsedValue) {
224
+ return;
225
+ }
226
+ if (Array.isArray(parsedValue)) {
227
+ rangeValueCode(parsedValue);
228
+ }
229
+ else {
230
+ //do nothing for invalid value
231
+ if (!parsedValue.isValid()) {
232
+ return;
233
+ }
234
+ singleValueCode(parsedValue);
235
+ }
236
+ }
237
+ /**
238
+ * Changes current value of date for for specified part by single step
239
+ * @param value - Value to be used checked for constrains
240
+ * @param part - Part of date that should be changed
241
+ * @param increment - Indication whether value should be incremented or decremented
242
+ */
243
+ stepChangeValue(value, part, increment) {
244
+ switch (part) {
245
+ case 'y':
246
+ case 'Y':
247
+ {
248
+ this.withMinMaxConstraint(value, () => increment ? value.addYears(1) : value.subtractYears(1));
249
+ break;
250
+ }
251
+ case 'Q':
252
+ {
253
+ break;
254
+ }
255
+ case 'M':
256
+ {
257
+ this.withMinMaxConstraint(value, () => increment ? value.addMonths(1) : value.subtractMonths(1));
258
+ break;
259
+ }
260
+ case 'w':
261
+ {
262
+ this.withMinMaxConstraint(value, () => increment ? value.addWeeks(1) : value.subtractWeeks(1));
263
+ break;
264
+ }
265
+ case 'd':
266
+ case 'D':
267
+ {
268
+ this.withMinMaxConstraint(value, () => increment ? value.addDays(1) : value.subtractDays(1));
269
+ break;
270
+ }
271
+ case 'H':
272
+ {
273
+ this.withMinMaxConstraint(value, () => increment ? value.addHours(1) : value.subtractHours(1));
274
+ break;
275
+ }
276
+ case 'm':
277
+ {
278
+ this.withMinMaxConstraint(value, () => increment ? value.addMinutes(1) : value.subtractMinutes(1));
279
+ break;
280
+ }
281
+ }
282
+ }
283
+ }
284
+ DateTimeInputHandlerSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DateTimeInputHandlerSADirective, deps: [{ token: DATE_TIME_INPUT }, { token: DATE_API }, { token: i1.DateTimeSADirective }, { token: i2.DatePositionParserService }, { token: i2.DateValueProvider }, { token: i1.DateTimePickerSADirective, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
285
+ DateTimeInputHandlerSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: DateTimeInputHandlerSADirective, isStandalone: true, selector: "[dateTime][withHandler]", ngImport: i0 });
286
+ __decorate([
287
+ BindThis,
288
+ __metadata("design:type", Function),
289
+ __metadata("design:paramtypes", []),
290
+ __metadata("design:returntype", void 0)
291
+ ], DateTimeInputHandlerSADirective.prototype, "handleSelect", null);
292
+ __decorate([
293
+ BindThis,
294
+ __metadata("design:type", Function),
295
+ __metadata("design:paramtypes", []),
296
+ __metadata("design:returntype", void 0)
297
+ ], DateTimeInputHandlerSADirective.prototype, "handleClick", null);
298
+ __decorate([
299
+ BindThis,
300
+ __metadata("design:type", Function),
301
+ __metadata("design:paramtypes", [KeyboardEvent]),
302
+ __metadata("design:returntype", void 0)
303
+ ], DateTimeInputHandlerSADirective.prototype, "handleKeypress", null);
304
+ __decorate([
305
+ BindThis,
306
+ __metadata("design:type", Function),
307
+ __metadata("design:paramtypes", [KeyboardEvent]),
308
+ __metadata("design:returntype", void 0)
309
+ ], DateTimeInputHandlerSADirective.prototype, "handleKeyboard", null);
310
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DateTimeInputHandlerSADirective, decorators: [{
311
+ type: Directive,
312
+ args: [{
313
+ selector: '[dateTime][withHandler]',
314
+ standalone: true,
315
+ }]
316
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
317
+ type: Inject,
318
+ args: [DATE_TIME_INPUT]
319
+ }] }, { type: undefined, decorators: [{
320
+ type: Inject,
321
+ args: [DATE_API]
322
+ }] }, { type: i1.DateTimeSADirective }, { type: i2.DatePositionParserService }, { type: i2.DateValueProvider }, { type: i1.DateTimePickerSADirective, decorators: [{
323
+ type: Optional
324
+ }] }]; }, propDecorators: { handleSelect: [], handleClick: [], handleKeypress: [], handleKeyboard: [] } });
325
+ //# sourceMappingURL=dateTimeInputHandler.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateTimeInputHandler.directive.js","sourceRoot":"","sources":["../../../../src/directives/dateTimeInputHandler/dateTimeInputHandler.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAqB,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAU,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,YAAY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MD;IAAC,QAAQ;;qCACuB,aAAa;;qEAwB5C;AAMD;IAAC,QAAQ;;qCACuB,aAAa;;qEA+F5C;2FAjPQ,+BAA+B;kBAL3C,SAAS;mBACV;oBACI,QAAQ,EAAE,yBAAyB;oBACnC,UAAU,EAAE,IAAI;iBACnB;;0BA6BgB,MAAM;2BAAC,eAAe;;0BACtB,MAAM;2BAAC,QAAQ;;0BAIf,QAAQ;4CAuCX,YAAY,MAuBZ,WAAW,MAoBX,cAAc,MA+Bd,cAAc","sourcesContent":["import {Directive, Inject, OnDestroy, OnInit, Optional} from '@angular/core';\nimport {Action1, BindThis} from '@jscrpt/common';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeInput} from '../../interfaces';\nimport {DATE_API, DATE_TIME_INPUT} from '../../misc/tokens';\nimport {DateTimeObjectValue} from '../../misc/types';\nimport {parseDateTime, parseRawInput} from '../../misc/utils';\nimport {DateTimePickerSADirective, DateTimeSADirective} from '../../modules';\nimport {DateApi, DateApiObject, DatePositionParser, DatePositionParserService, DateValueProvider} from '../../services';\n\n/**\n * Directive that adds handler for date time input, which allows navigation using keyboard and checking restriction of value\n */\n@Directive(\n{\n selector: '[dateTime][withHandler]',\n standalone: true,\n})\nexport class DateTimeInputHandlerSADirective<TDate = unknown> implements OnInit, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n /**\n * Instance of parser created for specific format\n */\n protected parser: DatePositionParser;\n\n /**\n * Gets input element as html input\n */\n protected get inputElement(): HTMLInputElement\n {\n if(this.input.element.nodeName == 'INPUT')\n {\n return this.input.element as HTMLInputElement;\n }\n\n throw new Error('You cant use DateTimeInputHandlerSADirective without input element!');\n }\n\n //######################### constructor #########################\n constructor(@Inject(DATE_TIME_INPUT) protected input: DateTimeInput<TDate>,\n @Inject(DATE_API) protected dateApi: DateApi<TDate>,\n protected dateTimeData: DateTimeSADirective<TDate>,\n protected parserSvc: DatePositionParserService,\n protected valueProvider: DateValueProvider<TDate>,\n @Optional() protected picker?: DateTimePickerSADirective<TDate>,)\n {\n this.parser = parserSvc.createParser(this.dateTimeData.customFormat);\n this.initSubscriptions.add(this.dateTimeData.customFormatChanges.subscribe(() => this.parser = parserSvc.createParser(this.dateTimeData.customFormat)));\n }\n\n //######################### public methods - implementation of OnInit #########################\n \n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this.input.element.addEventListener('keydown', this.handleKeyboard);\n this.input.element.addEventListener('keypress', this.handleKeypress);\n this.input.element.addEventListener('select', this.handleSelect);\n this.input.element.addEventListener('click', this.handleClick);\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 this.input.element.removeEventListener('keydown', this.handleKeyboard);\n this.input.element.removeEventListener('keypress', this.handleKeypress);\n this.input.element.removeEventListener('select', this.handleSelect);\n this.input.element.removeEventListener('click', this.handleClick);\n }\n\n //######################### protected methods #########################\n\n /**\n * Handles selection of text inside of input\n */\n @BindThis\n protected handleSelect(): void\n {\n this.runWithValue(() =>\n {\n //handles when all text is selected\n if(this.inputElement.selectionStart == 0 && this.inputElement.selectionEnd == this.inputElement.value.length)\n {\n const result = this.parser.parse(this.inputElement.value, this.inputElement.selectionStart);\n \n this.inputElement.selectionStart = result.positionFrom;\n this.inputElement.selectionEnd = result.positionTo;\n }\n },\n () =>\n {\n //TODO: add support for ranges\n });\n }\n\n /**\n * Handles click event inside of input\n */\n @BindThis\n protected handleClick(): void\n {\n this.runWithValue(() =>\n {\n const result = this.parser.parse(this.inputElement.value, this.inputElement.selectionStart ?? 0);\n \n this.inputElement.selectionStart = result.positionFrom;\n this.inputElement.selectionEnd = result.positionTo;\n },\n () =>\n {\n //TODO: add support for ranges\n });\n }\n\n /**\n * Handles keyboard events\n * @param event - Keyboard event that occured\n */\n @BindThis\n protected handleKeypress(event: KeyboardEvent): void\n {\n const selectionStart = this.inputElement.selectionStart ?? 0;\n const selectionEnd = this.inputElement.selectionEnd ?? 0;\n const newRawValueArray = this.inputElement.value.split('');\n newRawValueArray.splice(selectionStart , selectionEnd - selectionStart);\n newRawValueArray.splice(selectionStart, 0, ...event.key);\n const newRawValue = newRawValueArray.join('');\n\n const [parsedValue] = parseRawInput(newRawValue, this.dateApi, this.dateTimeData, this.valueProvider);\n\n this.runWithValue(parsedValue =>\n {\n if(this.minMaxConstraintTest(parsedValue))\n {\n event.preventDefault();\n event.stopPropagation();\n }\n },\n () =>\n {\n //TODO: add support for ranges\n },\n parsedValue);\n }\n\n /**\n * Handles keyboard events\n * @param event - Keyboard event that occured\n */\n @BindThis\n protected handleKeyboard(event: KeyboardEvent): void\n {\n this.runWithValue(parsedValue =>\n {\n const selectionStart = this.inputElement.selectionStart ?? 0;\n\n switch(event.key)\n {\n case 'ArrowRight':\n case 'ArrowLeft':\n {\n event.preventDefault();\n event.stopPropagation();\n \n const result = event.key == 'ArrowLeft' ? this.parser.previous(this.inputElement.value, selectionStart) : this.parser.next(this.inputElement.value, selectionStart);\n \n if(result)\n {\n this.inputElement.selectionStart = result.positionFrom;\n this.inputElement.selectionEnd = result.positionTo;\n }\n \n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n {\n event.preventDefault();\n event.stopPropagation();\n \n let result = this.parser.parse(this.inputElement.value, selectionStart);\n const selectionStartNew = result.positionFrom;\n \n this.stepChangeValue(parsedValue, result.part, event.key == 'ArrowUp');\n \n result = this.parser.parse(this.inputElement.value, selectionStartNew);\n \n this.inputElement.selectionStart = result.positionFrom;\n this.inputElement.selectionEnd = result.positionTo;\n \n break;\n }\n case 'Tab':\n {\n const result = event.shiftKey ? this.parser.previous(this.inputElement.value, selectionStart) : this.parser.next(this.inputElement.value, selectionStart);\n \n if(result)\n {\n event.preventDefault();\n event.stopPropagation();\n \n this.inputElement.selectionStart = result.positionFrom;\n this.inputElement.selectionEnd = result.positionTo;\n }\n \n break;\n }\n case 'a':\n {\n if(event.ctrlKey)\n {\n event.preventDefault();\n event.stopPropagation();\n }\n \n break;\n }\n case 'Backspace':\n {\n this.input.value = null;\n this.input.valueChange.next();\n \n break;\n }\n case 'Escape':\n {\n this.picker?.hidePicker();\n \n break;\n }\n case ' ':\n {\n if(event.ctrlKey)\n {\n this.picker?.showPicker();\n }\n \n break;\n }\n }\n },\n () =>\n {\n //TODO: add support for ranges\n });\n }\n\n /**\n * Tests whether are min or max constraint broken, returns true if constraint is broken\n * @param value - Value to be tested\n */\n protected minMaxConstraintTest(value: DateApiObject<TDate>): boolean\n {\n return (!!this.dateTimeData.minDateTime && value.isBefore(this.dateTimeData.minDateTime)) ||\n (!!this.dateTimeData.maxDateTime && value.isAfter(this.dateTimeData.maxDateTime));\n }\n\n /**\n * Runs code with check whether min max constrains was broken\n * @param value - Value to be used checked for constrains\n * @param code - Code that should be executed which can change current value\n */\n protected withMinMaxConstraint(value: DateApiObject<TDate>, code: () => void): void\n {\n value.updateOriginal();\n\n code();\n\n //min value constraint failure\n if(this.minMaxConstraintTest(value))\n {\n value.resetOriginal();\n }\n\n //value has changed, change input value\n if(!value.isSame(value.originalValue))\n {\n this.input.value = value.value;\n this.input.valueChange.next();\n }\n }\n\n /**\n * Runs code for existing and valid value of date time\n * @param singleValueCode - Code to be run when only single value can be inside of date time\n * @param rangeValueCode - Code to be run when range value can be inside of date time\n * @param parsedValueDefault - Default parsed value to be used\n */\n protected runWithValue(singleValueCode: Action1<DateApiObject<TDate>>, rangeValueCode: Action1<[DateApiObject<TDate> | null, DateApiObject<TDate> | null]>, parsedValueDefault?: DateTimeObjectValue<TDate>|undefined|null): void\n {\n const parsedValue = parsedValueDefault ?? parseDateTime(this.input.value, this.dateApi, null, this.dateTimeData.customFormat);\n\n if(!parsedValue)\n {\n return;\n }\n\n if(Array.isArray(parsedValue))\n {\n rangeValueCode(parsedValue);\n }\n else\n {\n //do nothing for invalid value\n if(!parsedValue.isValid())\n {\n return;\n }\n\n singleValueCode(parsedValue);\n }\n }\n\n /**\n * Changes current value of date for for specified part by single step\n * @param value - Value to be used checked for constrains\n * @param part - Part of date that should be changed\n * @param increment - Indication whether value should be incremented or decremented\n */\n protected stepChangeValue(value: DateApiObject<TDate>, part: string, increment: boolean): void\n {\n switch(part)\n {\n case 'y':\n case 'Y':\n {\n this.withMinMaxConstraint(value, () => increment ? value.addYears(1) : value.subtractYears(1));\n\n break;\n }\n case 'Q':\n {\n break;\n }\n case 'M':\n {\n this.withMinMaxConstraint(value, () => increment ? value.addMonths(1) : value.subtractMonths(1));\n\n break;\n }\n case 'w':\n {\n this.withMinMaxConstraint(value, () => increment ? value.addWeeks(1) : value.subtractWeeks(1));\n\n break;\n }\n case 'd':\n case 'D':\n {\n this.withMinMaxConstraint(value, () => increment ? value.addDays(1) : value.subtractDays(1));\n\n break;\n }\n case 'H':\n {\n this.withMinMaxConstraint(value, () => increment ? value.addHours(1) : value.subtractHours(1));\n\n break;\n }\n case 'm':\n {\n this.withMinMaxConstraint(value, () => increment ? value.addMinutes(1) : value.subtractMinutes(1));\n\n break;\n }\n }\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { Directive } from '@angular/core';
2
+ import { DatePickerInputSADirective } from '../datePickerInput/datePickerInput.directive';
3
+ import { WithTimeSADirective } from '../withTime/withTime.directive';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "../datePickerInput/datePickerInput.directive";
6
+ import * as i2 from "../withTime/withTime.directive";
7
+ /**
8
+ * Directive that combines date time picker with date time input
9
+ */
10
+ export class DateTimePickerInputSADirective {
11
+ }
12
+ DateTimePickerInputSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DateTimePickerInputSADirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
13
+ DateTimePickerInputSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: DateTimePickerInputSADirective, isStandalone: true, selector: "input[dateTime][dateTimePickerInput]", hostDirectives: [{ directive: i1.DatePickerInputSADirective }, { directive: i2.WithTimeSADirective }], ngImport: i0 });
14
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: DateTimePickerInputSADirective, decorators: [{
15
+ type: Directive,
16
+ args: [{
17
+ selector: 'input[dateTime][dateTimePickerInput]',
18
+ standalone: true,
19
+ hostDirectives: [
20
+ {
21
+ directive: DatePickerInputSADirective,
22
+ },
23
+ {
24
+ directive: WithTimeSADirective,
25
+ },
26
+ ],
27
+ }]
28
+ }] });
29
+ //# sourceMappingURL=dateTimePickerInput.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateTimePickerInput.directive.js","sourceRoot":"","sources":["../../../../src/directives/dateTimePickerInput/dateTimePickerInput.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EAAC,0BAA0B,EAAC,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;;;;AAEnE;;GAEG;AAeH,MAAM,OAAO,8BAA8B;;2HAA9B,8BAA8B;+GAA9B,8BAA8B;2FAA9B,8BAA8B;kBAd1C,SAAS;mBACV;oBACI,QAAQ,EAAE,sCAAsC;oBAChD,UAAU,EAAE,IAAI;oBAChB,cAAc,EACd;wBACI;4BACI,SAAS,EAAE,0BAA0B;yBACxC;wBACD;4BACI,SAAS,EAAE,mBAAmB;yBACjC;qBACJ;iBACJ","sourcesContent":["import {Directive} from '@angular/core';\n\nimport {DatePickerInputSADirective} from '../datePickerInput/datePickerInput.directive';\nimport {WithTimeSADirective} from '../withTime/withTime.directive';\n\n/**\n * Directive that combines date time picker with date time input\n */\n@Directive(\n{\n selector: 'input[dateTime][dateTimePickerInput]',\n standalone: true,\n hostDirectives:\n [\n {\n directive: DatePickerInputSADirective,\n },\n {\n directive: WithTimeSADirective,\n },\n ],\n})\nexport class DateTimePickerInputSADirective\n{\n}"]}
@@ -1,6 +1,10 @@
1
+ export * from './datePickerInput/datePickerInput.directive';
2
+ export * from './dateTimeInputHandler/dateTimeInputHandler.directive';
3
+ export * from './dateTimePickerInput/dateTimePickerInput.directive';
1
4
  export * from './simpleDatePickerInput/simpleDatePickerInput.directive';
2
5
  export * from './simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive';
3
6
  export * from './simpleDateTimePickerInput/simpleDateTimePickerInput.directive';
7
+ export * from './withNow/withNow.directive';
4
8
  export * from './withTime/withTime.directive';
5
9
  export * from './withToday/withToday.directive';
6
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,yDAAyD,CAAC;AACxE,cAAc,mEAAmE,CAAC;AAClF,cAAc,iEAAiE,CAAC;AAChF,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './simpleDatePickerInput/simpleDatePickerInput.directive';\nexport * from './simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive';\nexport * from './simpleDateTimePickerInput/simpleDateTimePickerInput.directive';\nexport * from './withTime/withTime.directive';\nexport * from './withToday/withToday.directive';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,yDAAyD,CAAC;AACxE,cAAc,mEAAmE,CAAC;AAClF,cAAc,iEAAiE,CAAC;AAChF,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './datePickerInput/datePickerInput.directive';\nexport * from './dateTimeInputHandler/dateTimeInputHandler.directive';\nexport * from './dateTimePickerInput/dateTimePickerInput.directive';\nexport * from './simpleDatePickerInput/simpleDatePickerInput.directive';\nexport * from './simpleDateTimeInputHandler/simpleDateTimeInputHandler.directive';\nexport * from './simpleDateTimePickerInput/simpleDateTimePickerInput.directive';\nexport * from './withNow/withNow.directive';\nexport * from './withTime/withTime.directive';\nexport * from './withToday/withToday.directive';\n"]}
@@ -0,0 +1,44 @@
1
+ import { Directive, Inject } from '@angular/core';
2
+ import { Subscription } from 'rxjs';
3
+ import { DATE_API } from '../../misc/tokens';
4
+ import { DateTimeInputSADirective } from '../../modules';
5
+ import * as i0 from "@angular/core";
6
+ import * as i1 from "../../modules";
7
+ /**
8
+ * Directive that sets current date and time as day and time for empty date time on focus
9
+ */
10
+ export class WithNowSADirective {
11
+ //######################### constructor #########################
12
+ constructor(input, dateApi) {
13
+ //######################### protected fields #########################
14
+ /**
15
+ * Subscriptions created during initialization
16
+ */
17
+ this.initSubscriptions = new Subscription();
18
+ this.initSubscriptions.add(input.focus.subscribe(() => {
19
+ if (!input.value) {
20
+ input.value = dateApi.now().value;
21
+ }
22
+ }));
23
+ }
24
+ //######################### public methods - implementation of OnDestroy #########################
25
+ /**
26
+ * Called when component is destroyed
27
+ */
28
+ ngOnDestroy() {
29
+ this.initSubscriptions.unsubscribe();
30
+ }
31
+ }
32
+ WithNowSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: WithNowSADirective, deps: [{ token: i1.DateTimeInputSADirective }, { token: DATE_API }], target: i0.ɵɵFactoryTarget.Directive });
33
+ WithNowSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: WithNowSADirective, isStandalone: true, selector: "[dateTime][withNow]", ngImport: i0 });
34
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: WithNowSADirective, decorators: [{
35
+ type: Directive,
36
+ args: [{
37
+ selector: '[dateTime][withNow]',
38
+ standalone: true,
39
+ }]
40
+ }], ctorParameters: function () { return [{ type: i1.DateTimeInputSADirective }, { type: undefined, decorators: [{
41
+ type: Inject,
42
+ args: [DATE_API]
43
+ }] }]; } });
44
+ //# sourceMappingURL=withNow.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withNow.directive.js","sourceRoot":"","sources":["../../../../src/directives/withNow/withNow.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,eAAe,CAAC;;;AAGvD;;GAEG;AAMH,MAAM,OAAO,kBAAkB;IAS3B,iEAAiE;IACjE,YAAY,KAAsC,EACpB,OAAuB;QATrD,sEAAsE;QAEtE;;WAEG;QACO,sBAAiB,GAAiB,IAAI,YAAY,EAAE,CAAC;QAM3D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YAElD,IAAG,CAAC,KAAK,CAAC,KAAK,EACf;gBACI,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;aACrC;QACL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;IAED,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;;+GA9BQ,kBAAkB,0DAWP,QAAQ;mGAXnB,kBAAkB;2FAAlB,kBAAkB;kBAL9B,SAAS;mBACV;oBACI,QAAQ,EAAE,qBAAqB;oBAC/B,UAAU,EAAE,IAAI;iBACnB;;0BAYgB,MAAM;2BAAC,QAAQ","sourcesContent":["import {Directive, Inject, OnDestroy} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {DATE_API} from '../../misc/tokens';\nimport {DateTimeInputSADirective} from '../../modules';\nimport {DateApi} from '../../services';\n\n/**\n * Directive that sets current date and time as day and time for empty date time on focus\n */\n@Directive(\n{\n selector: '[dateTime][withNow]',\n standalone: true,\n})\nexport class WithNowSADirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n //######################### constructor #########################\n constructor(input: DateTimeInputSADirective<TDate>,\n @Inject(DATE_API) dateApi: DateApi<TDate>,)\n {\n this.initSubscriptions.add(input.focus.subscribe(() =>\n {\n if(!input.value)\n {\n input.value = dateApi.now().value;\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.initSubscriptions.unsubscribe();\n }\n}"]}
@@ -5,19 +5,19 @@ import { DateTimeInputSADirective } from '../../modules';
5
5
  import * as i0 from "@angular/core";
6
6
  import * as i1 from "../../modules";
7
7
  /**
8
- * Directive that sets today as day for empty date time on focus
8
+ * Directive that sets today (start of a day) as day for empty date time on focus
9
9
  */
10
10
  export class WithTodaySADirective {
11
11
  //######################### constructor #########################
12
12
  constructor(input, dateApi) {
13
- //######################### private fields #########################
13
+ //######################### protected fields #########################
14
14
  /**
15
15
  * Subscriptions created during initialization
16
16
  */
17
- this._initSubscriptions = new Subscription();
18
- this._initSubscriptions.add(input.focus.subscribe(() => {
17
+ this.initSubscriptions = new Subscription();
18
+ this.initSubscriptions.add(input.focus.subscribe(() => {
19
19
  if (!input.value) {
20
- input.value = dateApi.now().value;
20
+ input.value = dateApi.now().startOfDay().value;
21
21
  }
22
22
  }));
23
23
  }
@@ -26,7 +26,7 @@ export class WithTodaySADirective {
26
26
  * Called when component is destroyed
27
27
  */
28
28
  ngOnDestroy() {
29
- this._initSubscriptions.unsubscribe();
29
+ this.initSubscriptions.unsubscribe();
30
30
  }
31
31
  }
32
32
  WithTodaySADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: WithTodaySADirective, deps: [{ token: i1.DateTimeInputSADirective }, { token: DATE_API }], target: i0.ɵɵFactoryTarget.Directive });
@@ -1 +1 @@
1
- {"version":3,"file":"withToday.directive.js","sourceRoot":"","sources":["../../../../src/directives/withToday/withToday.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,eAAe,CAAC;;;AAGvD;;GAEG;AAMH,MAAM,OAAO,oBAAoB;IAS7B,iEAAiE;IACjE,YAAY,KAAsC,EACpB,OAAuB;QATrD,oEAAoE;QAEpE;;WAEG;QACK,uBAAkB,GAAiB,IAAI,YAAY,EAAE,CAAC;QAM1D,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YAEnD,IAAG,CAAC,KAAK,CAAC,KAAK,EACf;gBACI,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;aACrC;QACL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;IAED,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;;iHA9BQ,oBAAoB,0DAWT,QAAQ;qGAXnB,oBAAoB;2FAApB,oBAAoB;kBALhC,SAAS;mBACV;oBACI,QAAQ,EAAE,uBAAuB;oBACjC,UAAU,EAAE,IAAI;iBACnB;;0BAYgB,MAAM;2BAAC,QAAQ","sourcesContent":["import {Directive, Inject, OnDestroy} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {DATE_API} from '../../misc/tokens';\nimport {DateTimeInputSADirective} from '../../modules';\nimport {DateApi} from '../../services';\n\n/**\n * Directive that sets today as day for empty date time on focus\n */\n@Directive(\n{\n selector: '[dateTime][withToday]',\n standalone: true,\n})\nexport class WithTodaySADirective<TDate = unknown> implements OnDestroy\n{\n //######################### private fields #########################\n\n /**\n * Subscriptions created during initialization\n */\n private _initSubscriptions: Subscription = new Subscription();\n\n //######################### constructor #########################\n constructor(input: DateTimeInputSADirective<TDate>,\n @Inject(DATE_API) dateApi: DateApi<TDate>,)\n {\n this._initSubscriptions.add(input.focus.subscribe(() =>\n {\n if(!input.value)\n {\n input.value = dateApi.now().value;\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._initSubscriptions.unsubscribe();\n }\n}"]}
1
+ {"version":3,"file":"withToday.directive.js","sourceRoot":"","sources":["../../../../src/directives/withToday/withToday.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,eAAe,CAAC;;;AAGvD;;GAEG;AAMH,MAAM,OAAO,oBAAoB;IAS7B,iEAAiE;IACjE,YAAY,KAAsC,EACpB,OAAuB;QATrD,sEAAsE;QAEtE;;WAEG;QACO,sBAAiB,GAAiB,IAAI,YAAY,EAAE,CAAC;QAM3D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YAElD,IAAG,CAAC,KAAK,CAAC,KAAK,EACf;gBACI,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC;aAClD;QACL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;IAED,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;;iHA9BQ,oBAAoB,0DAWT,QAAQ;qGAXnB,oBAAoB;2FAApB,oBAAoB;kBALhC,SAAS;mBACV;oBACI,QAAQ,EAAE,uBAAuB;oBACjC,UAAU,EAAE,IAAI;iBACnB;;0BAYgB,MAAM;2BAAC,QAAQ","sourcesContent":["import {Directive, Inject, OnDestroy} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {DATE_API} from '../../misc/tokens';\nimport {DateTimeInputSADirective} from '../../modules';\nimport {DateApi} from '../../services';\n\n/**\n * Directive that sets today (start of a day) as day for empty date time on focus\n */\n@Directive(\n{\n selector: '[dateTime][withToday]',\n standalone: true,\n})\nexport class WithTodaySADirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n //######################### constructor #########################\n constructor(input: DateTimeInputSADirective<TDate>,\n @Inject(DATE_API) dateApi: DateApi<TDate>,)\n {\n this.initSubscriptions.add(input.focus.subscribe(() =>\n {\n if(!input.value)\n {\n input.value = dateApi.now().startOfDay().value;\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.initSubscriptions.unsubscribe();\n }\n}"]}