UNPKG

@tarojs/components

Version:

Taro 组件库。

1 lines • 11.7 kB
let e,t,l=!1,n=!1,o=!1,s=!1;const i="undefined"!=typeof window?window:{},c=i.document||{head:{}},r={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,l,n)=>e.addEventListener(t,l,n),rel:(e,t,l,n)=>e.removeEventListener(t,l,n),ce:(e,t)=>new CustomEvent(e,t)},f=e=>Promise.resolve(e),a=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),u=(e,t,l)=>{l&&l.map((([l,n,o])=>{const s=$(e,l),i=d(t,o),c=p(l);r.ael(s,n,i,c),(t.o=t.o||[]).push((()=>r.rel(s,n,i,c)))}))},d=(e,t)=>l=>{try{256&e.t?e.i[t](l):(e.u=e.u||[]).push([t,l])}catch(e){fe(e)}},$=(e,t)=>4&t?c:e,p=e=>0!=(2&e),y="http://www.w3.org/1999/xlink",h=new WeakMap,m=e=>"sc-"+e.$,b={},w=e=>"object"==(e=typeof e)||"function"===e,v=(e,t,...l)=>{let n=null,o=null,s=null,i=!1,c=!1,r=[];const f=t=>{for(let l=0;l<t.length;l++)n=t[l],Array.isArray(n)?f(n):null!=n&&"boolean"!=typeof n&&((i="function"!=typeof e&&!w(n))&&(n+=""),i&&c?r[r.length-1].p+=n:r.push(i?k(null,n):n),c=i)};if(f(l),t){t.key&&(o=t.key),t.name&&(s=t.name);{const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}}if("function"==typeof e)return e(null===t?{}:t,r,S);const a=k(e,null);return a.h=t,r.length>0&&(a.m=r),a.v=o,a.k=s,a},k=(e,t)=>({t:0,g:e,p:t,S:null,m:null,h:null,v:null,k:null}),g={},S={forEach:(e,t)=>e.map(j).forEach(t),map:(e,t)=>e.map(j).map(t).map(M)},j=e=>({vattrs:e.h,vchildren:e.m,vkey:e.v,vname:e.k,vtag:e.g,vtext:e.p}),M=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),v(e.vtag,t,...e.vchildren||[])}const t=k(e.vtag,e.vtext);return t.h=e.vattrs,t.m=e.vchildren,t.v=e.vkey,t.k=e.vname,t},O=(e,t,l,n,o,s)=>{if(l!==n){let c=re(e,t),f=t.toLowerCase();if("class"===t){const t=e.classList,o=x(l),s=x(n);t.remove(...o.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!o.includes(e))))}else if("style"===t){for(const t in l)n&&null!=n[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in n)l&&n[t]===l[t]||(t.includes("-")?e.style.setProperty(t,n[t]):e.style[t]=n[t])}else if("key"===t);else if("ref"===t)n&&n(e);else if(c||"o"!==t[0]||"n"!==t[1]){const i=w(n);if((c||i&&null!==n)&&!o)try{if(e.tagName.includes("-"))e[t]=n;else{let o=null==n?"":n;"list"===t?c=!1:null!=l&&e[t]==o||(e[t]=o)}}catch(e){}let r=!1;f!==(f=f.replace(/^xlink\:?/,""))&&(t=f,r=!0),null==n||!1===n?!1===n&&""!==e.getAttribute(t)||(r?e.removeAttributeNS(y,t):e.removeAttribute(t)):(!c||4&s||o)&&!i&&(n=!0===n?"":n,r?e.setAttributeNS(y,t,n):e.setAttribute(t,n))}else t="-"===t[2]?t.slice(3):re(i,f)?f.slice(2):f[2]+t.slice(3),l&&r.rel(e,t,l,!1),n&&r.ael(e,t,n,!1)}},C=/\s/,x=e=>e?e.split(C):[],R=(e,t,l,n)=>{const o=11===t.S.nodeType&&t.S.host?t.S.host:t.S,s=e&&e.h||b,i=t.h||b;for(n in s)n in i||O(o,n,s[n],void 0,l,t.t);for(n in i)O(o,n,s[n],i[n],l,t.t)},P=(n,s,i)=>{let r,f,a,u=s.m[i],d=0;if(l||(o=!0,"slot"===u.g&&(u.t|=u.m?2:1)),null!==u.p)r=u.S=c.createTextNode(u.p);else if(1&u.t)r=u.S=c.createTextNode("");else if(r=u.S=c.createElement(2&u.t?"slot-fb":u.g),R(null,u,!1),u.m)for(d=0;d<u.m.length;++d)f=P(n,u,d),f&&r.appendChild(f);return r["s-hn"]=t,3&u.t&&(r["s-sr"]=!0,r["s-cr"]=e,r["s-sn"]=u.k||"",a=n&&n.m&&n.m[i],a&&a.g===u.g&&n.S&&T(n.S,!1)),r},T=(e,l)=>{r.t|=1;const n=e.childNodes;for(let e=n.length-1;e>=0;e--){const s=n[e];s["s-hn"]!==t&&s["s-ol"]&&(D(s).insertBefore(s,W(s)),s["s-ol"].remove(),s["s-ol"]=void 0,o=!0),l&&T(s,l)}r.t&=-2},E=(e,t,l,n,o,s)=>{let i,c=e["s-cr"]&&e["s-cr"].parentNode||e;for(;o<=s;++o)n[o]&&(i=P(null,l,o),i&&(n[o].S=i,c.insertBefore(i,W(t))))},L=(e,t,l,o,s)=>{for(;t<=l;++t)(o=e[t])&&(s=o.S,V(o),n=!0,s["s-ol"]?s["s-ol"].remove():T(s,!0),s.remove())},U=(e,t)=>e.g===t.g&&("slot"===e.g?e.k===t.k:e.v===t.v),W=e=>e&&e["s-ol"]||e,D=e=>(e["s-ol"]?e["s-ol"]:e).parentNode,A=(e,t)=>{const l=t.S=e.S,n=e.m,o=t.m,s=t.p;let i;null===s?("slot"===t.g||R(e,t,!1),null!==n&&null!==o?((e,t,l,n)=>{let o,s,i=0,c=0,r=0,f=0,a=t.length-1,u=t[0],d=t[a],$=n.length-1,p=n[0],y=n[$];for(;i<=a&&c<=$;)if(null==u)u=t[++i];else if(null==d)d=t[--a];else if(null==p)p=n[++c];else if(null==y)y=n[--$];else if(U(u,p))A(u,p),u=t[++i],p=n[++c];else if(U(d,y))A(d,y),d=t[--a],y=n[--$];else if(U(u,y))"slot"!==u.g&&"slot"!==y.g||T(u.S.parentNode,!1),A(u,y),e.insertBefore(u.S,d.S.nextSibling),u=t[++i],y=n[--$];else if(U(d,p))"slot"!==u.g&&"slot"!==y.g||T(d.S.parentNode,!1),A(d,p),e.insertBefore(d.S,u.S),d=t[--a],p=n[++c];else{for(r=-1,f=i;f<=a;++f)if(t[f]&&null!==t[f].v&&t[f].v===p.v){r=f;break}r>=0?(s=t[r],s.g!==p.g?o=P(t&&t[c],l,r):(A(s,p),t[r]=void 0,o=s.S),p=n[++c]):(o=P(t&&t[c],l,c),p=n[++c]),o&&D(u.S).insertBefore(o,W(u.S))}i>a?E(e,null==n[$+1]?null:n[$+1].S,l,n,c,$):c>$&&L(t,i,a)})(l,n,t,o):null!==o?(null!==e.p&&(l.textContent=""),E(l,null,t,o,0,o.length-1)):null!==n&&L(n,0,n.length-1)):(i=l["s-cr"])?i.parentNode.textContent=s:e.p!==s&&(l.data=s)},F=e=>{let t,l,n,o,s,i,c=e.childNodes;for(l=0,n=c.length;l<n;l++)if(t=c[l],1===t.nodeType){if(t["s-sr"])for(s=t["s-sn"],t.hidden=!1,o=0;o<n;o++)if(i=c[o].nodeType,c[o]["s-hn"]!==t["s-hn"]||""!==s){if(1===i&&s===c[o].getAttribute("slot")){t.hidden=!0;break}}else if(1===i||3===i&&""!==c[o].textContent.trim()){t.hidden=!0;break}F(t)}},H=[],N=e=>{let t,l,o,s,i,c,r=0,f=e.childNodes,a=f.length;for(;r<a;r++){if(t=f[r],t["s-sr"]&&(l=t["s-cr"])&&l.parentNode)for(o=l.parentNode.childNodes,s=t["s-sn"],c=o.length-1;c>=0;c--)l=o[c],l["s-cn"]||l["s-nr"]||l["s-hn"]===t["s-hn"]||(q(l,s)?(i=H.find((e=>e.j===l)),n=!0,l["s-sn"]=l["s-sn"]||s,i?i.M=t:H.push({M:t,j:l}),l["s-sr"]&&H.map((e=>{q(e.j,l["s-sn"])&&(i=H.find((e=>e.j===l)),i&&!e.M&&(e.M=i.M))}))):H.some((e=>e.j===l))||H.push({j:l}));1===t.nodeType&&N(t)}},q=(e,t)=>1===e.nodeType?null===e.getAttribute("slot")&&""===t||e.getAttribute("slot")===t:e["s-sn"]===t||""===t,V=e=>{e.h&&e.h.ref&&e.h.ref(null),e.m&&e.m.map(V)},_=e=>se(e).O,z=(e,t,l)=>{const n=_(e);return{emit:e=>B(n,t,{bubbles:!!(4&l),composed:!!(2&l),cancelable:!!(1&l),detail:e})}},B=(e,t,l)=>{const n=r.ce(t,l);return e.dispatchEvent(n),n},G=(e,t)=>{t&&!e.C&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.C=t)))},I=(e,t)=>{if(e.t|=16,!(4&e.t))return G(e,e.R),we((()=>J(e,t)));e.t|=512},J=(e,t)=>{const l=e.i;let n;return t?(e.t|=256,e.u&&(e.u.map((([e,t])=>Z(l,e,t))),e.u=null),n=Z(l,"componentWillLoad")):n=Z(l,"componentWillUpdate"),ee(n,(()=>K(e,l,t)))},K=async(e,t,l)=>{const n=e.O,o=n["s-rc"];l&&(e=>{const t=e.P;((e,t)=>{let l=m(t),n=de.get(l);if(e=11===e.nodeType?e:c,n)if("string"==typeof n){let t,o=h.get(e=e.head||e);o||h.set(e,o=new Set),o.has(l)||(t=c.createElement("style"),t.innerHTML=n,e.insertBefore(t,e.querySelector("link")),o&&o.add(l))}else e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n])})(e.O.getRootNode(),t)})(e);Q(e,t),o&&(o.map((e=>e())),n["s-rc"]=void 0);{const t=n["s-p"],l=()=>X(e);0===t.length?l():(Promise.all(t).then(l),e.t|=4,t.length=0)}},Q=(s,i)=>{try{i=i.render(),s.t&=-17,s.t|=2,((s,i)=>{const f=s.O,a=s.P,u=s.T||k(null,null),d=(e=>e&&e.g===g)(i)?i:v(null,null,i);if(t=f.tagName,d.g=null,d.t|=4,s.T=d,d.S=u.S=f,e=f["s-cr"],l=0!=(1&a.t),n=!1,A(u,d),r.t|=1,o){let e,t,l,n,o,s;N(d.S);let i=0;for(;i<H.length;i++)e=H[i],t=e.j,t["s-ol"]||(l=c.createTextNode(""),l["s-nr"]=t,t.parentNode.insertBefore(t["s-ol"]=l,t));for(i=0;i<H.length;i++)if(e=H[i],t=e.j,e.M){for(n=e.M.parentNode,o=e.M.nextSibling,l=t["s-ol"];l=l.previousSibling;)if(s=l["s-nr"],s&&s["s-sn"]===t["s-sn"]&&n===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){o=s;break}(!o&&n!==t.parentNode||t.nextSibling!==o)&&t!==o&&(!t["s-hn"]&&t["s-ol"]&&(t["s-hn"]=t["s-ol"].parentNode.nodeName),n.insertBefore(t,o))}else 1===t.nodeType&&(t.hidden=!0)}n&&F(d.S),r.t&=-2,H.length=0})(s,i)}catch(e){fe(e,s.O)}return null},X=e=>{const t=e.O,l=e.i,n=e.R;Z(l,"componentDidRender"),64&e.t?Z(l,"componentDidUpdate"):(e.t|=64,te(t),Z(l,"componentDidLoad"),e.L(t),n||Y()),e.U(t),e.C&&(e.C(),e.C=void 0),512&e.t&&be((()=>I(e,!1))),e.t&=-517},Y=()=>{te(c.documentElement),be((()=>B(i,"appload",{detail:{namespace:"taro-components"}})))},Z=(e,t,l)=>{if(e&&e[t])try{return e[t](l)}catch(e){fe(e)}},ee=(e,t)=>e&&e.then?e.then(t):t(),te=e=>e.classList.add("hydrated"),le=(e,t,l)=>{if(t.W){e.watchers&&(t.D=e.watchers);const n=Object.entries(t.W),o=e.prototype;if(n.map((([e,[n]])=>{31&n||2&l&&32&n?Object.defineProperty(o,e,{get(){return((e,t)=>se(this).A.get(t))(0,e)},set(l){((e,t,l,n)=>{const o=se(e),s=o.O,i=o.A.get(t),c=o.t,r=o.i;if(l=((e,t)=>null==e||w(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(l,n.W[t][0]),!(8&c&&void 0!==i||l===i)&&(o.A.set(t,l),r)){if(n.D&&128&c){const e=n.D[t];e&&e.map((e=>{try{r[e](l,i,t)}catch(e){fe(e,s)}}))}2==(18&c)&&I(o,!1)}})(this,e,l,t)},configurable:!0,enumerable:!0}):1&l&&64&n&&Object.defineProperty(o,e,{value(...t){const l=se(this);return l.F.then((()=>l.i[e](...t)))}})})),1&l){const t=new Map;o.attributeChangedCallback=function(e,l,n){r.jmp((()=>{const l=t.get(e);this.hasOwnProperty(l)&&(n=this[l],delete this[l]),this[l]=(null!==n||"boolean"!=typeof this[l])&&n}))},e.observedAttributes=n.filter((([e,t])=>15&t[0])).map((([e,l])=>{const n=l[1]||e;return t.set(n,e),n}))}}return e},ne=(e,t={})=>{const l=[],n=t.exclude||[],o=i.customElements,s=c.head,f=s.querySelector("meta[charset]"),d=c.createElement("style"),$=[];let p,y=!0;Object.assign(r,t),r.l=new URL(t.resourcesUrl||"./",c.baseURI).href,e.map((e=>e[1].map((t=>{const s={t:t[0],$:t[1],W:t[2],H:t[3]};s.W=t[2],s.H=t[3],s.D={};const i=s.$,f=class extends HTMLElement{constructor(e){super(e),ce(e=this,s)}connectedCallback(){p&&(clearTimeout(p),p=null),y?$.push(this):r.jmp((()=>(e=>{if(0==(1&r.t)){const t=se(e),l=t.P,n=()=>{};if(1&t.t)u(e,t,l.H);else{t.t|=1,12&l.t&&(e=>{const t=e["s-cr"]=c.createComment("");t["s-cn"]=!0,e.insertBefore(t,e.firstChild)})(e);{let l=e;for(;l=l.parentNode||l.host;)if(l["s-p"]){G(t,t.R=l);break}}l.W&&Object.entries(l.W).map((([t,[l]])=>{if(31&l&&e.hasOwnProperty(t)){const l=e[t];delete e[t],e[t]=l}})),(async(e,t,l,n,o)=>{if(0==(32&t.t)){{if(t.t|=32,(o=ue(l)).then){const e=()=>{};o=await o,e()}o.isProxied||(l.D=o.watchers,le(o,l,2),o.isProxied=!0);const e=()=>{};t.t|=8;try{new o(t)}catch(e){fe(e)}t.t&=-9,t.t|=128,e()}if(o.style){let e=o.style;const t=m(l);if(!de.has(t)){const n=()=>{};((e,t,l)=>{let n=de.get(e);a&&l?(n=n||new CSSStyleSheet,n.replace(t)):n=t,de.set(e,n)})(t,e,!!(1&l.t)),n()}}}const s=t.R,i=()=>I(t,!0);s&&s["s-rc"]?s["s-rc"].push(i):i()})(0,t,l)}n()}})(this)))}disconnectedCallback(){r.jmp((()=>(()=>{if(0==(1&r.t)){const e=se(this),t=e.i;e.o&&(e.o.map((e=>e())),e.o=void 0),Z(t,"disconnectedCallback")}})()))}componentOnReady(){return se(this).N}};s.q=e[0],n.includes(i)||o.get(i)||(l.push(i),o.define(i,le(f,s,1)))})))),d.innerHTML=l+"{visibility:hidden}.hydrated{visibility:inherit}",d.setAttribute("data-styles",""),s.insertBefore(d,f?f.nextSibling:s.firstChild),y=!1,$.length?$.map((e=>e.connectedCallback())):r.jmp((()=>p=setTimeout(Y,30)))},oe=new WeakMap,se=e=>oe.get(e),ie=(e,t)=>oe.set(t.i=e,t),ce=(e,t)=>{const l={t:0,O:e,P:t,A:new Map};return l.F=new Promise((e=>l.U=e)),l.N=new Promise((e=>l.L=e)),e["s-p"]=[],e["s-rc"]=[],u(e,l,t.H),oe.set(e,l)},re=(e,t)=>t in e,fe=(e,t)=>(0,console.error)(e,t),ae=new Map,ue=e=>{const t=e.$.replace(/-/g,"_"),l=e.q,n=ae.get(l);return n?n[t]:import(`./${l}.entry.js`).then((e=>(ae.set(l,e),e[t])),fe)},de=new Map,$e=[],pe=[],ye=(e,t)=>l=>{e.push(l),s||(s=!0,t&&4&r.t?be(me):r.raf(me))},he=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){fe(e)}e.length=0},me=()=>{he($e),he(pe),(s=$e.length>0)&&r.raf(me)},be=e=>f().then(e),we=ye(pe,!0);export{g as H,ne as b,z as c,_ as g,v as h,f as p,ie as r}