@progress/kendo-dateinputs-common 0.2.0-dev.202301231327 → 0.2.0-dev.202301241303
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/dist/cdn/js/kendo-dateinputs-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/dateobject.js +26 -52
- package/dist/es/dateinput/dateinput.js +147 -128
- package/dist/es/dateinput/utils.js +2 -2
- package/dist/es2015/common/dateobject.js +26 -51
- package/dist/es2015/dateinput/dateinput.js +147 -128
- package/dist/es2015/dateinput/utils.js +2 -2
- package/dist/npm/common/dateobject.js +26 -52
- package/dist/npm/dateinput/dateinput.d.ts +9 -1
- package/dist/npm/dateinput/dateinput.js +147 -128
- package/dist/npm/dateinput/utils.js +2 -2
- package/dist/systemjs/kendo-dateinputs-common.js +1 -1
- package/package.json +1 -1
|
@@ -9,9 +9,9 @@ export declare class DateInput extends Observable {
|
|
|
9
9
|
private resetSegmentValue;
|
|
10
10
|
private isActive;
|
|
11
11
|
private interactionMode;
|
|
12
|
-
private formatStateOnKeyDown;
|
|
13
12
|
private previousElementValue;
|
|
14
13
|
private previousElementSelection;
|
|
14
|
+
private switchedPartOnPreviousKeyAction;
|
|
15
15
|
private keyDownEvent;
|
|
16
16
|
private isPasteInProgress;
|
|
17
17
|
private mouseDownStarted;
|
|
@@ -172,6 +172,10 @@ export declare class DateInput extends Observable {
|
|
|
172
172
|
* @hidden
|
|
173
173
|
*/
|
|
174
174
|
forceUpdate(): void;
|
|
175
|
+
/**
|
|
176
|
+
* @hidden
|
|
177
|
+
*/
|
|
178
|
+
forceUpdateWithSelection(): void;
|
|
175
179
|
/**
|
|
176
180
|
* @hidden
|
|
177
181
|
*/
|
|
@@ -213,4 +217,8 @@ export declare class DateInput extends Observable {
|
|
|
213
217
|
* @hidden
|
|
214
218
|
*/
|
|
215
219
|
createDateObject(options?: {}): DateObject;
|
|
220
|
+
/**
|
|
221
|
+
* @hidden
|
|
222
|
+
*/
|
|
223
|
+
keyEventMatchesAutoSwitchKeys(keyObject: any): boolean;
|
|
216
224
|
}
|
|
@@ -32,7 +32,6 @@ var FOCUS_END = "focusEnd";
|
|
|
32
32
|
var CHANGE = "change";
|
|
33
33
|
var defaultDateInputOptions = {
|
|
34
34
|
format: "d",
|
|
35
|
-
allowNulls: false,
|
|
36
35
|
hasPlaceholder: false,
|
|
37
36
|
placeholder: null,
|
|
38
37
|
cycleTime: true,
|
|
@@ -60,6 +59,7 @@ var defaultDateInputOptions = {
|
|
|
60
59
|
_a[CHANGE] = null,
|
|
61
60
|
_a),
|
|
62
61
|
selectNearestSegmentOnFocus: false,
|
|
62
|
+
selectPreviousSegmentOnBackspace: false,
|
|
63
63
|
enableMouseWheel: false,
|
|
64
64
|
allowCaretMode: false,
|
|
65
65
|
autoSwitchParts: true,
|
|
@@ -213,6 +213,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
213
213
|
*/
|
|
214
214
|
DateInput.prototype.onElementClick = function (e) {
|
|
215
215
|
this.mouseDownStarted = false;
|
|
216
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
216
217
|
var selection = this.selection;
|
|
217
218
|
if (this.isInCaretMode()) {
|
|
218
219
|
// explicitly refresh the input element value
|
|
@@ -245,12 +246,10 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
245
246
|
*/
|
|
246
247
|
DateInput.prototype.onElementInput = function (e) {
|
|
247
248
|
this.triggerInput({ event: e });
|
|
248
|
-
var keyDownEvent = this.keyDownEvent || {};
|
|
249
|
-
var isBackspaceKey = keyDownEvent.keyCode === keycode_1.KeyCode.BACKSPACE || keyDownEvent.key === key_1.Key.BACKSPACE;
|
|
250
|
-
var isDeleteKey = keyDownEvent.keyCode === keycode_1.KeyCode.DELETE || keyDownEvent.key === key_1.Key.DELETE;
|
|
251
249
|
if (!this.element || !this.dateObject) {
|
|
252
250
|
return;
|
|
253
251
|
}
|
|
252
|
+
var switchedPartOnPreviousKeyAction = this.switchedPartOnPreviousKeyAction;
|
|
254
253
|
if (this.isPasteInProgress) {
|
|
255
254
|
if (this.options.allowCaretMode) {
|
|
256
255
|
// pasting should leave the input with caret
|
|
@@ -261,6 +260,9 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
261
260
|
this.isPasteInProgress = false;
|
|
262
261
|
return;
|
|
263
262
|
}
|
|
263
|
+
var keyDownEvent = this.keyDownEvent || {};
|
|
264
|
+
var isBackspaceKey = keyDownEvent.keyCode === keycode_1.KeyCode.BACKSPACE || keyDownEvent.key === key_1.Key.BACKSPACE;
|
|
265
|
+
var isDeleteKey = keyDownEvent.keyCode === keycode_1.KeyCode.DELETE || keyDownEvent.key === key_1.Key.DELETE;
|
|
264
266
|
var originalInteractionMode = this.interactionMode;
|
|
265
267
|
if (this.options.allowCaretMode &&
|
|
266
268
|
originalInteractionMode !== interaction_mode_1.DateInputInteractionMode.Caret &&
|
|
@@ -279,50 +281,36 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
279
281
|
this.restorePreviousInputEventState();
|
|
280
282
|
return;
|
|
281
283
|
}
|
|
282
|
-
var
|
|
284
|
+
var oldExistingDateValue = this.dateObject && this.dateObject.getValue();
|
|
285
|
+
var oldDateValue = this.dateObject ? this.dateObject.value : null;
|
|
283
286
|
var _a = this.dateObject.getTextAndFormat(), currentText = _a.text, currentFormat = _a.format;
|
|
284
287
|
this.currentFormat = currentFormat;
|
|
285
|
-
var
|
|
288
|
+
var oldText = "";
|
|
286
289
|
if (hasCaret) {
|
|
287
290
|
if (isBackspaceKey || isDeleteKey) {
|
|
288
|
-
|
|
291
|
+
oldText = this.previousElementValue;
|
|
289
292
|
}
|
|
290
293
|
else if (originalInteractionMode === interaction_mode_1.DateInputInteractionMode.Caret) {
|
|
291
|
-
|
|
294
|
+
oldText = this.previousElementValue;
|
|
292
295
|
}
|
|
293
296
|
else {
|
|
294
|
-
|
|
297
|
+
oldText = currentText;
|
|
295
298
|
}
|
|
296
299
|
}
|
|
297
300
|
else {
|
|
298
|
-
|
|
301
|
+
oldText = currentText;
|
|
299
302
|
}
|
|
300
303
|
var newText = this.elementValue;
|
|
301
304
|
var diff = utils_1.approximateStringMatching({
|
|
302
|
-
oldText:
|
|
305
|
+
oldText: oldText,
|
|
303
306
|
newText: newText,
|
|
304
307
|
formatPattern: this.currentFormat,
|
|
305
308
|
selectionStart: this.selection.start,
|
|
306
309
|
isInCaretMode: hasCaret,
|
|
307
310
|
keyEvent: this.keyDownEvent
|
|
308
311
|
});
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (currentFormatChar &&
|
|
312
|
-
currentFormatChar.length > 0 &&
|
|
313
|
-
currentFormatChar !== constants_1.Constants.formatSeparator) {
|
|
314
|
-
if (!diff || diff.length === 0) {
|
|
315
|
-
diff = [];
|
|
316
|
-
diff[0][0] = currentFormatChar;
|
|
317
|
-
diff[0][1] = e.data || "";
|
|
318
|
-
}
|
|
319
|
-
else if (diff[0] && diff[0][0] !== constants_1.Constants.formatSeparator) {
|
|
320
|
-
if (diff[0][0] !== currentFormatChar) {
|
|
321
|
-
diff[0][0] = currentFormatChar;
|
|
322
|
-
diff[0][1] = e.data || "";
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
312
|
+
if (diff && diff.length && diff[0] && diff[0][1] !== constants_1.Constants.formatSeparator) {
|
|
313
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
326
314
|
}
|
|
327
315
|
if (hasCaret && (!diff || diff.length === 0)) {
|
|
328
316
|
this.restorePreviousInputEventState();
|
|
@@ -361,104 +349,128 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
361
349
|
switchPart = false;
|
|
362
350
|
}
|
|
363
351
|
this.resetSegmentValue = false;
|
|
352
|
+
var hasFixedFormat = this.options.format === this.currentFormat ||
|
|
353
|
+
// all not fixed formats are 1 symbol, e.g. "d"
|
|
354
|
+
(utils_2.isPresent(this.options.format) && this.options.format.length > 1);
|
|
364
355
|
var lastParseResult = parsePartsResults[parsePartsResults.length - 1];
|
|
365
|
-
var lastParseResultHasNoValue = lastParseResult && !lastParseResult.value;
|
|
356
|
+
var lastParseResultHasNoValue = lastParseResult && !utils_2.isPresent(lastParseResult.value);
|
|
366
357
|
var parsingFailedOnDelete = (hasCaret && (isBackspaceKey || isDeleteKey) && lastParseResultHasNoValue);
|
|
367
358
|
var resetPart = lastParseResult ? lastParseResult.resetPart : false;
|
|
368
|
-
var
|
|
369
|
-
var
|
|
359
|
+
var newExistingDateValue = this.dateObject.getValue();
|
|
360
|
+
var hasExistingDateValueChanged = !kendo_date_math_1.isEqual(oldExistingDateValue, newExistingDateValue);
|
|
361
|
+
var newDateValue = this.dateObject.value;
|
|
370
362
|
var symbolForSelection;
|
|
371
363
|
var currentSelection = this.selection;
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if (!hasCaret || parsingFailedOnDelete || resetPart) {
|
|
380
|
-
if (symbolForSelection) {
|
|
381
|
-
this.setSelection(this.selectionBySymbol(symbolForSelection));
|
|
364
|
+
if (hasCaret) {
|
|
365
|
+
var diffChar = diff && diff.length > 0 ? diff[0][0] : null;
|
|
366
|
+
var hasLeadingZero = this.dateObject.getLeadingZero()[diffChar];
|
|
367
|
+
if (diff.length && diff[0][0] !== constants_1.Constants.formatSeparator) {
|
|
368
|
+
if (switchPart) {
|
|
369
|
+
this.forceUpdateWithSelection();
|
|
370
|
+
this.switchDateSegment(1);
|
|
382
371
|
}
|
|
383
|
-
else {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
372
|
+
else if (resetPart) {
|
|
373
|
+
symbolForSelection = this.currentFormat[currentSelection.start];
|
|
374
|
+
if (symbolForSelection) {
|
|
375
|
+
this.forceUpdate();
|
|
376
|
+
this.setSelection(this.selectionBySymbol(symbolForSelection));
|
|
387
377
|
}
|
|
388
378
|
else {
|
|
379
|
+
this.restorePreviousInputEventState();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else if (parsingFailedOnDelete) {
|
|
383
|
+
this.forceUpdate();
|
|
384
|
+
if (diff.length && diff[0][0] !== constants_1.Constants.formatSeparator) {
|
|
389
385
|
this.setSelection(this.selectionBySymbol(diff[0][0]));
|
|
390
386
|
}
|
|
391
387
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (switchPart) {
|
|
397
|
-
this.switchDateSegment(1);
|
|
388
|
+
else if (lastParseResultHasNoValue) {
|
|
389
|
+
if (e.data === "0" && hasLeadingZero) {
|
|
390
|
+
// do not reset element value on a leading zero
|
|
391
|
+
// wait for consecutive input to determine the value
|
|
398
392
|
}
|
|
399
|
-
else {
|
|
400
|
-
|
|
401
|
-
currentFormatChar && currentFormatChar !== "y") {
|
|
402
|
-
var elementValueLength = this.elementValue.length;
|
|
403
|
-
this.forceUpdate();
|
|
404
|
-
var selectionOffset = this.elementValue.length - elementValueLength;
|
|
405
|
-
this.setSelection({
|
|
406
|
-
start: currentSelection.start + selectionOffset,
|
|
407
|
-
end: currentSelection.start + selectionOffset
|
|
408
|
-
});
|
|
409
|
-
}
|
|
393
|
+
else if (utils_2.isPresent(oldExistingDateValue) && !utils_2.isPresent(newExistingDateValue)) {
|
|
394
|
+
this.restorePreviousInputEventState();
|
|
410
395
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (
|
|
416
|
-
this.
|
|
417
|
-
}
|
|
418
|
-
else if (e.data === "0" && hasLeadingZero) {
|
|
396
|
+
else if (!utils_2.isPresent(oldExistingDateValue) && utils_2.isPresent(newExistingDateValue)) {
|
|
397
|
+
this.forceUpdateWithSelection();
|
|
398
|
+
}
|
|
399
|
+
else if (utils_2.isPresent(oldExistingDateValue) && utils_2.isPresent(newExistingDateValue)) {
|
|
400
|
+
if (hasExistingDateValueChanged) {
|
|
401
|
+
this.forceUpdateWithSelection();
|
|
419
402
|
}
|
|
420
403
|
else {
|
|
421
404
|
this.restorePreviousInputEventState();
|
|
422
405
|
}
|
|
423
406
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
if (!switchPart && hasCaret && !isBackspaceKey && !isDeleteKey && !resetPart && lastParseResultHasNoValue) {
|
|
428
|
-
if (hasDateValueChanged) {
|
|
429
|
-
if (this.currentFormat.length === this.elementValue.length) {
|
|
430
|
-
// if a full date is entered, do not reset it
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
// the input is not complete, not parsable or not updatable
|
|
434
|
-
if (originalInteractionMode !== interaction_mode_1.DateInputInteractionMode.Caret && hasDateValueChanged) {
|
|
407
|
+
else if (!utils_2.isPresent(oldExistingDateValue) && !utils_2.isPresent(newExistingDateValue)) {
|
|
408
|
+
this.forceUpdateWithSelection();
|
|
435
409
|
}
|
|
436
|
-
else if (
|
|
437
|
-
|
|
438
|
-
this.forceUpdate();
|
|
439
|
-
this.setSelection(this.selectionBySymbol(symbolForSelection));
|
|
410
|
+
else if (oldDateValue !== newDateValue) {
|
|
411
|
+
// this can happen on auto correct when no valid value is parsed
|
|
440
412
|
}
|
|
441
|
-
else
|
|
413
|
+
else {
|
|
442
414
|
this.restorePreviousInputEventState();
|
|
443
415
|
}
|
|
444
416
|
}
|
|
417
|
+
else if (!lastParseResultHasNoValue) {
|
|
418
|
+
// the user types a valid but incomplete date (e.g. year "123" with format "yyyy")
|
|
419
|
+
// let them continue typing, but refresh for not fixed formats
|
|
420
|
+
if (!hasFixedFormat) {
|
|
421
|
+
this.forceUpdateWithSelection();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
445
424
|
}
|
|
446
425
|
else {
|
|
447
|
-
|
|
448
|
-
|
|
426
|
+
if (!this.options.autoSwitchParts && diff[0][1] === constants_1.Constants.formatSeparator) {
|
|
427
|
+
// do not change the selection when a separator is pressed
|
|
428
|
+
// this should happen only if autoSwitchKeys contains the separator explicitly
|
|
449
429
|
}
|
|
450
|
-
else
|
|
451
|
-
this.
|
|
430
|
+
else {
|
|
431
|
+
this.setSelection(this.selectionBySymbol(diff[0][0]));
|
|
452
432
|
}
|
|
453
433
|
}
|
|
454
434
|
}
|
|
455
|
-
else if (
|
|
456
|
-
|
|
457
|
-
|
|
435
|
+
else if (!hasCaret) {
|
|
436
|
+
this.forceUpdate();
|
|
437
|
+
if (diff.length && diff[0][0] !== constants_1.Constants.formatSeparator) {
|
|
438
|
+
this.setSelection(this.selectionBySymbol(diff[0][0]));
|
|
439
|
+
}
|
|
440
|
+
if (this.options.autoSwitchParts) {
|
|
441
|
+
if (navigationOnly) {
|
|
442
|
+
this.resetSegmentValue = true;
|
|
443
|
+
if (!switchedPartOnPreviousKeyAction) {
|
|
444
|
+
this.switchDateSegment(1);
|
|
445
|
+
}
|
|
446
|
+
this.switchedPartOnPreviousKeyAction = true;
|
|
447
|
+
}
|
|
448
|
+
else if (switchPart) {
|
|
449
|
+
this.switchDateSegment(1);
|
|
450
|
+
this.switchedPartOnPreviousKeyAction = true;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
if (lastParseResult && lastParseResult.switchToNext) {
|
|
455
|
+
// the value is complete and should be switched, but the "autoSwitchParts" option prevents this
|
|
456
|
+
// ensure that the segment value can be reset on next input
|
|
457
|
+
this.resetSegmentValue = true;
|
|
458
|
+
}
|
|
459
|
+
else if (navigationOnly) {
|
|
460
|
+
this.resetSegmentValue = true;
|
|
461
|
+
if (!switchedPartOnPreviousKeyAction) {
|
|
462
|
+
this.switchDateSegment(1);
|
|
463
|
+
}
|
|
464
|
+
this.switchedPartOnPreviousKeyAction = true;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (isBackspaceKey && this.options.selectPreviousSegmentOnBackspace) {
|
|
468
|
+
// kendo angular have this UX
|
|
469
|
+
this.switchDateSegment(-1);
|
|
458
470
|
}
|
|
459
471
|
}
|
|
460
472
|
this.tryTriggerValueChange({
|
|
461
|
-
oldValue:
|
|
473
|
+
oldValue: oldExistingDateValue,
|
|
462
474
|
event: e
|
|
463
475
|
});
|
|
464
476
|
this.triggerInputEnd({ event: e });
|
|
@@ -478,6 +490,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
478
490
|
}
|
|
479
491
|
this.isActive = true;
|
|
480
492
|
this.interactionMode = interaction_mode_1.DateInputInteractionMode.None;
|
|
493
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
481
494
|
this.refreshElementValue();
|
|
482
495
|
if (!this.mouseDownStarted) {
|
|
483
496
|
this.caret(0, this.elementValue.length);
|
|
@@ -495,6 +508,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
495
508
|
return;
|
|
496
509
|
}
|
|
497
510
|
this.interactionMode = interaction_mode_1.DateInputInteractionMode.None;
|
|
511
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
498
512
|
this.refreshElementValue();
|
|
499
513
|
this.triggerBlurEnd({ event: e });
|
|
500
514
|
};
|
|
@@ -514,20 +528,9 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
514
528
|
var _a = this.selection, start = _a.start, end = _a.end;
|
|
515
529
|
this.keyDownEvent = e;
|
|
516
530
|
this.previousElementValue = this.element.value;
|
|
517
|
-
this.formatStateOnKeyDown = {
|
|
518
|
-
format: this.currentFormat,
|
|
519
|
-
selectionStart: start,
|
|
520
|
-
selectionEnd: end
|
|
521
|
-
};
|
|
522
531
|
this.previousElementSelection = { start: start, end: end };
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (autoSwitchKeys.indexOf(e.keyCode.toString()) >= 0 ||
|
|
526
|
-
autoSwitchKeys.indexOf(e.keyCode) >= 0 ||
|
|
527
|
-
autoSwitchKeys.indexOf(e.key.toLowerCase().trim()) >= 0) {
|
|
528
|
-
var isTabKey = autoSwitchKeys.indexOf(key_1.Key.TAB.toLowerCase().trim()) >= 0 ||
|
|
529
|
-
autoSwitchKeys.indexOf(keycode_1.KeyCode.TAB) >= 0 ||
|
|
530
|
-
autoSwitchKeys.indexOf(keycode_1.KeyCode.TAB.toString()) >= 0;
|
|
532
|
+
if (this.keyEventMatchesAutoSwitchKeys(e)) {
|
|
533
|
+
var isTabKey = e.KeyCode === keycode_1.KeyCode.TAB;
|
|
531
534
|
if (isTabKey) {
|
|
532
535
|
var _b = this.selection, selectionStart = _b.start, selectionEnd = _b.end;
|
|
533
536
|
if (e.shiftKey && isTabKey) {
|
|
@@ -559,45 +562,33 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
559
562
|
case keycode_1.KeyCode.ARROW_LEFT:
|
|
560
563
|
this.switchDateSegment(-1);
|
|
561
564
|
shouldPreventDefault = true;
|
|
565
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
562
566
|
break;
|
|
563
567
|
case keycode_1.KeyCode.ARROW_UP:
|
|
564
568
|
this.modifyDateSegmentValue(step, symbol, event);
|
|
565
569
|
shouldPreventDefault = true;
|
|
570
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
566
571
|
break;
|
|
567
572
|
case keycode_1.KeyCode.ARROW_RIGHT:
|
|
568
573
|
this.switchDateSegment(1);
|
|
569
574
|
shouldPreventDefault = true;
|
|
575
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
570
576
|
break;
|
|
571
577
|
case keycode_1.KeyCode.ARROW_DOWN:
|
|
572
578
|
this.modifyDateSegmentValue(-step, symbol, event);
|
|
573
579
|
shouldPreventDefault = true;
|
|
580
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
574
581
|
break;
|
|
575
582
|
case keycode_1.KeyCode.ENTER:
|
|
576
583
|
// todo: handle "change" event
|
|
577
584
|
break;
|
|
578
|
-
case keycode_1.KeyCode.DELETE:
|
|
579
|
-
case keycode_1.KeyCode.BACKSPACE:
|
|
580
|
-
if (this.options.allowNulls) {
|
|
581
|
-
var oldValue = this.dateObject.value;
|
|
582
|
-
this.dateObject.setValue(null);
|
|
583
|
-
this.forceUpdate();
|
|
584
|
-
this.tryTriggerValueChange({
|
|
585
|
-
oldValue: oldValue,
|
|
586
|
-
event: e
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
shouldPreventDefault = true;
|
|
590
|
-
if (e.keyCode === keycode_1.KeyCode.BACKSPACE &&
|
|
591
|
-
((this.options.autoSwitchKeys || []).indexOf(keycode_1.KeyCode.BACKSPACE) >= 0 ||
|
|
592
|
-
(this.options.autoSwitchKeys || []).indexOf(key_1.Key.BACKSPACE) >= 0)) {
|
|
593
|
-
this.switchDateSegment(-1);
|
|
594
|
-
}
|
|
595
|
-
return;
|
|
596
585
|
case key_1.Key.HOME:
|
|
597
586
|
this.selectNearestSegment(0);
|
|
587
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
598
588
|
break;
|
|
599
589
|
case key_1.Key.END:
|
|
600
590
|
this.selectNearestSegment(this.elementValue.length);
|
|
591
|
+
this.switchedPartOnPreviousKeyAction = false;
|
|
601
592
|
break;
|
|
602
593
|
default:
|
|
603
594
|
// allow the "input" event to handle the change
|
|
@@ -702,9 +693,11 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
702
693
|
configurable: true
|
|
703
694
|
});
|
|
704
695
|
DateInput.prototype.setSelection = function (selection) {
|
|
705
|
-
// this._lastSelectedSymbol = this.currentFormat[selection.start];
|
|
706
696
|
if (this.element && document.activeElement === this.element) {
|
|
707
697
|
this.element.setSelectionRange(selection.start, selection.end);
|
|
698
|
+
if (selection.start !== selection.end) {
|
|
699
|
+
this.interactionMode = interaction_mode_1.DateInputInteractionMode.Selection;
|
|
700
|
+
}
|
|
708
701
|
}
|
|
709
702
|
};
|
|
710
703
|
/**
|
|
@@ -755,8 +748,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
755
748
|
var selection = this.selection;
|
|
756
749
|
if (this.isInCaretMode()) {
|
|
757
750
|
var start = selection.start;
|
|
758
|
-
var currentSymbol = this.currentFormat[start -
|
|
759
|
-
this.currentFormat[start];
|
|
751
|
+
var currentSymbol = this.currentFormat[start - 1];
|
|
760
752
|
var symbol = "";
|
|
761
753
|
var symbolCandidate = "";
|
|
762
754
|
if (offset < 0) {
|
|
@@ -943,6 +935,19 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
943
935
|
this.setTextAndFormat();
|
|
944
936
|
this.refreshElementValue();
|
|
945
937
|
};
|
|
938
|
+
/**
|
|
939
|
+
* @hidden
|
|
940
|
+
*/
|
|
941
|
+
DateInput.prototype.forceUpdateWithSelection = function () {
|
|
942
|
+
var _a = this.selection, start = _a.start, end = _a.end;
|
|
943
|
+
var elementValueLength = this.elementValue.length;
|
|
944
|
+
this.forceUpdate();
|
|
945
|
+
var selectionOffset = this.elementValue.length - elementValueLength;
|
|
946
|
+
this.setSelection({
|
|
947
|
+
start: start + selectionOffset,
|
|
948
|
+
end: end + selectionOffset
|
|
949
|
+
});
|
|
950
|
+
};
|
|
946
951
|
/**
|
|
947
952
|
* @hidden
|
|
948
953
|
*/
|
|
@@ -1126,6 +1131,20 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
1126
1131
|
}, options));
|
|
1127
1132
|
return dateObject;
|
|
1128
1133
|
};
|
|
1134
|
+
/* tslint:enable:align */
|
|
1135
|
+
/**
|
|
1136
|
+
* @hidden
|
|
1137
|
+
*/
|
|
1138
|
+
DateInput.prototype.keyEventMatchesAutoSwitchKeys = function (keyObject) {
|
|
1139
|
+
var autoSwitchKeys = (this.options.autoSwitchKeys || [])
|
|
1140
|
+
.map(function (x) { return x.toString().toLowerCase().trim(); });
|
|
1141
|
+
if (autoSwitchKeys.indexOf(keyObject.keyCode.toString()) >= 0 ||
|
|
1142
|
+
autoSwitchKeys.indexOf(keyObject.keyCode) >= 0 ||
|
|
1143
|
+
autoSwitchKeys.indexOf(keyObject.key.toLowerCase().trim()) >= 0) {
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
return false;
|
|
1147
|
+
};
|
|
1129
1148
|
return DateInput;
|
|
1130
1149
|
}(observable_1.Observable));
|
|
1131
1150
|
exports.DateInput = DateInput;
|
|
@@ -70,8 +70,8 @@ exports.approximateStringMatching = function (_a) {
|
|
|
70
70
|
return [[symbol, newSegmentText[selectionStart - 1]]];
|
|
71
71
|
}
|
|
72
72
|
/* Handle the entering of a space or a separator for navigating to the next item. */
|
|
73
|
-
if ((
|
|
74
|
-
(
|
|
73
|
+
if ((newSegmentText[newSegmentText.length - 1] === ' ') ||
|
|
74
|
+
(newSegmentText[newSegmentText.length - 1] === oldTextSeparator)) {
|
|
75
75
|
return [[formatPattern[selectionStart - 1], constants_1.Constants.formatSeparator]];
|
|
76
76
|
}
|
|
77
77
|
/* Handle typing over a correctly selected part. */
|