UNPKG

@tarojs/components

Version:

Taro 组件库

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