vft 0.0.233 → 0.0.234
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,6 +1,6 @@
|
|
|
1
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
2
|
import { addUnit as J } from "@vft/utils";
|
|
3
|
-
import { addListener as K, removeListener as P } from "resize-detector
|
|
3
|
+
import { addListener as K, removeListener as P } from "resize-detector";
|
|
4
4
|
const Q = ["title", "aria-label"], W = M({
|
|
5
5
|
name: "vft-clamp"
|
|
6
6
|
}), p = /* @__PURE__ */ M({
|
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"),$=require("@vft/utils"),b=require("resize-detector
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),$=require("@vft/utils"),b=require("resize-detector"),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:z}){const g=z,n=l.ref(null),f=l.ref(null),r=l.ref(null),a=l.reactive({offset:0,localExpanded:e.expanded,unregisterResizeCallback:null}),L=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:L.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.234";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.234",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"qrcode": "1.5.3",
|
|
55
55
|
"resize-detector": "0.3.0",
|
|
56
56
|
"sortablejs": "1.15.0",
|
|
57
|
-
"@vft/store": "0.0.39",
|
|
58
57
|
"@vft/router": "0.0.56",
|
|
59
|
-
"@vft/utils": "0.0.113",
|
|
60
|
-
"@vft/directives": "0.0.29",
|
|
61
58
|
"@vft/use": "0.0.53",
|
|
62
|
-
"@vft/
|
|
59
|
+
"@vft/store": "0.0.39",
|
|
60
|
+
"@vft/utils": "0.0.113",
|
|
61
|
+
"@vft/constants": "0.0.69",
|
|
62
|
+
"@vft/directives": "0.0.29"
|
|
63
63
|
},
|
|
64
64
|
"vetur": {
|
|
65
65
|
"tags": "tags.json",
|
package/web-types.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"http://json.schemastore.org/web-types","framework":"vue","name":"vft","version":"0.0.
|
|
1
|
+
{"$schema":"http://json.schemastore.org/web-types","framework":"vue","name":"vft","version":"0.0.234","js-types-syntax":"typescript","description-markup":"markdown","contributions":{"html":{}}}
|