2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
import{S as t,i as e,a as r,b as i,u as o,s as n,f as l,n as s,h as a,d,o as u,t as c,g as h,j as p,v as f,l as m,q as v,m as b,p as g,w}from"./index-4348483d.js";import{px2rem as y,getTextWidth as x,getCanvasFont as $}from"../../../../../../../../../js/libraries/miscTools.js";function k(t,e,r){const i=t.slice();return i[26]=e[r],i[27]=e,i[28]=r,i}function z(t){let e,r,o,n,s,a,u=t[26]+"",p=t[28];const f=()=>t[14](e,p),g=()=>t[14](null,p);function w(){return t[15](t[28])}return{c(){e=l("button"),r=l("span"),o=c(u),n=h(),e.value=t[28]},m(t,l){i(t,e,l),m(e,r),m(r,o),m(e,n),f(),s||(a=v(e,"click",w),s=!0)},p(e,r){t=e,4&r&&u!==(u=t[26]+"")&&b(o,u),p!==t[28]&&(g(),p=t[28],f())},d(t){t&&d(e),g(),s=!1,a()}}}function L(t){let e,r,o,n,s,u,w,y,x,$,L,j=(null!=t[0]?t[0]:"")+"",M=t[2],T=[];for(let e=0;e<M.length;e+=1)T[e]=z(k(t,M,e));return{c(){e=l("button"),r=l("div"),o=l("span"),n=c(j),s=h(),u=l("img"),y=h(),x=l("div");for(let t=0;t<T.length;t+=1)T[t].c();a(o,"id","current-options-span"),a(r,"id","current-options-div"),a(u,"id","arrow-down"),p(u.src,w="../assets/arrow_down.svg")||a(u,"src","../assets/arrow_down.svg"),a(u,"alt","arrow down"),a(e,"id","current-option-button"),a(x,"id","options-holder"),f(x,"display","none")},m(l,a){i(l,e,a),m(e,r),m(r,o),m(o,n),t[12](o),m(e,s),m(e,u),t[13](e),i(l,y,a),i(l,x,a);for(let t=0;t<T.length;t+=1)T[t].m(x,null);t[16](x),$||(L=v(e,"click",t[9]),$=!0)},p(t,e){if(1&e&&j!==(j=(null!=t[0]?t[0]:"")+"")&&b(n,j),1062&e){let r;for(M=t[2],r=0;r<M.length;r+=1){const i=k(t,M,r);T[r]?T[r].p(i,e):(T[r]=z(i),T[r].c(),T[r].m(x,null))}for(;r<T.length;r+=1)T[r].d(1);T.length=M.length}},d(r){r&&d(e),t[12](null),t[13](null),r&&d(y),r&&d(x),g(T,r),t[16](null),$=!1,L()}}}function j(t){let e,r=t[8],o=L(t);return{c(){e=l("div"),o.c(),this.c=s,a(e,"class","select")},m(r,n){i(r,e,n),o.m(e,null),t[17](e)},p(t,[i]){256&i&&n(r,r=t[8])?(o.d(1),o=L(t),o.c(),o.m(e,null)):o.p(t,i)},i:s,o:s,d(r){r&&d(e),o.d(r),t[17](null)}}}function M(t,e,r){let i,o,n,l,{callback:s=null}=e,{options:a=[""]}=e,{value:d=null}=e,{valueindex:c=null}=e,h=arguments[0],p=[],f=0,m=null;function v(t,e){if(null!==t){if(e.includes(t)){let i=e.findIndex((e=>e==t));r(6,n.innerHTML=t,n),r(5,p[i].style.display="none",p),r(11,c=i)}r(8,f+=1)}}function b(t,e){null!=t&&null!=e&&e[t]!=d&&(r(0,d=e[t]),r(8,f+=1))}function g(){"none"==o.style.display?r(4,o.style.display="initial",o):r(4,o.style.display="none",o)}function k(t,e){r(11,c=t),r(0,d=a[t]),null!=e&&null!=e&&e(t)}function z(){r(4,o.style.display="none",o)}function L(t,e){let r;if(null!=t&&null!=e){let i=getComputedStyle(t).getPropertyValue("--width");if(isNaN(i)||""==i){if(null==m)return m=new ResizeObserver((()=>L(t,e))),void m.observe(l);i=getComputedStyle(l).getPropertyValue("width"),r=y(parseFloat(i.slice(0,i.length-2)))}else r=parseFloat(i.slice(0,i.length-2));let o=[];for(let t=0;t<e.children.length;t++){let r=e.children[t].children[0],i=x(r.innerHTML,$(r));o.push(i)}let n=y(Math.max(...o));if(n>r){let t=1.1*n+"rem";e.style.width=t;for(let r=0;r<e.children.length;r++){e.children[r].style.width=t}e.style.marginLeft=-(1.1*n-r)/2-.05+"rem"}else{let t=r+.1+"rem";for(let r=0;r<e.children.length;r++){e.children[r].style.width=t}}}}function j(t){w[t?"unshift":"push"]((()=>{n=t,r(6,n)}))}function M(t){w[t?"unshift":"push"]((()=>{l=t,r(7,l)}))}function T(t,e){w[t?"unshift":"push"]((()=>{p[e]=t,r(5,p)}))}u((()=>{h.addEventListener("focusout",z)}));const E=t=>k(t,s);function H(t){w[t?"unshift":"push"]((()=>{o=t,r(4,o)}))}function R(t){w[t?"unshift":"push"]((()=>{i=t,r(3,i)}))}return t.$$set=t=>{"callback"in t&&r(1,s=t.callback),"options"in t&&r(2,a=t.options),"value"in t&&r(0,d=t.value),"valueindex"in t&&r(11,c=t.valueindex)},t.$$.update=()=>{5&t.$$.dirty&&v(d,a),2052&t.$$.dirty&&b(c,a),24&t.$$.dirty&&L(i,o)},[d,s,a,i,o,p,n,l,f,g,k,c,j,M,T,E,H,R]}class T extends t{constructor(t){super(),this.shadowRoot.innerHTML="<style>@import '/css/common.css';#current-options-div{position:relative;overflow:hidden;width:calc(100% - 2.5rem);text-align:var(--text-align,left);padding-top:0.5rem}#arrow-down{right:0.5rem;width:1.365rem;position:absolute;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%)}.select{position:relative;margin-top:var(--margin-top,0);width:var(--width);max-width:var(--max-width);height:var(--height,2.75rem);border:var(--border,rgba(0,0,0,var(--opacity,1)) solid);border-width:var(--border-width, 0.063rem);border-radius:var(--border-radius,0.126rem)}.select button{width:var(--width);max-width:var(--max-width)}#current-option-button,#current-option-button *{opacity:var(--opacity,1);font-family:var(--font-family,var(--serif), serif);font-size:var(--font-size, 1.3rem)}.select>:first-child{margin-right:-2.75rem;padding-right:0.0rem}.select span{position:relative;padding-top:0.5rem;white-space:nowrap}#current-option-button{display:flex;width:100%;height:100%;padding-left:0.341rem;font-weight:var(--font-weight,400)}#options-holder{position:absolute;margin-top:calc(-1 * var(--border-width, 0.063rem));background:white;z-index:1;margin-left:-0.05rem;border-radius:var(--border-radius-options,0.126rem)}#options-holder *{font-size:var(--options-font-size, 1.2rem);font-family:var(--font-family,var(--serif), serif)}#options-holder button{display:flex;position:relative;width:var(--width);background:white;font-weight:400;text-align:var(--text-align,left);padding-top:0.341rem;padding-bottom:0.341rem;padding-right:3.515rem;padding-left:0.341rem}#options-holder button:hover{background:#cdcdcd}#options-holder button{border:black solid;border-width:0 var(--border-width-options,var(--border-width, 0.063rem)) 0 var(--border-width-options,var(--border-width, 0.063rem))}#options-holder>:first-child{border-top:black solid var(--border-width-options,var(--border-width, 0.063rem));border-top-left-radius:var(--border-radius-options,0.126rem);border-top-right-radius:var(--border-radius-options,0.126rem)}#options-holder>:last-child{border-bottom:black solid var(--border-width-options,var(--border-width, 0.063rem));border-bottom-left-radius:var(--border-radius-options,0.126rem);border-bottom-right-radius:var(--border-radius-options,0.126rem)}</style>",e(this,{target:this.shadowRoot,props:r(this.attributes),customElement:!0},M,j,n,{callback:1,options:2,value:0,valueindex:11},null),t&&(t.target&&i(t.target,this,t.anchor),t.props&&(this.$set(t.props),o()))}static get observedAttributes(){return["callback","options","value","valueindex"]}get callback(){return this.$$.ctx[1]}set callback(t){this.$$set({callback:t}),o()}get options(){return this.$$.ctx[2]}set options(t){this.$$set({options:t}),o()}get value(){return this.$$.ctx[0]}set value(t){this.$$set({value:t}),o()}get valueindex(){return this.$$.ctx[11]}set valueindex(t){this.$$set({valueindex:t}),o()}}customElements.define("select-component",T);export{T as default};
|