text-fields
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -13,3 +13,3 @@ | ||
$parcel$export(module.exports, "default", () => $4fa36e821943b400$export$2e2bcd8739ae039); | ||
function $598d57897adea35a$var$notched() { | ||
function $c35decadc36dbe51$var$notched() { | ||
const labels = document.querySelectorAll(".floating-label"); | ||
@@ -34,12 +34,24 @@ labels.forEach((label)=>{ | ||
} | ||
var $598d57897adea35a$export$2e2bcd8739ae039 = $598d57897adea35a$var$notched; | ||
var $c35decadc36dbe51$export$2e2bcd8739ae039 = $c35decadc36dbe51$var$notched; | ||
function $b4201eebdf0099a8$var$observers(field, container) { | ||
function $6f47aa3ef7224efa$var$required(field, container, fieldType) { | ||
if (field.required) container.classList.add(fieldType ? "textarea--error" : "input--error"); | ||
else container.classList.remove(fieldType ? "textarea--error" : "input--error"); | ||
} | ||
var $6f47aa3ef7224efa$export$2e2bcd8739ae039 = $6f47aa3ef7224efa$var$required; | ||
function $51dd5d3f7e8bc6e9$var$disabled(field, container, fieldType) { | ||
if (field.disabled) container.classList.add(fieldType ? "textarea--disabled" : "input--disabled"); | ||
else container.classList.remove(fieldType ? "textarea--disabled" : "input--disabled"); | ||
} | ||
var $51dd5d3f7e8bc6e9$export$2e2bcd8739ae039 = $51dd5d3f7e8bc6e9$var$disabled; | ||
function $2547ed608777a5fe$var$observers(field, container) { | ||
const fieldType = field instanceof HTMLTextAreaElement; | ||
const observer = new MutationObserver(()=>{ | ||
if (field.required) container.classList.add(fieldType ? "textarea--error" : "input--error"); | ||
else container.classList.remove(fieldType ? "textarea--error" : "input--error"); | ||
if (field.disabled) container.classList.add(fieldType ? "textarea--disabled" : "input--disabled"); | ||
else container.classList.remove(fieldType ? "textarea--disabled" : "input--disabled"); | ||
(0, $6f47aa3ef7224efa$export$2e2bcd8739ae039)(field, container, fieldType); | ||
(0, $51dd5d3f7e8bc6e9$export$2e2bcd8739ae039)(field, container, fieldType); | ||
}); | ||
@@ -54,14 +66,13 @@ observer.observe(field, { | ||
} | ||
var $b4201eebdf0099a8$export$2e2bcd8739ae039 = $b4201eebdf0099a8$var$observers; | ||
var $2547ed608777a5fe$export$2e2bcd8739ae039 = $2547ed608777a5fe$var$observers; | ||
function $3a21e1140688247a$var$getNotchWidth(notch) { | ||
function $f05f33b2a1e3bc6c$var$getNotchWidth(notch) { | ||
const label = notch.querySelector(".floating-label"); | ||
return label ? `${(parseFloat(getComputedStyle(label).width) + 13) * 0.75}px` : "auto"; | ||
} | ||
function $3a21e1140688247a$var$filled(field, container, fieldType) { | ||
if (field.value.trim().length > 0) container.classList.add(fieldType ? "textarea--filled" : "input--filled"); | ||
else container.classList.remove(fieldType ? "textarea--filled" : "input--filled"); | ||
} | ||
function $3a21e1140688247a$var$textareaResizeable(field, container, fieldType) { | ||
var $f05f33b2a1e3bc6c$export$2e2bcd8739ae039 = $f05f33b2a1e3bc6c$var$getNotchWidth; | ||
function $1f6247984b559a91$var$textareaResizeable(field, container, fieldType) { | ||
if (fieldType && container.classList.contains("textarea--auto-resizeable")) { | ||
@@ -73,3 +84,14 @@ const currentField = field; | ||
} | ||
function $3a21e1140688247a$var$listeners(field, container, notch, fieldType) { | ||
var $1f6247984b559a91$export$2e2bcd8739ae039 = $1f6247984b559a91$var$textareaResizeable; | ||
function $a937e105c7bb00ac$var$filled(field, container, fieldType) { | ||
if (field.value.trim().length > 0) container.classList.add(fieldType ? "textarea--filled" : "input--filled"); | ||
else container.classList.remove(fieldType ? "textarea--filled" : "input--filled"); | ||
} | ||
var $a937e105c7bb00ac$export$2e2bcd8739ae039 = $a937e105c7bb00ac$var$filled; | ||
function $c863a16b060bf865$var$listeners(field, container, notch, fieldType) { | ||
const eventType = fieldType ? "input" : "change"; | ||
@@ -79,3 +101,3 @@ const notchStyle = notch.style; | ||
container.classList.add(fieldType ? "textarea--focused" : "input--focused"); | ||
notchStyle.width = $3a21e1140688247a$var$getNotchWidth(notch); | ||
notchStyle.width = (0, $f05f33b2a1e3bc6c$export$2e2bcd8739ae039)(notch); | ||
}); | ||
@@ -87,9 +109,10 @@ field.addEventListener("blur", ()=>{ | ||
field.addEventListener(eventType, ()=>{ | ||
$3a21e1140688247a$var$filled(field, container, fieldType); | ||
$3a21e1140688247a$var$textareaResizeable(field, container, fieldType); | ||
(0, $a937e105c7bb00ac$export$2e2bcd8739ae039)(field, container, fieldType); | ||
(0, $1f6247984b559a91$export$2e2bcd8739ae039)(field, container, fieldType); | ||
}); | ||
$3a21e1140688247a$var$filled(field, container, fieldType); | ||
notchStyle.width = $3a21e1140688247a$var$getNotchWidth(notch); | ||
(0, $a937e105c7bb00ac$export$2e2bcd8739ae039)(field, container, fieldType); | ||
(0, $51dd5d3f7e8bc6e9$export$2e2bcd8739ae039)(field, container, fieldType); | ||
notchStyle.width = (0, $f05f33b2a1e3bc6c$export$2e2bcd8739ae039)(notch); | ||
} | ||
var $3a21e1140688247a$export$2e2bcd8739ae039 = $3a21e1140688247a$var$listeners; | ||
var $c863a16b060bf865$export$2e2bcd8739ae039 = $c863a16b060bf865$var$listeners; | ||
@@ -99,3 +122,3 @@ | ||
notches: [], | ||
notched: $598d57897adea35a$export$2e2bcd8739ae039, | ||
notched: $c35decadc36dbe51$export$2e2bcd8739ae039, | ||
handlers () { | ||
@@ -110,4 +133,4 @@ const fields = [ | ||
const fieldType = field instanceof HTMLTextAreaElement; | ||
(0, $b4201eebdf0099a8$export$2e2bcd8739ae039)(field, container, notch); | ||
(0, $3a21e1140688247a$export$2e2bcd8739ae039)(field, container, notch, fieldType); | ||
(0, $2547ed608777a5fe$export$2e2bcd8739ae039)(field, container, notch); | ||
(0, $c863a16b060bf865$export$2e2bcd8739ae039)(field, container, notch, fieldType); | ||
}); | ||
@@ -114,0 +137,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
function $85068ae01dc596ad$var$notched() { | ||
function $b6e9082d8b811de5$var$notched() { | ||
const labels = document.querySelectorAll(".floating-label"); | ||
@@ -21,12 +21,24 @@ labels.forEach((label)=>{ | ||
} | ||
var $85068ae01dc596ad$export$2e2bcd8739ae039 = $85068ae01dc596ad$var$notched; | ||
var $b6e9082d8b811de5$export$2e2bcd8739ae039 = $b6e9082d8b811de5$var$notched; | ||
function $12b7859a657b7ab7$var$observers(field, container) { | ||
function $a138b0cb7beaacac$var$required(field, container, fieldType) { | ||
if (field.required) container.classList.add(fieldType ? "textarea--error" : "input--error"); | ||
else container.classList.remove(fieldType ? "textarea--error" : "input--error"); | ||
} | ||
var $a138b0cb7beaacac$export$2e2bcd8739ae039 = $a138b0cb7beaacac$var$required; | ||
function $f4d83fd2c8dbf337$var$disabled(field, container, fieldType) { | ||
if (field.disabled) container.classList.add(fieldType ? "textarea--disabled" : "input--disabled"); | ||
else container.classList.remove(fieldType ? "textarea--disabled" : "input--disabled"); | ||
} | ||
var $f4d83fd2c8dbf337$export$2e2bcd8739ae039 = $f4d83fd2c8dbf337$var$disabled; | ||
function $8019ab4d39907fdc$var$observers(field, container) { | ||
const fieldType = field instanceof HTMLTextAreaElement; | ||
const observer = new MutationObserver(()=>{ | ||
if (field.required) container.classList.add(fieldType ? "textarea--error" : "input--error"); | ||
else container.classList.remove(fieldType ? "textarea--error" : "input--error"); | ||
if (field.disabled) container.classList.add(fieldType ? "textarea--disabled" : "input--disabled"); | ||
else container.classList.remove(fieldType ? "textarea--disabled" : "input--disabled"); | ||
(0, $a138b0cb7beaacac$export$2e2bcd8739ae039)(field, container, fieldType); | ||
(0, $f4d83fd2c8dbf337$export$2e2bcd8739ae039)(field, container, fieldType); | ||
}); | ||
@@ -41,14 +53,13 @@ observer.observe(field, { | ||
} | ||
var $12b7859a657b7ab7$export$2e2bcd8739ae039 = $12b7859a657b7ab7$var$observers; | ||
var $8019ab4d39907fdc$export$2e2bcd8739ae039 = $8019ab4d39907fdc$var$observers; | ||
function $8290bb03cd88138a$var$getNotchWidth(notch) { | ||
function $2cd48c5c256c7ff7$var$getNotchWidth(notch) { | ||
const label = notch.querySelector(".floating-label"); | ||
return label ? `${(parseFloat(getComputedStyle(label).width) + 13) * 0.75}px` : "auto"; | ||
} | ||
function $8290bb03cd88138a$var$filled(field, container, fieldType) { | ||
if (field.value.trim().length > 0) container.classList.add(fieldType ? "textarea--filled" : "input--filled"); | ||
else container.classList.remove(fieldType ? "textarea--filled" : "input--filled"); | ||
} | ||
function $8290bb03cd88138a$var$textareaResizeable(field, container, fieldType) { | ||
var $2cd48c5c256c7ff7$export$2e2bcd8739ae039 = $2cd48c5c256c7ff7$var$getNotchWidth; | ||
function $9d84a9ca8fdba971$var$textareaResizeable(field, container, fieldType) { | ||
if (fieldType && container.classList.contains("textarea--auto-resizeable")) { | ||
@@ -60,3 +71,14 @@ const currentField = field; | ||
} | ||
function $8290bb03cd88138a$var$listeners(field, container, notch, fieldType) { | ||
var $9d84a9ca8fdba971$export$2e2bcd8739ae039 = $9d84a9ca8fdba971$var$textareaResizeable; | ||
function $dc1e20be3f06df2e$var$filled(field, container, fieldType) { | ||
if (field.value.trim().length > 0) container.classList.add(fieldType ? "textarea--filled" : "input--filled"); | ||
else container.classList.remove(fieldType ? "textarea--filled" : "input--filled"); | ||
} | ||
var $dc1e20be3f06df2e$export$2e2bcd8739ae039 = $dc1e20be3f06df2e$var$filled; | ||
function $b60dcf6944ff4d60$var$listeners(field, container, notch, fieldType) { | ||
const eventType = fieldType ? "input" : "change"; | ||
@@ -66,3 +88,3 @@ const notchStyle = notch.style; | ||
container.classList.add(fieldType ? "textarea--focused" : "input--focused"); | ||
notchStyle.width = $8290bb03cd88138a$var$getNotchWidth(notch); | ||
notchStyle.width = (0, $2cd48c5c256c7ff7$export$2e2bcd8739ae039)(notch); | ||
}); | ||
@@ -74,9 +96,10 @@ field.addEventListener("blur", ()=>{ | ||
field.addEventListener(eventType, ()=>{ | ||
$8290bb03cd88138a$var$filled(field, container, fieldType); | ||
$8290bb03cd88138a$var$textareaResizeable(field, container, fieldType); | ||
(0, $dc1e20be3f06df2e$export$2e2bcd8739ae039)(field, container, fieldType); | ||
(0, $9d84a9ca8fdba971$export$2e2bcd8739ae039)(field, container, fieldType); | ||
}); | ||
$8290bb03cd88138a$var$filled(field, container, fieldType); | ||
notchStyle.width = $8290bb03cd88138a$var$getNotchWidth(notch); | ||
(0, $dc1e20be3f06df2e$export$2e2bcd8739ae039)(field, container, fieldType); | ||
(0, $f4d83fd2c8dbf337$export$2e2bcd8739ae039)(field, container, fieldType); | ||
notchStyle.width = (0, $2cd48c5c256c7ff7$export$2e2bcd8739ae039)(notch); | ||
} | ||
var $8290bb03cd88138a$export$2e2bcd8739ae039 = $8290bb03cd88138a$var$listeners; | ||
var $b60dcf6944ff4d60$export$2e2bcd8739ae039 = $b60dcf6944ff4d60$var$listeners; | ||
@@ -86,3 +109,3 @@ | ||
notches: [], | ||
notched: $85068ae01dc596ad$export$2e2bcd8739ae039, | ||
notched: $b6e9082d8b811de5$export$2e2bcd8739ae039, | ||
handlers () { | ||
@@ -97,4 +120,4 @@ const fields = [ | ||
const fieldType = field instanceof HTMLTextAreaElement; | ||
(0, $12b7859a657b7ab7$export$2e2bcd8739ae039)(field, container, notch); | ||
(0, $8290bb03cd88138a$export$2e2bcd8739ae039)(field, container, notch, fieldType); | ||
(0, $8019ab4d39907fdc$export$2e2bcd8739ae039)(field, container, notch); | ||
(0, $b60dcf6944ff4d60$export$2e2bcd8739ae039)(field, container, notch, fieldType); | ||
}); | ||
@@ -101,0 +124,0 @@ }, |
{ | ||
"name": "text-fields", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Input, textarea, material", | ||
@@ -5,0 +5,0 @@ "author": "ux-ui.pro", |
@@ -1,4 +0,4 @@ | ||
import notched from './utils/notched'; | ||
import observers from './utils/observers'; | ||
import listeners from './utils/listeners'; | ||
import notched from './module/notched'; | ||
import observers from './module/observers'; | ||
import listeners from './module/listeners'; | ||
@@ -5,0 +5,0 @@ const TextFields = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81505
29
389