Comparing version 2.1.5 to 2.1.6
@@ -27,3 +27,3 @@ import './inbox-element/inbox-element'; | ||
*/ | ||
standardValue(valueString: string): JBInputStandardValueObject; | ||
standardValue(valueString: string | number): JBInputStandardValueObject; | ||
/** | ||
@@ -30,0 +30,0 @@ * |
@@ -148,2 +148,15 @@ var HTML = "<div class=\"jb-input-web-component\">\r\n <label class=\"--hide\"><span class=\"label-value\"></span></label>\r\n <div class=\"input-box\">\r\n <div class=\"jb-input-start-section-wrapper\">\r\n <slot name=\"start-section\"></slot>\r\n </div>\r\n <input>\r\n <div class=\"password-trigger\">\r\n <svg viewBox=\"0 0 120 120\">\r\n <path class=\"eye-line\" stroke-linecap=\"round\"></path>\r\n <circle cx=\"60\" cy=\"60\" r=\"20\"></circle>\r\n </svg>\r\n </div>\r\n <div class=\"jb-input-end-section-wrapper\">\r\n <slot name=\"end-section\"></slot>\r\n </div>\r\n </div>\r\n <div class=\"message-box\"></div>\r\n</div>"; | ||
standardValue(valueString) { | ||
if (typeof valueString !== "string") { | ||
if (typeof valueString === "number") { | ||
if (!isNaN(valueString)) { | ||
valueString = `${valueString}`; | ||
} | ||
else { | ||
valueString = ''; | ||
} | ||
} | ||
else { | ||
valueString = ''; | ||
} | ||
} | ||
let standardedValue = { | ||
@@ -189,3 +202,3 @@ displayValue: valueString, | ||
// } | ||
const decimalNums = valueString.split('.')[1]; | ||
const [integerNums, decimalNums] = valueString.split('.'); | ||
const decimalPrecisionCount = decimalNums ? decimalNums.length : 0; | ||
@@ -200,2 +213,7 @@ if (!(this.numberFieldParameters.decimalPrecision === null || this.numberFieldParameters.decimalPrecision == undefined) && decimalPrecisionCount && decimalPrecisionCount > this.numberFieldParameters.decimalPrecision) { | ||
} | ||
// check for negative value | ||
if (this.numberFieldParameters && this.numberFieldParameters.acceptNegative == false && integerNums.startsWith('-')) { | ||
valueString = '0'; | ||
console.error('negative number is not allowed change numberFieldParameters.acceptNegative to true to allow negative numbers'); | ||
} | ||
const standardValueObject = { | ||
@@ -202,0 +220,0 @@ displayValue: valueString, |
@@ -85,3 +85,14 @@ import HTML from './JBInput.html'; | ||
*/ | ||
standardValue(valueString: string): JBInputStandardValueObject { | ||
standardValue(valueString: string | number): JBInputStandardValueObject { | ||
if(typeof valueString !== "string"){ | ||
if(typeof valueString === "number"){ | ||
if(!isNaN(valueString)){ | ||
valueString = `${valueString}`; | ||
}else{ | ||
valueString = ''; | ||
} | ||
}else{ | ||
valueString = ''; | ||
} | ||
} | ||
let standardedValue:JBInputStandardValueObject = { | ||
@@ -127,3 +138,4 @@ displayValue:valueString, | ||
// } | ||
const decimalNums = valueString.split('.')[1]; | ||
const[integerNums, decimalNums] = valueString.split('.'); | ||
const decimalPrecisionCount = decimalNums ? decimalNums.length : 0; | ||
@@ -138,2 +150,7 @@ if (!(this.numberFieldParameters!.decimalPrecision === null || this.numberFieldParameters!.decimalPrecision == undefined) && decimalPrecisionCount && decimalPrecisionCount > this.numberFieldParameters!.decimalPrecision) { | ||
} | ||
// check for negative value | ||
if(this.numberFieldParameters && this.numberFieldParameters.acceptNegative == false && integerNums.startsWith('-')){ | ||
valueString = '0'; | ||
console.error('negative number is not allowed change numberFieldParameters.acceptNegative to true to allow negative numbers'); | ||
} | ||
const standardValueObject: JBInputStandardValueObject = { | ||
@@ -140,0 +157,0 @@ displayValue: valueString, |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"bugs": "https://github.com/javadbat/jb-input/issues", | ||
@@ -20,0 +20,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
151280
1577