Comparing version 2.0.2 to 2.0.3
@@ -10,3 +10,3 @@ import HTML from './JBInput.html'; | ||
elements?: ElementsObject; | ||
#validationList:JBInputValidationItem[] = []; | ||
#validationList: JBInputValidationItem[] = []; | ||
#disabled = false; | ||
@@ -19,3 +19,3 @@ internals_?: ElementInternals; | ||
decreaseNumber?: () => void; | ||
get value() { | ||
get value(): string { | ||
return this.#value; | ||
@@ -32,6 +32,6 @@ } | ||
} | ||
get validationList():JBInputValidationItem[] { | ||
get validationList(): JBInputValidationItem[] { | ||
return this.#validationList; | ||
} | ||
set validationList(value:JBInputValidationItem[]) { | ||
set validationList(value: JBInputValidationItem[]) { | ||
this.#validationList = value; | ||
@@ -48,3 +48,3 @@ this.triggerInputValidation(false); | ||
} | ||
connectedCallback() { | ||
connectedCallback(): void { | ||
// standard web component event that called when all of dom is binded | ||
@@ -56,11 +56,11 @@ this.callOnLoadEvent(); | ||
} | ||
callOnLoadEvent() { | ||
callOnLoadEvent(): void { | ||
const event = new CustomEvent('load', { bubbles: true, composed: true }); | ||
this.dispatchEvent(event); | ||
} | ||
callOnInitEvent() { | ||
callOnInitEvent(): void { | ||
const event = new CustomEvent('init', { bubbles: true, composed: true }); | ||
this.dispatchEvent(event); | ||
} | ||
initWebComponent() { | ||
initWebComponent(): void { | ||
const shadowRoot = this.attachShadow({ | ||
@@ -78,4 +78,4 @@ mode: 'open', | ||
label: shadowRoot.querySelector('label .label-value')!, | ||
messageBox:shadowRoot.querySelector('.message-box')!, | ||
passwordTrigger:shadowRoot.querySelector('.password-trigger')!, | ||
messageBox: shadowRoot.querySelector('.message-box')!, | ||
passwordTrigger: shadowRoot.querySelector('.password-trigger')!, | ||
}; | ||
@@ -90,3 +90,3 @@ this.registerEventListener(); | ||
*/ | ||
standardValue(valueString: string) { | ||
standardValue(valueString: string): string { | ||
let standardedValue = valueString; | ||
@@ -103,3 +103,3 @@ if (this.getAttribute('type') == "number") { | ||
*/ | ||
standardValueForNumberInput(valueString: string) { | ||
standardValueForNumberInput(valueString: string): string { | ||
//if our input type is number and user want to set it to new value we do nececcery logic here | ||
@@ -130,3 +130,3 @@ const value: number = parseFloat(valueString); | ||
} | ||
registerEventListener() { | ||
registerEventListener(): void { | ||
this.elements!.input.addEventListener('change', (e) => this.onInputChange((e))); | ||
@@ -160,10 +160,10 @@ this.elements!.input.addEventListener('beforeinput', this.onInputBeforeInput.bind(this)); | ||
} | ||
static get observedAttributes() { | ||
static get observedAttributes(): string[] { | ||
return ['label', 'type', 'message', 'value', 'name', 'autocomplete', 'placeholder', 'disabled', 'inputmode']; | ||
} | ||
attributeChangedCallback(name: string, oldValue: string, newValue: string) { | ||
attributeChangedCallback(name: string, oldValue: string, newValue: string): void { | ||
// do something when an attribute has changed | ||
this.onAttributeChange(name, newValue); | ||
} | ||
onAttributeChange(name: string, value: string) { | ||
onAttributeChange(name: string, value: string): void { | ||
switch (name) { | ||
@@ -218,3 +218,3 @@ case 'label': | ||
} | ||
initPassword() { | ||
initPassword(): void { | ||
this.elements!.inputBox.classList.add('type-password'); | ||
@@ -229,3 +229,3 @@ this.isPasswordvisible = false; | ||
*/ | ||
setNumberFieldParameter(numberFieldParameters: NumberFieldParameter) { | ||
setNumberFieldParameter(numberFieldParameters: NumberFieldParameter): void { | ||
if (numberFieldParameters.step && !isNaN(numberFieldParameters.step)) { | ||
@@ -241,3 +241,3 @@ this.numberFieldParameters!.step = numberFieldParameters.step; | ||
} | ||
onPasswordTriggerClicked() { | ||
onPasswordTriggerClicked(): void { | ||
this.isPasswordvisible = !this.isPasswordvisible; | ||
@@ -258,3 +258,3 @@ const textField = this.elements!.input; | ||
*/ | ||
onInputKeyDown(e: KeyboardEvent) { | ||
onInputKeyDown(e: KeyboardEvent): void { | ||
//handle up and down on number key | ||
@@ -287,3 +287,3 @@ if (this.getAttribute('type') == "number") { | ||
} | ||
onInputKeyPress(e: KeyboardEvent) { | ||
onInputKeyPress(e: KeyboardEvent): void { | ||
const keyPressInitObj: KeyboardEventInit = { | ||
@@ -306,3 +306,3 @@ key: e.key, | ||
} | ||
onInputKeyup(e: KeyboardEvent) { | ||
onInputKeyup(e: KeyboardEvent): void { | ||
const keyUpInitObj = { | ||
@@ -324,3 +324,3 @@ key: e.key, | ||
} | ||
onInputEnter() { | ||
onInputEnter(): void { | ||
const event = new CustomEvent('enter'); | ||
@@ -333,3 +333,3 @@ this.dispatchEvent(event); | ||
*/ | ||
onInputInput(e: InputEvent) { | ||
onInputInput(e: InputEvent): void { | ||
const inputText = (e.target as HTMLInputElement).value; | ||
@@ -358,3 +358,3 @@ this.value = inputText; | ||
*/ | ||
onInputBeforeInput(e: InputEvent) { | ||
onInputBeforeInput(e: InputEvent): void { | ||
const eventInitDict = { | ||
@@ -378,3 +378,3 @@ bubbles: e.bubbles, | ||
} | ||
onInputChange(e:Event): void { | ||
onInputChange(e: Event): void { | ||
const inputText = (e.target as HTMLInputElement).value; | ||
@@ -386,3 +386,3 @@ this.triggerInputValidation(true); | ||
} | ||
dispatchOnChangeEvent() { | ||
dispatchOnChangeEvent():void{ | ||
const validationObject = this.checkInputValidation(this.value); | ||
@@ -397,3 +397,3 @@ const event = new CustomEvent('change', { | ||
} | ||
triggerInputValidation(showError = true) { | ||
triggerInputValidation(showError = true):ValidationResult{ | ||
// this method is for use out of component for example if user click on submit button and developer want to check if all fields are valid | ||
@@ -419,4 +419,4 @@ //takeAction determine if we want to show user error in web component difualtManner or developer will handle it by himself | ||
} | ||
checkInputValidation(value:string) { | ||
const validationResult:ValidationResult = { | ||
checkInputValidation(value: string) { | ||
const validationResult: ValidationResult = { | ||
validationList: [], | ||
@@ -434,3 +434,3 @@ isAllValid: true | ||
} | ||
checkValidation(text: string, validation: JBInputValidationItem): ValidationResultItem{ | ||
checkValidation(text: string, validation: JBInputValidationItem): ValidationResultItem { | ||
let testRes; | ||
@@ -459,3 +459,3 @@ if (validation.validator instanceof RegExp) { | ||
} | ||
showValidationError(error:string) { | ||
showValidationError(error: string) { | ||
this.elements!.messageBox.innerHTML = error; | ||
@@ -477,3 +477,3 @@ this.elements!.messageBox.classList.add('error'); | ||
initNumberField() { | ||
const addFloatNumber = (num1:number, num2:number) => { | ||
const addFloatNumber = (num1: number, num2: number) => { | ||
const prec1 = `${num1}`.split('.')[1]; | ||
@@ -480,0 +480,0 @@ const prec2 = `${num2}`.split('.')[1]; |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"bugs": "https://github.com/javadbat/jb-input/issues", | ||
@@ -20,0 +20,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
127608