Добавлена возможность оставить пустое поле даты

This commit is contained in:
Andrey Pokidov committed 2020-02-25 17:37:24 +07:00
1 parent 9eb6cfb1ec
commit 8fe52a2a19
5 files changed
+17 -9

No files matched your search

+5 -3
View File
@@ -950,7 +950,9 @@ function () {
this._field.addEventListener('blur', function () {
_this.correctValue(true);
if (!_this._isEmptyValue(_this._field.value)) {
_this.returnLastCorrectValue();
}
});
}
}, {
@@ -1005,7 +1007,7 @@ function () {
return;
}
this._setValueToFieled(parsedValue);
this._setValueToField(parsedValue);
}
}, {
key: "setValue",
@@ -1037,8 +1039,8 @@ function () {
return this._formatter.getCorrectedValue();
}
}, {
key: "_setValueToFieled",
value: function _setValueToFieled(newValue) {
key: "_setValueToField",
value: function _setValueToField(newValue) {
var position = this._field.selectionStart;
var isAtEnd = position === this._field.value.length;
this._field.value = newValue;
+1 -1
View File
@@ -1 +1 @@
"use strict";function _get(a,b,c){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(a,b,c){var d=_superPropBase(a,b);if(d){var e=Object.getOwnPropertyDescriptor(d,b);return e.get?e.get.call(c):e.value}},_get(a,b,c||a)}function _superPropBase(a,b){for(;!Object.prototype.hasOwnProperty.call(a,b)&&(a=_getPrototypeOf(a),null!==a););return a}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _possibleConstructorReturn(a,b){return b&&("object"===_typeof(b)||"function"==typeof b)?b:_assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}var AbstractSmartDatePart=function(){function a(b,c){_classCallCheck(this,a),this._state=a.STATE_NONE,this._cleanedValue="",this._parsedValue="",this._scanned="",this._placeholder=b,this._static=c}return _createClass(a,[{key:"state",value:function(){return this._state}},{key:"isNoState",value:function(){return this._state===a.STATE_NONE}},{key:"isIncomplete",value:function(){return this._state===a.STATE_INCOMPLETE}},{key:"isComplete",value:function(){return this._state===a.STATE_COMPLETE}},{key:"resetState",value:function(){this._state=a.STATE_NONE}},{key:"cleanedValue",value:function(){return this._cleanedValue}},{key:"parsedValue",value:function(){return this._parsedValue}},{key:"placeHolder",value:function(){return this._placeholder}},{key:"isStatic",value:function(){return this._static}},{key:"_isNumericSymbol",value:function(a){return"0"<=a&&"9">=a}},{key:"check",value:function(){return!1}}]),a}();AbstractSmartDatePart.STATE_NONE=0,AbstractSmartDatePart.STATE_INCOMPLETE=1,AbstractSmartDatePart.STATE_COMPLETE=2;var SmartDateStaticPart=function(a){function b(a){var c;return _classCallCheck(this,b),c=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this,a,!0)),c._cleanedValue=a,c}return _inherits(b,a),_createClass(b,[{key:"parse",value:function(a){for(var b=a.value(),c=a.valueIndex();c<b.length&&!this._isNumericSymbol(b[c]);)c++;return this._parsedValue=b.substring(a.valueIndex(),c),this._state=AbstractSmartDatePart.STATE_COMPLETE,a.setValueIndex(c),!0}}]),b}(AbstractSmartDatePart),AbstractSmartDateNumericPart=function(a){function b(a,c){var d;return _classCallCheck(this,b),d=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this,a,!1)),d._numericValue=0,d._size=c,d}return _inherits(b,a),_createClass(b,[{key:"numericValue",value:function(){return this._numericValue}},{key:"formatDate",value:function(){return""}},{key:"formatValue",value:function(a){var b=this._correctValue(a)+"";return"0"==b?b:b.length>this._size?b.substring(0,this._size):b.length<this._size?b.padStart(this._size,"0"):b}},{key:"_correctValue",value:function(a){var b=Math.round;return b(a)}},{key:"scanStringNumber",value:function(a){for(var b=a.valueIndex(),c=a.value();b<c.length&&this._isNumericSymbol(c[b]);)b++;var d=c.substring(a.valueIndex(),b);return a.setValueIndex(b),d}},{key:"calculateNumericValue",value:function(a,b){for(var c=0,d=0,e=0;c<a.length&&0===a[c];)c++;for(d=c;d<a.length&&e<b;)e=10*e+ +a[d],d++;return e>b&&d--,+a.substring(c,d)}},{key:"scanValue",value:function(a,b){for(var c=a.valueIndex(),d=a.value(),e=0;c<d.length&&this._isNumericSymbol(d[c])&&e<b;)e=10*e+ +d[c],c++;e>b&&c--;var f=d.substring(a.valueIndex(),c);return a.setValueIndex(c),f}},{key:"_defineParsingState",value:function(a,b){return 0<this._numericValue&&(this._parsedValue.length>=this._size||!b)?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):10*this._numericValue>a?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):void(this._state=AbstractSmartDatePart.STATE_INCOMPLETE)}},{key:"_defineCleanValue",value:function(){return this._cleanedValue="",this.isNoState()?void 0:this.isComplete()?void(this._cleanedValue=this.formatLine truncated
"use strict";function _get(a,b,c){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(a,b,c){var d=_superPropBase(a,b);if(d){var e=Object.getOwnPropertyDescriptor(d,b);return e.get?e.get.call(c):e.value}},_get(a,b,c||a)}function _superPropBase(a,b){for(;!Object.prototype.hasOwnProperty.call(a,b)&&(a=_getPrototypeOf(a),null!==a););return a}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _possibleConstructorReturn(a,b){return b&&("object"===_typeof(b)||"function"==typeof b)?b:_assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}var AbstractSmartDatePart=function(){function a(b,c){_classCallCheck(this,a),this._state=a.STATE_NONE,this._cleanedValue="",this._parsedValue="",this._scanned="",this._placeholder=b,this._static=c}return _createClass(a,[{key:"state",value:function(){return this._state}},{key:"isNoState",value:function(){return this._state===a.STATE_NONE}},{key:"isIncomplete",value:function(){return this._state===a.STATE_INCOMPLETE}},{key:"isComplete",value:function(){return this._state===a.STATE_COMPLETE}},{key:"resetState",value:function(){this._state=a.STATE_NONE}},{key:"cleanedValue",value:function(){return this._cleanedValue}},{key:"parsedValue",value:function(){return this._parsedValue}},{key:"placeHolder",value:function(){return this._placeholder}},{key:"isStatic",value:function(){return this._static}},{key:"_isNumericSymbol",value:function(a){return"0"<=a&&"9">=a}},{key:"check",value:function(){return!1}}]),a}();AbstractSmartDatePart.STATE_NONE=0,AbstractSmartDatePart.STATE_INCOMPLETE=1,AbstractSmartDatePart.STATE_COMPLETE=2;var SmartDateStaticPart=function(a){function b(a){var c;return _classCallCheck(this,b),c=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this,a,!0)),c._cleanedValue=a,c}return _inherits(b,a),_createClass(b,[{key:"parse",value:function(a){for(var b=a.value(),c=a.valueIndex();c<b.length&&!this._isNumericSymbol(b[c]);)c++;return this._parsedValue=b.substring(a.valueIndex(),c),this._state=AbstractSmartDatePart.STATE_COMPLETE,a.setValueIndex(c),!0}}]),b}(AbstractSmartDatePart),AbstractSmartDateNumericPart=function(a){function b(a,c){var d;return _classCallCheck(this,b),d=_possibleConstructorReturn(this,_getPrototypeOf(b).call(this,a,!1)),d._numericValue=0,d._size=c,d}return _inherits(b,a),_createClass(b,[{key:"numericValue",value:function(){return this._numericValue}},{key:"formatDate",value:function(){return""}},{key:"formatValue",value:function(a){var b=this._correctValue(a)+"";return"0"==b?b:b.length>this._size?b.substring(0,this._size):b.length<this._size?b.padStart(this._size,"0"):b}},{key:"_correctValue",value:function(a){var b=Math.round;return b(a)}},{key:"scanStringNumber",value:function(a){for(var b=a.valueIndex(),c=a.value();b<c.length&&this._isNumericSymbol(c[b]);)b++;var d=c.substring(a.valueIndex(),b);return a.setValueIndex(b),d}},{key:"calculateNumericValue",value:function(a,b){for(var c=0,d=0,e=0;c<a.length&&0===a[c];)c++;for(d=c;d<a.length&&e<b;)e=10*e+ +a[d],d++;return e>b&&d--,+a.substring(c,d)}},{key:"scanValue",value:function(a,b){for(var c=a.valueIndex(),d=a.value(),e=0;c<d.length&&this._isNumericSymbol(d[c])&&e<b;)e=10*e+ +d[c],c++;e>b&&c--;var f=d.substring(a.valueIndex(),c);return a.setValueIndex(c),f}},{key:"_defineParsingState",value:function(a,b){return 0<this._numericValue&&(this._parsedValue.length>=this._size||!b)?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):10*this._numericValue>a?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):void(this._state=AbstractSmartDatePart.STATE_INCOMPLETE)}},{key:"_defineCleanValue",value:function(){return this._cleanedValue="",this.isNoState()?void 0:this.isComplete()?void(this._cleanedValue=this.formatLine truncated
+5 -2
View File
@@ -856,7 +856,10 @@ class SmartDateField
this._field.addEventListener('blur', function () {
_this.correctValue(true);
if (!_this._isEmptyValue(_this._field.value)) {
_this.returnLastCorrectValue();
}
});
}
@@ -898,7 +901,7 @@ class SmartDateField
return;
}
this._setValueToFieled(parsedValue);
this._setValueToField(parsedValue);
}
setValue(value)
@@ -931,7 +934,7 @@ class SmartDateField
return this._formatter.getCorrectedValue();
}
_setValueToFieled(newValue)
_setValueToField(newValue)
{
let position = this._field.selectionStart;
let isAtEnd = (position === this._field.value.length);
+1 -1
View File
@@ -1 +1 @@
class AbstractSmartDatePart{constructor(a,b){this._state=AbstractSmartDatePart.STATE_NONE,this._cleanedValue="",this._parsedValue="",this._scanned="",this._placeholder=a,this._static=b}state(){return this._state}isNoState(){return this._state===AbstractSmartDatePart.STATE_NONE}isIncomplete(){return this._state===AbstractSmartDatePart.STATE_INCOMPLETE}isComplete(){return this._state===AbstractSmartDatePart.STATE_COMPLETE}resetState(){this._state=AbstractSmartDatePart.STATE_NONE}cleanedValue(){return this._cleanedValue}parsedValue(){return this._parsedValue}placeHolder(){return this._placeholder}isStatic(){return this._static}_isNumericSymbol(a){return"0"<=a&&"9">=a}check(a){return!1}}AbstractSmartDatePart.STATE_NONE=0,AbstractSmartDatePart.STATE_INCOMPLETE=1,AbstractSmartDatePart.STATE_COMPLETE=2;class SmartDateStaticPart extends AbstractSmartDatePart{constructor(a){super(a,!0),this._cleanedValue=a}parse(a){let b=a.value(),c=a.valueIndex();for(;c<b.length&&!this._isNumericSymbol(b[c]);)c++;return this._parsedValue=b.substring(a.valueIndex(),c),this._state=AbstractSmartDatePart.STATE_COMPLETE,a.setValueIndex(c),!0}}class AbstractSmartDateNumericPart extends AbstractSmartDatePart{constructor(a,b){super(a,!1),this._numericValue=0,this._size=b}numericValue(){return this._numericValue}formatDate(a){return""}formatValue(a){let b=this._correctValue(a)+"";return"0"==b?b:b.length>this._size?b.substring(0,this._size):b.length<this._size?b.padStart(this._size,"0"):b}_correctValue(a){return Math.round(a)}scanStringNumber(a){let b=a.valueIndex(),c=a.value();for(;b<c.length&&this._isNumericSymbol(c[b]);)b++;let d=c.substring(a.valueIndex(),b);return a.setValueIndex(b),d}calculateNumericValue(a,b){for(var c=0,d=0,e=0;c<a.length&&0===a[c];)c++;for(d=c;d<a.length&&e<b;)e=10*e+ +a[d],d++;return e>b&&d--,+a.substring(c,d)}scanValue(a,b){let c=a.valueIndex(),d=a.value(),e=0;for(;c<d.length&&this._isNumericSymbol(d[c])&&e<b;)e=10*e+ +d[c],c++;e>b&&c--;let f=d.substring(a.valueIndex(),c);return a.setValueIndex(c),f}_defineParsingState(a,b){return 0<this._numericValue&&(this._parsedValue.length>=this._size||!b)?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):10*this._numericValue>a?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):void(this._state=AbstractSmartDatePart.STATE_INCOMPLETE)}_defineCleanValue(){return this._cleanedValue="",this.isNoState()?void 0:this.isComplete()?void(this._cleanedValue=this.formatValue(this._numericValue)):void(0<this._parsedValue.length&&(this._cleanedValue=this._numericValue+""))}}class SmartDateDayPart extends AbstractSmartDateNumericPart{constructor(){super(SmartDateFormat.DAY_PLACEHOLDER,2),this.maximalValue=SmartDateDayPart.MAXIMAL_VALUE}resetState(){super.resetState(),this.maximalValue=SmartDateDayPart.MAXIMAL_VALUE}setMaximalValue(a){a!=a||a<SmartDateDayPart.MAXIMAL_VALUE_LOW_LIMIT||SmartDateDayPart.MAXIMAL_VALUE_HIGH_LIMIT<a||(this.maximalValue=a,this._numericValue<=this.maximalValue||(this._numericValue=this.maximalValue,this._defineCleanValue()))}resetMaximalValue(){this.maximalValue=SmartDateDayPart.MAXIMAL_VALUE}formatDate(a){return this.formatValue(a.getDate())}parse(a){this._parsedValue=this.scanStringNumber(a),this._numericValue=this.calculateNumericValue(this._parsedValue,this.maximalValue),this._defineParsingState(this.maximalValue,a.isOver()),this._defineCleanValue()}}SmartDateDayPart.MAXIMAL_VALUE_LOW_LIMIT=28,SmartDateDayPart.MAXIMAL_VALUE_HIGH_LIMIT=31,SmartDateDayPart.MAXIMAL_VALUE=SmartDateDayPart.MAXIMAL_VALUE_HIGH_LIMIT;class SmartDateMonthPart extends AbstractSmartDateNumericPart{constructor(){super(SmartDateFormat.MONTH_PLACEHOLDER,2)}formatDate(a){return this.formatValue(a.getMonth()+1)}parse(a){this._parsedValue=this.scanStringNumber(a),this._numericValue=this.calculateNumericValue(this._parsedValue,SmartDateMonthPart.MAXIMAL_VALUE),this._defineParsingState(SmartDateMonthPart.MAXIMAL_VALUE,a.isOver()),this._defineCleanValue()}}SmartDateMonthPart.MAXIMAL_VALUE=12;class SmartDateYearPart extends AbstractSmartDateNumericPart{constructor(){super(SmartDateFormat.YEAR_PLACEHOLDER,4)}formatDate(a){return this.formatValue(a.getFullYear())}parse(a){this._parsedValue=this.scanStringNumber(a),this._numericValue=+this._parsedValue,this._defineParsingState(),this._numericValue>SmartDateYearPart.MAXIMAL_VALUE&&(this._numericValue=SmartDateYearPart.MAXIMAL_VALUE),this.isComplete()&&this._numericValue<SmartDateYearPart.MINIMAL_VALUE&&(this._numericValue=SmartDateYearPart.MINIMAL_VALUE),this._defineCleanValue()}_defineParsingState(){return 0<this._numericValue&&this._parsedValue.length>=this._size?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):void(this._state=AbstractSmartDatePart.STATE_INCOMPLETE)}_defineCleanValue(){this._cleanedValue=0<this._numericValue?this._numericValue+"":""}}SmartDateYearPart.MINIMAL_VALUE=1e3,SmartDateYearPart.MAXIMAL_VALUE=9999;class SmartDateParseState{constructor(){this._value="",this._valueIndex=0}start(a){this._value=a,this._valueIndexLine truncated
class AbstractSmartDatePart{constructor(a,b){this._state=AbstractSmartDatePart.STATE_NONE,this._cleanedValue="",this._parsedValue="",this._scanned="",this._placeholder=a,this._static=b}state(){return this._state}isNoState(){return this._state===AbstractSmartDatePart.STATE_NONE}isIncomplete(){return this._state===AbstractSmartDatePart.STATE_INCOMPLETE}isComplete(){return this._state===AbstractSmartDatePart.STATE_COMPLETE}resetState(){this._state=AbstractSmartDatePart.STATE_NONE}cleanedValue(){return this._cleanedValue}parsedValue(){return this._parsedValue}placeHolder(){return this._placeholder}isStatic(){return this._static}_isNumericSymbol(a){return"0"<=a&&"9">=a}check(a){return!1}}AbstractSmartDatePart.STATE_NONE=0,AbstractSmartDatePart.STATE_INCOMPLETE=1,AbstractSmartDatePart.STATE_COMPLETE=2;class SmartDateStaticPart extends AbstractSmartDatePart{constructor(a){super(a,!0),this._cleanedValue=a}parse(a){let b=a.value(),c=a.valueIndex();for(;c<b.length&&!this._isNumericSymbol(b[c]);)c++;return this._parsedValue=b.substring(a.valueIndex(),c),this._state=AbstractSmartDatePart.STATE_COMPLETE,a.setValueIndex(c),!0}}class AbstractSmartDateNumericPart extends AbstractSmartDatePart{constructor(a,b){super(a,!1),this._numericValue=0,this._size=b}numericValue(){return this._numericValue}formatDate(a){return""}formatValue(a){let b=this._correctValue(a)+"";return"0"==b?b:b.length>this._size?b.substring(0,this._size):b.length<this._size?b.padStart(this._size,"0"):b}_correctValue(a){return Math.round(a)}scanStringNumber(a){let b=a.valueIndex(),c=a.value();for(;b<c.length&&this._isNumericSymbol(c[b]);)b++;let d=c.substring(a.valueIndex(),b);return a.setValueIndex(b),d}calculateNumericValue(a,b){for(var c=0,d=0,e=0;c<a.length&&0===a[c];)c++;for(d=c;d<a.length&&e<b;)e=10*e+ +a[d],d++;return e>b&&d--,+a.substring(c,d)}scanValue(a,b){let c=a.valueIndex(),d=a.value(),e=0;for(;c<d.length&&this._isNumericSymbol(d[c])&&e<b;)e=10*e+ +d[c],c++;e>b&&c--;let f=d.substring(a.valueIndex(),c);return a.setValueIndex(c),f}_defineParsingState(a,b){return 0<this._numericValue&&(this._parsedValue.length>=this._size||!b)?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):10*this._numericValue>a?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):void(this._state=AbstractSmartDatePart.STATE_INCOMPLETE)}_defineCleanValue(){return this._cleanedValue="",this.isNoState()?void 0:this.isComplete()?void(this._cleanedValue=this.formatValue(this._numericValue)):void(0<this._parsedValue.length&&(this._cleanedValue=this._numericValue+""))}}class SmartDateDayPart extends AbstractSmartDateNumericPart{constructor(){super(SmartDateFormat.DAY_PLACEHOLDER,2),this.maximalValue=SmartDateDayPart.MAXIMAL_VALUE}resetState(){super.resetState(),this.maximalValue=SmartDateDayPart.MAXIMAL_VALUE}setMaximalValue(a){a!=a||a<SmartDateDayPart.MAXIMAL_VALUE_LOW_LIMIT||SmartDateDayPart.MAXIMAL_VALUE_HIGH_LIMIT<a||(this.maximalValue=a,this._numericValue<=this.maximalValue||(this._numericValue=this.maximalValue,this._defineCleanValue()))}resetMaximalValue(){this.maximalValue=SmartDateDayPart.MAXIMAL_VALUE}formatDate(a){return this.formatValue(a.getDate())}parse(a){this._parsedValue=this.scanStringNumber(a),this._numericValue=this.calculateNumericValue(this._parsedValue,this.maximalValue),this._defineParsingState(this.maximalValue,a.isOver()),this._defineCleanValue()}}SmartDateDayPart.MAXIMAL_VALUE_LOW_LIMIT=28,SmartDateDayPart.MAXIMAL_VALUE_HIGH_LIMIT=31,SmartDateDayPart.MAXIMAL_VALUE=SmartDateDayPart.MAXIMAL_VALUE_HIGH_LIMIT;class SmartDateMonthPart extends AbstractSmartDateNumericPart{constructor(){super(SmartDateFormat.MONTH_PLACEHOLDER,2)}formatDate(a){return this.formatValue(a.getMonth()+1)}parse(a){this._parsedValue=this.scanStringNumber(a),this._numericValue=this.calculateNumericValue(this._parsedValue,SmartDateMonthPart.MAXIMAL_VALUE),this._defineParsingState(SmartDateMonthPart.MAXIMAL_VALUE,a.isOver()),this._defineCleanValue()}}SmartDateMonthPart.MAXIMAL_VALUE=12;class SmartDateYearPart extends AbstractSmartDateNumericPart{constructor(){super(SmartDateFormat.YEAR_PLACEHOLDER,4)}formatDate(a){return this.formatValue(a.getFullYear())}parse(a){this._parsedValue=this.scanStringNumber(a),this._numericValue=+this._parsedValue,this._defineParsingState(),this._numericValue>SmartDateYearPart.MAXIMAL_VALUE&&(this._numericValue=SmartDateYearPart.MAXIMAL_VALUE),this.isComplete()&&this._numericValue<SmartDateYearPart.MINIMAL_VALUE&&(this._numericValue=SmartDateYearPart.MINIMAL_VALUE),this._defineCleanValue()}_defineParsingState(){return 0<this._numericValue&&this._parsedValue.length>=this._size?void(this._state=AbstractSmartDatePart.STATE_COMPLETE):void(this._state=AbstractSmartDatePart.STATE_INCOMPLETE)}_defineCleanValue(){this._cleanedValue=0<this._numericValue?this._numericValue+"":""}}SmartDateYearPart.MINIMAL_VALUE=1e3,SmartDateYearPart.MAXIMAL_VALUE=9999;class SmartDateParseState{constructor(){this._value="",this._valueIndex=0}start(a){this._value=a,this._valueIndexLine truncated
+5 -2
View File
@@ -142,7 +142,10 @@ class SmartDateField
this._field.addEventListener('blur', function () {
_this.correctValue(true);
if (!_this._isEmptyValue(_this._field.value)) {
_this.returnLastCorrectValue();
}
});
}
@@ -184,7 +187,7 @@ class SmartDateField
return;
}
this._setValueToFieled(parsedValue);
this._setValueToField(parsedValue);
}
setValue(value)
@@ -217,7 +220,7 @@ class SmartDateField
return this._formatter.getCorrectedValue();
}
_setValueToFieled(newValue)
_setValueToField(newValue)
{
let position = this._field.selectionStart;
let isAtEnd = (position === this._field.value.length);