@artmate/chat
Version:
**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**
2 lines (1 loc) • 4.49 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./node_modules/@vueuse/shared/index.js"),l=require("vue"),E=s.isClient?window:void 0;function v(t){var r;const f=l.toValue(t);return(r=f==null?void 0:f.$el)!=null?r:f}function S(...t){const r=[],f=()=>{r.forEach(o=>o()),r.length=0},c=(o,u,a,h)=>(o.addEventListener(u,a,h),()=>o.removeEventListener(u,a,h)),b=l.computed(()=>{const o=s.toArray(l.toValue(t[0])).filter(u=>u!=null);return o.every(u=>typeof u!="string")?o:void 0}),g=s.watchImmediate(()=>{var o,u;return[(u=(o=b.value)==null?void 0:o.map(a=>v(a)))!=null?u:[E].filter(a=>a!=null),s.toArray(l.toValue(b.value?t[1]:t[0])),s.toArray(l.unref(b.value?t[2]:t[1])),l.toValue(b.value?t[3]:t[2])]},([o,u,a,h])=>{if(f(),!(o!=null&&o.length)||!(u!=null&&u.length)||!(a!=null&&a.length))return;const n=s.isObject(h)?{...h}:h;r.push(...o.flatMap(d=>u.flatMap(y=>a.map(O=>c(d,y,O,n)))))},{flush:"post"}),p=()=>{g(),f()};return s.tryOnScopeDispose(f),p}let R=!1;function P(t,r,f={}){const{window:c=E,ignore:b=[],capture:g=!0,detectIframe:p=!1,controls:o=!1}=f;if(!c)return o?{stop:s.noop,cancel:s.noop,trigger:s.noop}:s.noop;if(s.isIOS&&!R){R=!0;const e={passive:!0};Array.from(c.document.body.children).forEach(i=>S(i,"click",s.noop,e)),S(c.document.documentElement,"click",s.noop,e)}let u=!0;const a=e=>l.toValue(b).some(i=>{if(typeof i=="string")return Array.from(c.document.querySelectorAll(i)).some(m=>m===e.target||e.composedPath().includes(m));{const m=v(i);return m&&(e.target===m||e.composedPath().includes(m))}});function h(e){const i=l.toValue(e);return i&&i.$.subTree.shapeFlag===16}function n(e,i){const m=l.toValue(e),A=m.$.subTree&&m.$.subTree.children;return A==null||!Array.isArray(A)?!1:A.some(M=>M.el===i.target||i.composedPath().includes(M.el))}const d=e=>{const i=v(t);if(e.target!=null&&!(!(i instanceof Element)&&h(t)&&n(t,e))&&!(!i||i===e.target||e.composedPath().includes(i))){if("detail"in e&&e.detail===0&&(u=!a(e)),!u){u=!0;return}r(e)}};let y=!1;const O=[S(c,"click",e=>{y||(y=!0,setTimeout(()=>{y=!1},0),d(e))},{passive:!0,capture:g}),S(c,"pointerdown",e=>{const i=v(t);u=!a(e)&&!!(i&&!e.composedPath().includes(i))},{passive:!0}),p&&S(c,"blur",e=>{setTimeout(()=>{var i;const m=v(t);((i=c.document.activeElement)==null?void 0:i.tagName)==="IFRAME"&&!(m!=null&&m.contains(c.document.activeElement))&&r(e)},0)},{passive:!0})].filter(Boolean),w=()=>O.forEach(e=>e());return o?{stop:w,cancel:()=>{u=!1},trigger:e=>{u=!0,d(e),u=!1}}:w}function C(){const t=l.shallowRef(!1),r=l.getCurrentInstance();return r&&l.onMounted(()=>{t.value=!0},r),t}function x(t){const r=C();return l.computed(()=>(r.value,!!t()))}function I(t,r,f={}){const{window:c=E,...b}=f;let g;const p=x(()=>c&&"ResizeObserver"in c),o=()=>{g&&(g.disconnect(),g=void 0)},u=l.computed(()=>{const n=l.toValue(t);return Array.isArray(n)?n.map(d=>v(d)):[v(n)]}),a=l.watch(u,n=>{if(o(),p.value&&c){g=new ResizeObserver(r);for(const d of n)d&&g.observe(d,b)}},{immediate:!0,flush:"post"}),h=()=>{o(),a()};return s.tryOnScopeDispose(h),{isSupported:p,stop:h}}function T(t,r={width:0,height:0},f={}){const{window:c=E,box:b="content-box"}=f,g=l.computed(()=>{var n,d;return(d=(n=v(t))==null?void 0:n.namespaceURI)==null?void 0:d.includes("svg")}),p=l.shallowRef(r.width),o=l.shallowRef(r.height),{stop:u}=I(t,([n])=>{const d=b==="border-box"?n.borderBoxSize:b==="content-box"?n.contentBoxSize:n.devicePixelContentBoxSize;if(c&&g.value){const y=v(t);if(y){const O=y.getBoundingClientRect();p.value=O.width,o.value=O.height}}else if(d){const y=s.toArray(d);p.value=y.reduce((O,{inlineSize:w})=>O+w,0),o.value=y.reduce((O,{blockSize:w})=>O+w,0)}else p.value=n.contentRect.width,o.value=n.contentRect.height},f);s.tryOnMounted(()=>{const n=v(t);n&&(p.value="offsetWidth"in n?n.offsetWidth:r.width,o.value="offsetHeight"in n?n.offsetHeight:r.height)});const a=l.watch(()=>v(t),n=>{p.value=n?r.width:0,o.value=n?r.height:0});function h(){u(),a()}return{width:p,height:o,stop:h}}exports.getLifeCycleTarget=s.getLifeCycleTarget;exports.isClient=s.isClient;exports.isIOS=s.isIOS;exports.isObject=s.isObject;exports.noop=s.noop;exports.toArray=s.toArray;exports.tryOnMounted=s.tryOnMounted;exports.tryOnScopeDispose=s.tryOnScopeDispose;exports.watchImmediate=s.watchImmediate;exports.defaultWindow=E;exports.onClickOutside=P;exports.unrefElement=v;exports.useElementSize=T;exports.useEventListener=S;exports.useMounted=C;exports.useResizeObserver=I;exports.useSupported=x;