text-fields
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -19,22 +19,23 @@ function $parcel$defineInteropFlag(a) { | ||
const $4fa36e821943b400$var$customizeLabel = (textField)=>{ | ||
const label = textField.previousElementSibling; | ||
const notchedOutline = textField.parentElement.querySelector(".notched-outline"); | ||
if (!notchedOutline) textField.parentElement.insertAdjacentHTML("afterbegin", $4fa36e821943b400$var$notched); | ||
else notchedOutline.querySelector(".notched-outline__notch").appendChild(label); | ||
if (notchedOutline) return; | ||
textField.parentElement.insertAdjacentHTML("afterbegin", $4fa36e821943b400$var$notched); | ||
const notch = textField.parentElement.querySelector(".notched-outline__notch"); | ||
if (!notch.contains(label)) notch.appendChild(label); | ||
}; | ||
const $4fa36e821943b400$var$handleInput = (input, classList, label, style)=>{ | ||
if (input && label) { | ||
const $4fa36e821943b400$var$handleInput = (input, classList, label1, style)=>{ | ||
if (input && label1) { | ||
if (input.disabled) classList.add("input--disabled"); | ||
if (input.required) label.classList.add("floating-label--required"); | ||
if (input.required) label1.classList.add("floating-label--required"); | ||
if (input.value.trim().length > 0) { | ||
classList.add("input--filled"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
} | ||
input.addEventListener("focus", ()=>{ | ||
classList.add("input--focused"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
}); | ||
input.addEventListener("blur", ()=>{ | ||
classList.remove("input--focused"); | ||
if (input.value.trim().length <= 0 && label) style.width = "auto"; | ||
if (input.value.trim().length <= 0 && label1) style.width = "auto"; | ||
}); | ||
@@ -46,17 +47,17 @@ input.addEventListener("input", ()=>{ | ||
}; | ||
const $4fa36e821943b400$var$handleTextarea = (textarea, classList, label, style)=>{ | ||
if (textarea && label) { | ||
const $4fa36e821943b400$var$handleTextarea = (textarea, classList, label1, style)=>{ | ||
if (textarea && label1) { | ||
if (textarea.disabled) classList.add("textarea--disabled"); | ||
if (textarea.required) label.classList.add("floating-label--required"); | ||
if (textarea.required) label1.classList.add("floating-label--required"); | ||
if (textarea.value.trim().length > 0) { | ||
classList.add("textarea--filled"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
} | ||
textarea.addEventListener("focus", ()=>{ | ||
classList.add("textarea--focused"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
}); | ||
textarea.addEventListener("blur", ()=>{ | ||
classList.remove("textarea--focused"); | ||
if (textarea.value.trim().length <= 0 && label) style.width = "auto"; | ||
if (textarea.value.trim().length <= 0 && label1) style.width = "auto"; | ||
}); | ||
@@ -77,8 +78,8 @@ textarea.addEventListener("change", ()=>{ | ||
for (let input of inputs){ | ||
const label = input.previousElementSibling; | ||
if (!label) return; | ||
const label1 = input.previousElementSibling; | ||
if (!label1) return; | ||
$4fa36e821943b400$var$customizeLabel(input); | ||
const { classList: classList } = input.parentNode; | ||
const { style: style } = label.parentNode; | ||
$4fa36e821943b400$var$handleInput(input, classList, label, style); | ||
const { style: style } = label1.parentNode; | ||
$4fa36e821943b400$var$handleInput(input, classList, label1, style); | ||
} | ||
@@ -89,8 +90,8 @@ }; | ||
for (let textarea of textareas){ | ||
const label = textarea.previousElementSibling; | ||
if (!label) return; | ||
const label1 = textarea.previousElementSibling; | ||
if (!label1) return; | ||
$4fa36e821943b400$var$customizeLabel(textarea); | ||
const { classList: classList } = textarea.parentNode; | ||
const { style: style } = label.parentNode; | ||
$4fa36e821943b400$var$handleTextarea(textarea, classList, label, style); | ||
const { style: style } = label1.parentNode; | ||
$4fa36e821943b400$var$handleTextarea(textarea, classList, label1, style); | ||
} | ||
@@ -97,0 +98,0 @@ }; |
@@ -9,22 +9,23 @@ const $cf838c15c8b009ba$var$notched = ` | ||
const $cf838c15c8b009ba$var$customizeLabel = (textField)=>{ | ||
const label = textField.previousElementSibling; | ||
const notchedOutline = textField.parentElement.querySelector(".notched-outline"); | ||
if (!notchedOutline) textField.parentElement.insertAdjacentHTML("afterbegin", $cf838c15c8b009ba$var$notched); | ||
else notchedOutline.querySelector(".notched-outline__notch").appendChild(label); | ||
if (notchedOutline) return; | ||
textField.parentElement.insertAdjacentHTML("afterbegin", $cf838c15c8b009ba$var$notched); | ||
const notch = textField.parentElement.querySelector(".notched-outline__notch"); | ||
if (!notch.contains(label)) notch.appendChild(label); | ||
}; | ||
const $cf838c15c8b009ba$var$handleInput = (input, classList, label, style)=>{ | ||
if (input && label) { | ||
const $cf838c15c8b009ba$var$handleInput = (input, classList, label1, style)=>{ | ||
if (input && label1) { | ||
if (input.disabled) classList.add("input--disabled"); | ||
if (input.required) label.classList.add("floating-label--required"); | ||
if (input.required) label1.classList.add("floating-label--required"); | ||
if (input.value.trim().length > 0) { | ||
classList.add("input--filled"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
} | ||
input.addEventListener("focus", ()=>{ | ||
classList.add("input--focused"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
}); | ||
input.addEventListener("blur", ()=>{ | ||
classList.remove("input--focused"); | ||
if (input.value.trim().length <= 0 && label) style.width = "auto"; | ||
if (input.value.trim().length <= 0 && label1) style.width = "auto"; | ||
}); | ||
@@ -36,17 +37,17 @@ input.addEventListener("input", ()=>{ | ||
}; | ||
const $cf838c15c8b009ba$var$handleTextarea = (textarea, classList, label, style)=>{ | ||
if (textarea && label) { | ||
const $cf838c15c8b009ba$var$handleTextarea = (textarea, classList, label1, style)=>{ | ||
if (textarea && label1) { | ||
if (textarea.disabled) classList.add("textarea--disabled"); | ||
if (textarea.required) label.classList.add("floating-label--required"); | ||
if (textarea.required) label1.classList.add("floating-label--required"); | ||
if (textarea.value.trim().length > 0) { | ||
classList.add("textarea--filled"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
} | ||
textarea.addEventListener("focus", ()=>{ | ||
classList.add("textarea--focused"); | ||
style.width = (label.clientWidth + 13) * .75 + "px"; | ||
style.width = (label1.clientWidth + 13) * .75 + "px"; | ||
}); | ||
textarea.addEventListener("blur", ()=>{ | ||
classList.remove("textarea--focused"); | ||
if (textarea.value.trim().length <= 0 && label) style.width = "auto"; | ||
if (textarea.value.trim().length <= 0 && label1) style.width = "auto"; | ||
}); | ||
@@ -67,8 +68,8 @@ textarea.addEventListener("change", ()=>{ | ||
for (let input of inputs){ | ||
const label = input.previousElementSibling; | ||
if (!label) return; | ||
const label1 = input.previousElementSibling; | ||
if (!label1) return; | ||
$cf838c15c8b009ba$var$customizeLabel(input); | ||
const { classList: classList } = input.parentNode; | ||
const { style: style } = label.parentNode; | ||
$cf838c15c8b009ba$var$handleInput(input, classList, label, style); | ||
const { style: style } = label1.parentNode; | ||
$cf838c15c8b009ba$var$handleInput(input, classList, label1, style); | ||
} | ||
@@ -79,8 +80,8 @@ }; | ||
for (let textarea of textareas){ | ||
const label = textarea.previousElementSibling; | ||
if (!label) return; | ||
const label1 = textarea.previousElementSibling; | ||
if (!label1) return; | ||
$cf838c15c8b009ba$var$customizeLabel(textarea); | ||
const { classList: classList } = textarea.parentNode; | ||
const { style: style } = label.parentNode; | ||
$cf838c15c8b009ba$var$handleTextarea(textarea, classList, label, style); | ||
const { style: style } = label1.parentNode; | ||
$cf838c15c8b009ba$var$handleTextarea(textarea, classList, label1, style); | ||
} | ||
@@ -87,0 +88,0 @@ }; |
{ | ||
"name": "text-fields", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Input, textarea, material, vanilla", | ||
@@ -5,0 +5,0 @@ "author": "ux-ui.pro", |
@@ -10,9 +10,12 @@ const notched = ` | ||
const customizeLabel = (textField) => { | ||
const label = textField.previousElementSibling | ||
const notchedOutline = textField.parentElement.querySelector('.notched-outline') | ||
if (!notchedOutline) { | ||
textField.parentElement.insertAdjacentHTML('afterbegin', notched) | ||
} else { | ||
notchedOutline.querySelector('.notched-outline__notch').appendChild(label) | ||
if (notchedOutline) return | ||
textField.parentElement.insertAdjacentHTML('afterbegin', notched) | ||
const notch = textField.parentElement.querySelector('.notched-outline__notch') | ||
if (!notch.contains(label)) { | ||
notch.appendChild(label) | ||
} | ||
@@ -19,0 +22,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72377
325