vft 0.0.229 → 0.0.232
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,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as M, ref as v, reactive as
|
|
2
|
-
import { addUnit as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as M, ref as v, reactive as N, computed as u, watch as s, nextTick as E, onUnmounted as V, onMounted as q, createElementBlock as D, openBlock as G, normalizeStyle as I, createElementVNode as w, renderSlot as B } from "vue";
|
|
2
|
+
import { addUnit as J } from "@vft/utils";
|
|
3
|
+
import { addListener as K, removeListener as P } from "resize-detector/esm";
|
|
4
|
+
const Q = ["title", "aria-label"], W = M({
|
|
5
5
|
name: "vft-clamp"
|
|
6
|
-
}),
|
|
7
|
-
...
|
|
6
|
+
}), p = /* @__PURE__ */ M({
|
|
7
|
+
...W,
|
|
8
8
|
props: {
|
|
9
9
|
text: {},
|
|
10
10
|
maxHeight: {},
|
|
@@ -16,20 +16,20 @@ const W = ["title", "aria-label"], X = M({
|
|
|
16
16
|
},
|
|
17
17
|
emits: ["clamp-change", "update:expanded"],
|
|
18
18
|
setup(e, { expose: T, emit: $ }) {
|
|
19
|
-
const
|
|
19
|
+
const R = $, a = v(null), r = v(null), x = v(null), l = N({
|
|
20
20
|
offset: 0,
|
|
21
21
|
localExpanded: e.expanded,
|
|
22
22
|
unregisterResizeCallback: null
|
|
23
|
-
}),
|
|
23
|
+
}), j = u(() => {
|
|
24
24
|
if (!l.localExpanded && e.maxHeight)
|
|
25
|
-
return
|
|
26
|
-
}),
|
|
27
|
-
x.value && (x.value.textContent =
|
|
25
|
+
return J(e.maxHeight);
|
|
26
|
+
}), y = () => {
|
|
27
|
+
x.value && (x.value.textContent = S.value);
|
|
28
28
|
}, c = () => {
|
|
29
|
-
l.localExpanded || (
|
|
30
|
-
},
|
|
31
|
-
e.text && (l.offset = e.text.length, C(), e.autoResize && a.value && (
|
|
32
|
-
a.value &&
|
|
29
|
+
l.localExpanded || (y(), (d() || n.value) && g());
|
|
30
|
+
}, k = () => {
|
|
31
|
+
e.text && (l.offset = e.text.length, C(), e.autoResize && a.value && (K(a.value, c), l.unregisterResizeCallback = () => {
|
|
32
|
+
a.value && P(a.value, c);
|
|
33
33
|
}), c());
|
|
34
34
|
}, C = () => {
|
|
35
35
|
var t;
|
|
@@ -42,19 +42,19 @@ const W = ["title", "aria-label"], X = M({
|
|
|
42
42
|
).length : 0, g = (...t) => {
|
|
43
43
|
const [i = 0, f = l.offset] = t;
|
|
44
44
|
if (f - i <= 3) {
|
|
45
|
-
|
|
45
|
+
U();
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
const o = Math.floor((f + i) / 2);
|
|
49
49
|
h(o), d() ? g(i, o) : g(o, f);
|
|
50
50
|
}, h = (t) => {
|
|
51
|
-
l.offset = t,
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
51
|
+
l.offset = t, y();
|
|
52
|
+
}, U = () => {
|
|
53
|
+
A(), O();
|
|
54
|
+
}, A = () => {
|
|
55
55
|
for (; (!d() || m() < 2) && l.offset < e.text.length; )
|
|
56
56
|
H(1);
|
|
57
|
-
},
|
|
57
|
+
}, O = () => {
|
|
58
58
|
for (; d() && m() > 1 && l.offset > 0; )
|
|
59
59
|
H(-1);
|
|
60
60
|
}, H = (t) => {
|
|
@@ -69,7 +69,7 @@ const W = ["title", "aria-label"], X = M({
|
|
|
69
69
|
},
|
|
70
70
|
{ immediate: !0 }
|
|
71
71
|
);
|
|
72
|
-
const
|
|
72
|
+
const S = u(() => n.value ? F.value : e.text), F = u(() => {
|
|
73
73
|
if (e.location === "start")
|
|
74
74
|
return e.ellipsis + (e.text.slice(0, l.offset) || "").trim();
|
|
75
75
|
if (e.location === "middle") {
|
|
@@ -105,22 +105,22 @@ const W = ["title", "aria-label"], X = M({
|
|
|
105
105
|
() => [e.text, e.autoResize].join(),
|
|
106
106
|
() => {
|
|
107
107
|
E(() => {
|
|
108
|
-
|
|
108
|
+
k();
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
),
|
|
111
|
+
), V(() => {
|
|
112
112
|
C();
|
|
113
|
-
}),
|
|
114
|
-
|
|
113
|
+
}), q(() => {
|
|
114
|
+
k();
|
|
115
115
|
}), T({
|
|
116
116
|
isClamped: n
|
|
117
|
-
}), (t, i) => (
|
|
117
|
+
}), (t, i) => (G(), D("div", {
|
|
118
118
|
ref_key: "textClampRef",
|
|
119
119
|
ref: a,
|
|
120
120
|
class: "text-clamp",
|
|
121
|
-
style:
|
|
121
|
+
style: I({
|
|
122
122
|
overflow: "hidden",
|
|
123
|
-
maxHeight:
|
|
123
|
+
maxHeight: j.value
|
|
124
124
|
})
|
|
125
125
|
}, [
|
|
126
126
|
w("span", {
|
|
@@ -139,7 +139,7 @@ const W = ["title", "aria-label"], X = M({
|
|
|
139
139
|
ref: x,
|
|
140
140
|
title: t.text,
|
|
141
141
|
"aria-label": t.text
|
|
142
|
-
}, null, 8,
|
|
142
|
+
}, null, 8, Q),
|
|
143
143
|
B(t.$slots, "after", {
|
|
144
144
|
expand: L,
|
|
145
145
|
collapse: b,
|
|
@@ -152,5 +152,5 @@ const W = ["title", "aria-label"], X = M({
|
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
export {
|
|
155
|
-
|
|
155
|
+
p as default
|
|
156
156
|
};
|
package/es/package.json.d.ts
CHANGED
package/es/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),$=require("@vft/utils"),b=require("resize-detector/esm"),q=["title","aria-label"],O=l.defineComponent({name:"vft-clamp"}),U=l.defineComponent({...O,props:{text:{},maxHeight:{},maxLines:{default:1},expanded:{type:Boolean,default:!1},ellipsis:{default:"…"},autoResize:{type:Boolean,default:!1},location:{default:"end"}},emits:["clamp-change","update:expanded"],setup(e,{expose:w,emit:L}){const g=L,n=l.ref(null),f=l.ref(null),r=l.ref(null),a=l.reactive({offset:0,localExpanded:e.expanded,unregisterResizeCallback:null}),z=l.computed(()=>{if(!a.localExpanded&&e.maxHeight)return $.addUnit(e.maxHeight)}),v=()=>{r.value&&(r.value.textContent=j.value)},s=()=>{a.localExpanded||(v(),(d()||i.value)&&m())},E=()=>{e.text&&(a.offset=e.text.length,k(),e.autoResize&&n.value&&(b.addListener(n.value,s),a.unregisterResizeCallback=()=>{n.value&&b.removeListener(n.value,s)}),s())},k=()=>{var t;(t=a.unregisterResizeCallback)==null||t.call(a)},d=()=>!e.maxLines&&!e.maxHeight||!n.value?!1:e.maxLines&&x()>e.maxLines?!0:!!(e.maxHeight&&n.value.scrollHeight>n.value.offsetHeight),x=()=>f.value?Object.keys(Array.prototype.slice.call(f.value.getClientRects()).reduce((t,{top:c,bottom:u})=>{const o=`${c}/${u}`;return t[o]||(t[o]=!0),t},{})).length:0,m=(...t)=>{const[c=0,u=a.offset]=t;if(u-c<=3){T();return}const o=Math.floor((u+c)/2);h(o),d()?m(c,o):m(o,u)},h=t=>{a.offset=t,v()},T=()=>{M(),S()},M=()=>{for(;(!d()||x()<2)&&a.offset<e.text.length;)y(1)},S=()=>{for(;d()&&x()>1&&a.offset>0;)y(-1)},y=t=>{h(a.offset+t)},i=l.computed(()=>e.text?a.offset!==e.text.length:!1);l.watch(()=>i.value,t=>{l.nextTick(()=>{g("clamp-change",t)})},{immediate:!0});const j=l.computed(()=>i.value?B.value:e.text),B=l.computed(()=>{if(e.location==="start")return e.ellipsis+(e.text.slice(0,a.offset)||"").trim();if(e.location==="middle"){const t=Math.floor(a.offset/2);return(e.text.slice(0,t)||"").trim()+e.ellipsis+(e.text.slice(-t)||"").trim()}return(e.text.slice(0,a.offset)||"").trim()+e.ellipsis}),R=()=>{a.localExpanded=!0},C=()=>{a.localExpanded=!1},H=()=>{a.localExpanded=!a.localExpanded};return l.watch(()=>e.expanded,t=>{a.localExpanded=t}),l.watch(()=>a.localExpanded,t=>{t?h(e.text.length):s(),e.expanded!==t&&g("update:expanded",t)}),l.watch(()=>[e.maxLines,e.maxHeight,e.ellipsis,e.location,i.value].join(),()=>{l.nextTick(()=>{s()})}),l.watch(()=>[e.text,e.autoResize].join(),()=>{l.nextTick(()=>{E()})}),l.onUnmounted(()=>{k()}),l.onMounted(()=>{E()}),w({isClamped:i}),(t,c)=>(l.openBlock(),l.createElementBlock("div",{ref_key:"textClampRef",ref:n,class:"text-clamp",style:l.normalizeStyle({overflow:"hidden",maxHeight:z.value})},[l.createElementVNode("span",{ref_key:"contentRef",ref:f},[l.renderSlot(t.$slots,"before",{expand:R,collapse:C,toggle:H,clamped:i.value,expanded:a.localExpanded}),l.createElementVNode("span",{ref_key:"textRef",ref:r,title:t.text,"aria-label":t.text},null,8,q),l.renderSlot(t.$slots,"after",{expand:R,collapse:C,toggle:H,clamped:i.value,expanded:a.localExpanded})],512)],4))}});exports.default=U;
|
package/lib/package.json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.232";exports.version=e;
|
package/lib/package.json.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.232",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"resize-detector": "0.3.0",
|
|
56
56
|
"sortablejs": "1.15.0",
|
|
57
57
|
"@vft/router": "0.0.56",
|
|
58
|
-
"@vft/
|
|
59
|
-
"@vft/store": "0.0.37",
|
|
58
|
+
"@vft/store": "0.0.38",
|
|
60
59
|
"@vft/use": "0.0.51",
|
|
61
|
-
"@vft/
|
|
62
|
-
"@vft/
|
|
60
|
+
"@vft/directives": "0.0.29",
|
|
61
|
+
"@vft/utils": "0.0.112",
|
|
62
|
+
"@vft/constants": "0.0.66"
|
|
63
63
|
},
|
|
64
64
|
"vetur": {
|
|
65
65
|
"tags": "tags.json",
|