@syncfusion/ej2-calendars 35.1.41 → 35.1.43

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.
@@ -2327,6 +2327,12 @@ let Calendar = class Calendar extends CalendarBase {
2327
2327
  else {
2328
2328
  tempValue = new Date(tempValue.getFullYear(), tempValue.getMonth(), tempValue.getDate(), 0, 0, 0, 0);
2329
2329
  }
2330
+ if (+tempValue < +this.min) {
2331
+ tempValue = new Date(+this.min);
2332
+ }
2333
+ else if (+tempValue > +this.max) {
2334
+ tempValue = new Date(+this.max);
2335
+ }
2330
2336
  return tempValue;
2331
2337
  }
2332
2338
  todayButtonClick(e) {
@@ -3433,7 +3439,7 @@ let DatePicker = class DatePicker extends Calendar {
3433
3439
  this.setAllowEdit();
3434
3440
  if (this.enableMask && !this.value && this.maskedDateValue && (this.floatLabelType === 'Always' || !this.floatLabelType || !this.placeholder)) {
3435
3441
  this.updateInput(true);
3436
- this.updateInputValue(this.maskedDateValue);
3442
+ this.setMaskedInputValue();
3437
3443
  }
3438
3444
  else if (!this.enableMask) {
3439
3445
  this.updateInput(true);
@@ -3553,7 +3559,7 @@ let DatePicker = class DatePicker extends Calendar {
3553
3559
  this.updateInputValue('');
3554
3560
  }
3555
3561
  else {
3556
- this.updateInputValue(this.maskedDateValue);
3562
+ this.setMaskedInputValue();
3557
3563
  this.notify('createMask', {
3558
3564
  module: 'MaskedDateTime'
3559
3565
  });
@@ -3845,6 +3851,31 @@ let DatePicker = class DatePicker extends Calendar {
3845
3851
  updateInputValue(value) {
3846
3852
  Input.setValue(value, this.inputElement, this.floatLabelType, this.showClearButton);
3847
3853
  }
3854
+ isMaskPlaceholderSwap() {
3855
+ return this.getModuleName() === 'datepicker' && this.enableMask && this.strictMode
3856
+ && (!this.placeholder || this.floatLabelType === 'Always') && !!this.maskedDateValue
3857
+ && !this.value && !isNullOrUndefined(this.inputElement) && !isNullOrUndefined(closest(this.inputElement, 'form'));
3858
+ }
3859
+ setMaskedInputValue() {
3860
+ if (this.isMaskPlaceholderSwap() && (this.isBlur || document.activeElement !== this.inputElement)) {
3861
+ this.swapMaskPlaceholder(false);
3862
+ }
3863
+ else {
3864
+ this.updateInputValue(this.maskedDateValue);
3865
+ }
3866
+ }
3867
+ swapMaskPlaceholder(toValue) {
3868
+ if (toValue) {
3869
+ this.updateInputValue(this.maskedDateValue);
3870
+ if (this.inputElement.hasAttribute('placeholder')) {
3871
+ this.inputElement.removeAttribute('placeholder');
3872
+ }
3873
+ }
3874
+ else {
3875
+ this.updateInputValue('');
3876
+ this.inputElement.setAttribute('placeholder', this.maskedDateValue);
3877
+ }
3878
+ }
3848
3879
  windowResize() {
3849
3880
  this.updateFloatLabelOverflowWidth(true);
3850
3881
  }
@@ -3979,7 +4010,10 @@ let DatePicker = class DatePicker extends Calendar {
3979
4010
  if (this.initTimeZone !== new Date().getTimezoneOffset()) {
3980
4011
  this.strictModeUpdate(true);
3981
4012
  }
3982
- if (this.enableMask && !this.inputElement.value && this.placeholder) {
4013
+ if (this.isMaskPlaceholderSwap() && (!this.inputElement.value || this.inputElement.value === this.maskedDateValue)) {
4014
+ this.swapMaskPlaceholder(true);
4015
+ }
4016
+ else if (this.enableMask && !this.inputElement.value && this.placeholder) {
3983
4017
  if (this.maskedDateValue && !this.value && (this.floatLabelType === 'Auto' || this.floatLabelType === 'Never' || this.placeholder)) {
3984
4018
  this.updateInputValue(this.maskedDateValue);
3985
4019
  this.inputElement.selectionStart = 0;
@@ -4030,7 +4064,10 @@ let DatePicker = class DatePicker extends Calendar {
4030
4064
  this.isBlur = false;
4031
4065
  this.popupUpdate();
4032
4066
  this.changeTrigger(e);
4033
- if (this.enableMask && this.maskedDateValue && this.placeholder && this.floatLabelType !== 'Always') {
4067
+ if (this.isMaskPlaceholderSwap() && (!this.inputElement.value || this.inputElement.value === this.maskedDateValue)) {
4068
+ this.swapMaskPlaceholder(false);
4069
+ }
4070
+ else if (this.enableMask && this.maskedDateValue && this.placeholder && this.floatLabelType !== 'Always') {
4034
4071
  if (this.inputElement.value === this.maskedDateValue && !this.value && (this.floatLabelType === 'Auto' || this.floatLabelType === 'Never' || this.placeholder)) {
4035
4072
  this.updateInputValue('');
4036
4073
  }
@@ -5285,7 +5322,7 @@ let DatePicker = class DatePicker extends Calendar {
5285
5322
  if (!this.popupObj) {
5286
5323
  this.updateInputValue(inputVal);
5287
5324
  if (this.enableMask) {
5288
- this.updateInputValue(this.maskedDateValue);
5325
+ this.setMaskedInputValue();
5289
5326
  this.notify('createMask', {
5290
5327
  module: 'MaskedDateTime', isBlur: isBlur
5291
5328
  });
@@ -5357,7 +5394,7 @@ let DatePicker = class DatePicker extends Calendar {
5357
5394
  this.previousElementValue = this.inputElement.value;
5358
5395
  if (isNullOrUndefined(this.value)) {
5359
5396
  if (this.enableMask) {
5360
- this.updateInputValue(this.maskedDateValue);
5397
+ this.setMaskedInputValue();
5361
5398
  }
5362
5399
  else {
5363
5400
  this.updateInputValue('');
@@ -5469,13 +5506,21 @@ let DatePicker = class DatePicker extends Calendar {
5469
5506
  this.notify('createMask', {
5470
5507
  module: 'MaskedDateTime'
5471
5508
  });
5472
- this.updateInputValue(this.maskedDateValue);
5509
+ if (this.isMaskPlaceholderSwap() && document.activeElement !== this.inputElement) {
5510
+ this.swapMaskPlaceholder(false);
5511
+ }
5512
+ else {
5513
+ this.updateInputValue(this.maskedDateValue);
5514
+ }
5473
5515
  this.bindInputEvent();
5474
5516
  }
5475
5517
  else {
5476
5518
  if (this.inputElement.value === this.maskedDateValue) {
5477
5519
  this.updateInputValue('');
5478
5520
  }
5521
+ if (!this.placeholder && this.inputElement.hasAttribute('placeholder') && this.inputElement.getAttribute('placeholder') === this.maskedDateValue) {
5522
+ this.inputElement.removeAttribute('placeholder');
5523
+ }
5479
5524
  }
5480
5525
  break;
5481
5526
  case 'min':