2 lines
3.9 KiB
JavaScript
2 lines
3.9 KiB
JavaScript
import{bk as S,b6 as I,ae as _,k as x,r as h,K as P,bl as L,dr as $,bz as D,a0 as R,o as z,ac as M,dj as Y,H as k,bf as H,d as B,C as p,ds as V}from"./CwKn53hw.js";import{m as w,t as W,b as v,c as y,h as m,d as C,k as j,w as A}from"./Ds1fDJiL.js";var E=typeof window<"u";function de(e){const n=S(e,null);if(n){const t=I(),{link:o,unlink:i,internalChildren:c}=n;o(t),_(()=>i(t));const d=x(()=>c.indexOf(t));return{parent:n,index:d}}return{parent:null,index:h(-1)}}function F(e){const n=[],t=o=>{Array.isArray(o)&&o.forEach(i=>{var c;H(i)&&(n.push(i),(c=i.component)!=null&&c.subTree&&(n.push(i.component.subTree),t(i.component.subTree.children)),i.children&&t(i.children))})};return t(e),n}var O=(e,n)=>{const t=e.indexOf(n);return t===-1?e.findIndex(o=>n.key!==void 0&&n.key!==null&&o.type===n.type&&o.key===n.key):t};function K(e,n,t){const o=F(e.subTree.children);t.sort((c,d)=>O(o,c.vnode)-O(o,d.vnode));const i=t.map(c=>c.proxy);n.sort((c,d)=>{const r=i.indexOf(c),s=i.indexOf(d);return r-s})}function ue(e){const n=P([]),t=P([]),o=I();return{children:n,linkChildren:c=>{L(e,Object.assign({link:s=>{s.proxy&&(t.push(s),n.push(s.proxy),K(o,n,t))},unlink:s=>{const a=t.indexOf(s);n.splice(a,1),t.splice(a,1)},children:n,internalChildren:t},c))}}}function U(e){let n;z(()=>{e(),M(()=>{n=!0})}),Y(()=>{n&&e()})}function le(e,n,t={}){if(!E)return;const{target:o=window,passive:i=!1,capture:c=!1}=t;let d=!1,r;const s=u=>{if(d)return;const l=k(u);l&&!r&&(l.addEventListener(e,n,{capture:c,passive:i}),r=!0)},a=u=>{if(d)return;const l=k(u);l&&r&&(l.removeEventListener(e,n,c),r=!1)};_(()=>a(o)),$(()=>a(o)),U(()=>s(o));let f;return D(o)&&(f=R(o,(u,l)=>{a(l),s(u)})),()=>{f==null||f(),a(o),d=!0}}var g,b;function fe(){if(!g&&(g=h(0),b=h(0),E)){const e=()=>{g.value=window.innerWidth,b.value=window.innerHeight};e(),window.addEventListener("resize",e,{passive:!0}),window.addEventListener("orientationchange",e,{passive:!0})}return{width:g,height:b}}var Z=/scroll|auto|overlay/i,G=E?window:void 0;function X(e){return e.tagName!=="HTML"&&e.tagName!=="BODY"&&e.nodeType===1}function me(e,n=G){let t=e;for(;t&&t!==n&&X(t);){const{overflowY:o}=window.getComputedStyle(t);if(Z.test(o))return t;t=t.parentNode}return n}const ge="van-hairline",pe="van-haptics-feedback",ve=5,[q,T]=y("badge"),J={dot:Boolean,max:v,tag:w("div"),color:String,offset:Array,content:v,showZero:W,position:w("top-right")};var Q=B({name:q,props:J,setup(e,{slots:n}){const t=()=>{if(n.content)return!0;const{content:r,showZero:s}=e;return C(r)&&r!==""&&(s||r!==0&&r!=="0")},o=()=>{const{dot:r,max:s,content:a}=e;if(!r&&t())return n.content?n.content():C(s)&&j(a)&&+a>+s?`${s}+`:a},i=r=>r.startsWith("-")?r.replace("-",""):`-${r}`,c=x(()=>{const r={background:e.color};if(e.offset){const[s,a]=e.offset,{position:f}=e,[u,l]=f.split("-");n.default?(typeof a=="number"?r[u]=m(u==="top"?a:-a):r[u]=u==="top"?m(a):i(a),typeof s=="number"?r[l]=m(l==="left"?s:-s):r[l]=l==="left"?m(s):i(s)):(r.marginTop=m(a),r.marginLeft=m(s))}return r}),d=()=>{if(t()||e.dot)return p("div",{class:T([e.position,{dot:e.dot,fixed:!!n.default}]),style:c.value},[o()])};return()=>{if(n.default){const{tag:r}=e;return p(r,{class:T("wrapper")},{default:()=>[n.default(),d()]})}return d()}}});const ee=A(Q),[ne,be]=y("config-provider"),te=Symbol(ne),[re,N]=y("icon"),oe=e=>e==null?void 0:e.includes("/"),se={dot:Boolean,tag:w("i"),name:String,size:v,badge:v,color:String,badgeProps:Object,classPrefix:String};var ie=B({name:re,props:se,setup(e,{slots:n}){const t=S(te,null),o=x(()=>e.classPrefix||(t==null?void 0:t.iconPrefix)||N());return()=>{const{tag:i,dot:c,name:d,size:r,badge:s,color:a}=e,f=oe(d);return p(ee,V({dot:c,tag:i,class:[o.value,f?"":`${o.value}-${d}`],style:{color:a,fontSize:m(r)},content:s},e.badgeProps),{default:()=>{var u;return[(u=n.default)==null?void 0:u.call(n),f&&p("img",{class:N("image"),src:d},null)]}})}}});const he=A(ie);export{ge as B,pe as H,he as I,ve as T,le as a,ue as b,de as c,me as g,U as o,fe as u};
|