vue3-float-label 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,73 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
import { computed as e, createCommentVNode as t, createElementBlock as n, createElementVNode as r, createTextVNode as i, normalizeClass as a, onBeforeUnmount as o, onMounted as s, openBlock as c, ref as l, renderSlot as u, toDisplayString as d, unref as f, watch as p } from "vue";
|
|
2
|
+
//#region src/components/FloatLabel.vue
|
|
3
|
+
var m = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "float-label__label float-label--no-click"
|
|
6
|
+
}, h = { class: "float-label__label__text" }, g = ["for"], _ = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "float-label__label__bg"
|
|
9
|
+
}, v = { class: "float-label__label__text" }, y = "[type=date], [type=datetime-local], [type=datetime], [type=email], [type=month], [type=number], [type=password], [type=search], [type=tel], [type=text], [type=time], [type=url], [type=week], textarea, select", b = {
|
|
10
|
+
__name: "FloatLabel",
|
|
11
|
+
props: {
|
|
12
|
+
label: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: ""
|
|
15
|
+
},
|
|
16
|
+
float: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: null
|
|
19
|
+
},
|
|
20
|
+
onFocus: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: !1
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
setup(b) {
|
|
26
|
+
let x = b, S = l(null), C = l(""), w = l(""), T = l(null), E = l({}), D = l(""), O = l(""), k = l(!1), A = l(!1), j = l(!1), M = e(() => x.label), N = e(() => O.value === "select" ? !0 : w.value && C.value !== w.value), P = e(() => {
|
|
27
|
+
let e = !1;
|
|
28
|
+
return e = x.float ? !0 : k.value && k.value !== "0", e;
|
|
29
|
+
}), F = () => {
|
|
30
|
+
C.value = M.value ? x.label : w.value;
|
|
31
|
+
}, I = () => E.value.getAttribute("id"), L = () => "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (e) => (e ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> e / 4).toString(16)), R = () => {
|
|
32
|
+
switch (O.value) {
|
|
33
|
+
case "input":
|
|
34
|
+
case "textarea": return E.value.placeholder;
|
|
35
|
+
case "select":
|
|
36
|
+
let e = E.value.querySelector("option:disabled");
|
|
37
|
+
return e ? e.innerHTML : "";
|
|
38
|
+
default: return "";
|
|
39
|
+
}
|
|
40
|
+
}, z = () => {
|
|
41
|
+
D.value || (D.value = L(), E.value.id = D.value);
|
|
42
|
+
}, B = () => {
|
|
43
|
+
O.value === "select" ? E.value.addEventListener("change", H) : E.value.addEventListener("input", H);
|
|
44
|
+
}, V = () => {
|
|
45
|
+
O.value === "select" ? E.value.removeEventListener("change", H) : E.value.removeEventListener("input", H);
|
|
46
|
+
}, H = (e) => {
|
|
47
|
+
k.value = e.target.value.length > 0;
|
|
48
|
+
};
|
|
49
|
+
return p(M, (e, t) => {
|
|
50
|
+
F();
|
|
51
|
+
}), s(() => {
|
|
52
|
+
T.value = x.label, E.value = S.value.querySelector(y), A.value = !!E.value, j.value = x.float === null, A.value ? (D.value = I(), O.value = E.value ? E.value.tagName.toLowerCase() : "", k.value = !!E.value.value, w.value = R(), z(), j.value === !0 && setTimeout(() => {
|
|
53
|
+
B();
|
|
54
|
+
}, 200)) : w.value = "", F();
|
|
55
|
+
}), o(() => {
|
|
56
|
+
A.value && V();
|
|
57
|
+
}), (e, o) => (c(), n("div", {
|
|
58
|
+
class: a(["float-label", {
|
|
59
|
+
"float-label--fade-anim": N.value,
|
|
60
|
+
"float-label--on-focus": x.onFocus,
|
|
61
|
+
"float-label--fixed": P.value
|
|
62
|
+
}]),
|
|
63
|
+
ref_key: "root",
|
|
64
|
+
ref: S
|
|
65
|
+
}, [u(e.$slots, "default"), f(O) === "" ? (c(), n("div", m, [r("span", h, d(f(C)), 1)])) : (c(), n("label", {
|
|
66
|
+
key: 1,
|
|
67
|
+
class: a(["float-label__label", { "float-label--no-click": f(O) === "select" }]),
|
|
68
|
+
for: f(D)
|
|
69
|
+
}, [
|
|
70
|
+
f(O) === "textarea" ? (c(), n("span", _)) : t("", !0),
|
|
71
|
+
o[0] ||= i(),
|
|
72
|
+
r("span", v, d(f(C)), 1)
|
|
73
|
+
], 10, g))], 2));
|
|
74
|
+
}
|
|
73
75
|
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { b as FloatLabel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue")):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Vue3FloatLabel={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n={key:0,class:`float-label__label float-label--no-click`},r={class:`float-label__label__text`},i=[`for`],a={key:0,class:`float-label__label__bg`},o={class:`float-label__label__text`},s=`[type=date], [type=datetime-local], [type=datetime], [type=email], [type=month], [type=number], [type=password], [type=search], [type=tel], [type=text], [type=time], [type=url], [type=week], textarea, select`;e.FloatLabel={__name:`FloatLabel`,props:{label:{type:String,default:``},float:{type:Boolean,default:null},onFocus:{type:Boolean,default:!1}},setup(e){let c=e,l=(0,t.ref)(null),u=(0,t.ref)(``),d=(0,t.ref)(``),f=(0,t.ref)(null),p=(0,t.ref)({}),m=(0,t.ref)(``),h=(0,t.ref)(``),g=(0,t.ref)(!1),_=(0,t.ref)(!1),v=(0,t.ref)(!1),y=(0,t.computed)(()=>c.label),b=(0,t.computed)(()=>h.value===`select`?!0:d.value&&u.value!==d.value),x=(0,t.computed)(()=>{let e=!1;return e=c.float?!0:g.value&&g.value!==`0`,e}),S=()=>{u.value=y.value?c.label:d.value},C=()=>p.value.getAttribute(`id`),w=()=>`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)),T=()=>{switch(h.value){case`input`:case`textarea`:return p.value.placeholder;case`select`:let e=p.value.querySelector(`option:disabled`);return e?e.innerHTML:``;default:return``}},E=()=>{m.value||(m.value=w(),p.value.id=m.value)},D=()=>{h.value===`select`?p.value.addEventListener(`change`,k):p.value.addEventListener(`input`,k)},O=()=>{h.value===`select`?p.value.removeEventListener(`change`,k):p.value.removeEventListener(`input`,k)},k=e=>{g.value=e.target.value.length>0};return(0,t.watch)(y,(e,t)=>{S()}),(0,t.onMounted)(()=>{f.value=c.label,p.value=l.value.querySelector(s),_.value=!!p.value,v.value=c.float===null,_.value?(m.value=C(),h.value=p.value?p.value.tagName.toLowerCase():``,g.value=!!p.value.value,d.value=T(),E(),v.value===!0&&setTimeout(()=>{D()},200)):d.value=``,S()}),(0,t.onBeforeUnmount)(()=>{_.value&&O()}),(e,s)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`float-label`,{"float-label--fade-anim":b.value,"float-label--on-focus":c.onFocus,"float-label--fixed":x.value}]),ref_key:`root`,ref:l},[(0,t.renderSlot)(e.$slots,`default`),(0,t.unref)(h)===``?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,n,[(0,t.createElementVNode)(`span`,r,(0,t.toDisplayString)((0,t.unref)(u)),1)])):((0,t.openBlock)(),(0,t.createElementBlock)(`label`,{key:1,class:(0,t.normalizeClass)([`float-label__label`,{"float-label--no-click":(0,t.unref)(h)===`select`}]),for:(0,t.unref)(m)},[(0,t.unref)(h)===`textarea`?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,a)):(0,t.createCommentVNode)(``,!0),s[0]||=(0,t.createTextVNode)(),(0,t.createElementVNode)(`span`,o,(0,t.toDisplayString)((0,t.unref)(u)),1)],10,i))],2))}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue3-float-label",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "A Vue 3 component for float labels.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Justin Moreland",
|
|
@@ -35,9 +35,8 @@
|
|
|
35
35
|
"preview": "vite preview"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@vitejs/plugin-vue": "^
|
|
39
|
-
"
|
|
40
|
-
"vite": "^6.4.1"
|
|
38
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
39
|
+
"vite": "^8.0.16"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
42
|
"vue": "^3.5.13"
|