PageSourceSearch

https://faector.nl/apps/framework/build/web-component/g2ui-input-checklist-BLA9WzPQ.js

js faector.nl collected 2026-10-03 21:39:12 UTC 10,832 bytes, 5 lines download raw bytes

1import{p as B,F as j}from"../base-Ci7vLHE_.js";import{p as H}from"../internals--3vI9LC5.js";import"../preload-helper-BVLnHgTN.js";var O=Object.defineProperty,I=i=>{throw TypeError(i)},F=(i,t,e)=>t in i?O(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,$=(i,t,e)=>F(i,typeof t!="symbol"?t+"":t,e),T=(i,t,e)=>t.has(i)||I("Cannot "+e),s=(i,t,e)=>(T(i,t,"read from private field"),e?e.call(i):t.get(i)),u=(i,t,e)=>t.has(i)?I("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),c=(i,t,e,o)=>(T(i,t,"write to private field"),t.set(i,e),e),h=(i,t,e)=>(T(i,t,"access private method"),e);let _=Object.hasOwn(HTMLElement.prototype,"popover");const U=`<svg viewBox="0 0 14 14" tabindex="0">
2  <path d="M3 8L6 11L11 3.5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
3</svg>`,Y=`<svg viewBox="0 0 14 14" tabindex="0">
4  <circle cx="7" cy="7" r="2.5"/>
5</svg>`;var f,m,C,R,D;class z{constructor(t,e){u(this,R),u(this,f),u(this,m),u(this,C),c(this,f,t),c(this,C,e),c(this,m,new Set)}get length(){return s(this,m).size}get selectedIndex(){const t=[...s(this,m).values()];for(const e in t)if(t[e].checked)return parseInt(e);return-1}set selectedIndex(t){if(t<0){s(this,f).values=[];return}const e=[...s(this,m).values()];for(const o in e)if(parseInt(o)===t){s(this,f).values=[e[o].value];return}s(this,f).values=[]}add(t,e=null){var o;if(t.tagName!=="LABEL")throw new DOMException("Expecting a LABEL with an INPUT child");const n=t.querySelector(":scope > input");if(!n)throw new DOMException("Expecting an INPUT as direct child of LABEL");n.addEventListener("change",s(this,C)),n.type==="checkbox"&&n.insertAdjacentHTML("afterend",U),n.type==="radio"&&n.insertAdjacentHTML("afterend",Y),s(this,m).add(n),((o=t.parentNode)==null?void 0:o.tagName)==="FIELDSET"?h(this,R,D).call(this).insertBefore(t.parentNode,e):h(this,R,D).call(this).insertBefore(t,e)}remove(t){if(s(this,m).delete(t)){for(const e of t.labels)e.remove();t.remove()}}replaceWithSerialized(t){for(const e of s(this,m))this.remove(e);for(const e of t){const o=s(this,f).ownerDocument.createElement("label"),n=s(this,f).ownerDocument.createElement("input");n.type=e.type||"checkbox",n.name=e.name,n.value=e.value,n.checked=e.checked,n.disabled=e.disabled,o.append(n,e.label),this.add(o)}s(this,C)()}serialize(){var t;const e=[];for(const o of s(this,m))e.push({type:o.type,name:o.name,value:o.value,checked:o.checked,label:(((t=o.labels.item(0))==null?void 0:t.textContent)||"").trim()});return e}[Symbol.iterator](){return s(this,m).values()}}f=new WeakMap,m=new WeakMap,C=new WeakMap,R=new WeakSet,D=function(){return s(this,f).shadowRoot.querySelector(".values")};var y,q,L,E,p,r,v,l,M,x,A,S;const W=class N extends B{constructor(){super(),u(this,l),u(this,y),u(this,q,!1),u(this,L),u(this,E),u(this,p),u(this,r,_),u(this,v,!1),c(this,L,j().newTranslator()),c(this,y,HTMLElement.prototype.attachInternals?this.attachInternals():new H(this)),c(this,p,new z(this,()=>h(this,l,S).call(this)));const t=this.ownerDocument.createElement("div");t.classList.add("wrapper"),this.addEventListener("click",g=>{if(g.stopImmediatePropagation(),s(this,r))s(this,v)||this.togglePicker();else{if(s(this,v)){c(this,v,!1);return}this.togglePicker(),c(this,v,g.composedPath().filter(V=>V.tagName==="LABEL").length>0)}}),this.shadowRoot.appendChild(t);const e=this.ownerDocument.createElement("div");e.classList.add("select"),t.appendChild(e);const o=this.ownerDocument.createElement("div"),n=this.ownerDocument.createElement("span");n.classList.add("selected-option"),o.classList.add("open"),o.appendChild(n),e.appendChild(o);const d=this.ownerDocument.createElement("div");d.classList.add("picker"),d.addEventListener("click",g=>g.stopPropagation()),t.appendChild(d);const w=this.ownerDocument.createElement("div");w.classList.add("helpers"),d.appendChild(w);const a=this.ownerDocument.createElement("div");a.classList.add("values"),d.appendChild(a);const k=this.ownerDocument.createElement("button");k.textContent=s(this,L).lookup("select_all"),k.type="button",k.classList.add("all"),k.addEventListener("click",()=>{for(const g of s(this,p))g.checked=!0;h(this,l,S).call(this)}),w.appendChild(k);const b=this.ownerDocument.createElement("button");b.textContent=s(this,L).lookup("select_none"),b.type="button",b.classList.add("none"),b.addEventListener("click",()=>{for(const g of s(this,p))g.checked=!1;h(this,l,S).call(this)}),w.appendChild(b);const P=this.ownerDocument.createElement("button");P.textContent="▼",P.type="button",P.classList.add("open"),o.appendChild(P)}connectedCallback(){var t;this.hasAttribute("required")&&c(this,q,this.getAttribute("required")),c(this,r,s(this,r)&&!this.closest("dialog"));const e=this.shadowRoot.querySelector(".wrapper");if(e.classList.toggle("popover",s(this,r)),e.classList.toggle("no-popover",!s(this,r)),!s(this,r)){const a=this.ownerDocument.createElement("div");for(a.classList.add("non-popover-wrapper");e.firstChild;)a.appendChild(e.firstChild);e.appendChild(a)}const o=this.shadowRoot.querySelector(".picker");s(this,r)?(o.popover="auto",o.addEventListener("beforetoggle",a=>{h(this,l,x).call(this,a.newState),c(this,v,!0),h(this,l,A).call(this)}),o.addEventListener("toggle",a=>{c(this,v,!1)})):o.hidden=!0;const n=this.shadowRoot.querySelector("button");s(this,r)?(n.popoverTargetElement=o,n.popoverTargetAction="toggle",n.addEventListener("click",a=>{a.stopPropagation()})):n.addEventListener("click",a=>{a.stopPropagation(),this.togglePicker()});for(const a of this.querySelectorAll("template")){const k=a.content.cloneNode(!0).querySelectorAll("label");for(const b of k)s(this,p).add(b)}h(this,l,S).call(this,{initial:!0}),c(this,E,this.closest("form")),(t=s(this,E))==null||t.addEventListener("submit",()=>this.hidePicker()),c(this,v,!1),this.shadowRoot.querySelector(".helpers").classList.toggle("is-enabled",s(this,p).length>5);const d=window.getComputedStyle(this).accentColor;
5d!=="auto"&&d!==""&&(e.style.setProperty("--_g2ui-input-checklist-accent-color",d),e.classList.add("computed-accent"));const w=window.getComputedStyle(this).paddingLeft;parseFloat(w)!==0&&e.style.setProperty("--_g2ui-input-checklist-space",w),h(this,l,M).call(this)}disconnectedCallback(){c(this,E,null)}checkValidity(){return s(this,y).checkValidity()}reportValidity(){return s(this,y).reportValidity()}setValidity(t,e=""){s(this,y).setValidity(t,e)}get form(){return s(this,E)}set values(t){for(const e of s(this,p))e.checked=!!t.includes(e.value);h(this,l,S).call(this)}get values(){const t=[];for(const e of s(this,p))e.checked&&t.push(e.value);return t}get options(){return s(this,p)}get open(){return s(this,r)?this.shadowRoot.querySelector(".picker").matches(":popover-open"):this.shadowRoot.querySelector(".wrapper").classList.contains("is-active")}showPicker(){if(this.open)return;const t=this.shadowRoot.querySelector(".picker");s(this,r)?t.showPopover():h(this,l,x).call(this,"open"),this.shadowRoot.querySelector("button").focus()}hidePicker(){this.open&&(s(this,r)?this.shadowRoot.querySelector(".picker").hidePopover():h(this,l,x).call(this,"closed"))}togglePicker(t=null){(t===null?!this.open:t)?this.showPicker():this.hidePicker()}async handleEvent(t){if(t.type==="keydown"){if(t.key==="ArrowDown"||t.key==="ArrowUp")t.preventDefault();else return;let e;const o=this.shadowRoot.querySelector(".values label:focus-within");t.key==="ArrowDown"?e=(o==null?void 0:o.nextElementSibling)||this.shadowRoot.querySelector(".values label"):e=(o==null?void 0:o.previousElementSibling)||this.shadowRoot.querySelector(".values label:last-child"),e.focus()}t.type==="focusout"&&requestAnimationFrame(()=>{this.matches(":focus-within")||h(this,l,x).call(this,"closed")})}static register(){customElements.get("g2ui-input-checklist")||customElements.define("g2ui-input-checklist",N)}};y=new WeakMap,q=new WeakMap,L=new WeakMap,E=new WeakMap,p=new WeakMap,r=new WeakMap,v=new WeakMap,l=new WeakSet,M=function(){if(s(this,q)){const i=[...s(this,p)].filter(t=>t.checked);s(this,y).setValidity({valueMissing:i.length===0},s(this,L).lookup("value_missing"),this.shadowRoot.querySelector("button"))}},x=function(i){if(i==="open"){const t=this.shadowRoot.querySelector(".wrapper");t.classList.remove("above"),s(this,r)||(h(this,l,A).call(this),t.classList.add("is-active"),this.addEventListener("focusout",this)),this.addEventListener("keydown",this)}else{const t=this.shadowRoot.querySelector(".wrapper");s(this,r)||t.classList.remove("is-active"),this.removeEventListener("keydown",this),s(this,r)||this.removeEventListener("focusout",this)}},A=function(){const i=this.shadowRoot.querySelector(".wrapper");i.classList.remove("above"),i.classList.remove("below");const t=window.getComputedStyle(this),e=this.getBoundingClientRect(),o=e.top+window.scrollY,n=document.documentElement.scrollHeight-e.bottom-window.scrollY,d=document.documentElement.scrollHeight*.5,w=window.innerHeight*.5;o>d&&o>n&&e.bottom>w?(i.classList.add("above"),s(this,r)?i.style.setProperty("--picker-inset-correction-top",`calc(${t.paddingTop})`):i.style.setProperty("--picker-inset-correction-top",`calc(${e.height}px - ${t.paddingTop} - ${t.borderTopWidth} - ${t.borderBottomWidth})`)):(i.classList.add("below"),s(this,r)?i.style.setProperty("--picker-inset-correction-top",`calc(${t.borderTopWidth} + ${t.paddingTop} - ${t.borderBottomWidth})`):i.style.setProperty("--picker-inset-correction-top",`calc(${e.height}px - ${t.borderBottomWidth} - ${t.borderTopWidth} - ${t.paddingBottom})`));const a=window.innerWidth-this.offsetParent.getBoundingClientRect().right;i.style.setProperty("--picker-inset-correction-start",`calc((${t.borderLeftWidth} + ${t.paddingLeft}) * -1)`),i.style.setProperty("--picker-min-width",`calc(${this.clientWidth}px + ${t.borderLeftWidth} + ${t.borderRightWidth}`),i.style.setProperty("--picker-max-width",`calc(${this.offsetParent.clientWidth}px - ${this.offsetLeft}px + ${a}px - 1em)`),i.style.setProperty("--inherited-border-block",`${t.borderBlock}`),i.style.setProperty("--inherited-border-inline",`${t.borderInline}`)},S=function({initial:i=!1}={}){const t=this.shadowRoot.querySelector(".selected-option"),e=[...s(this,p)].filter(n=>n.checked);e.length===0?t.textContent=this.getAttribute("placeholder")||"":e.length>2?t.textContent=s(this,L).lookup("selected_elements",e.length):t.textContent=e.map(n=>{var d;return(((d=n.closest("label"))==null?void 0:d.textContent)||n.value).trim()}).join(", ");const o=new FormData;for(const n of e)o.append(n.name,n.value);s(this,y).setFormValue(o),h(this,l,M).call(this),i||this.dispatchEvent(new Event("change"))},$(W,"shadowRootOptions",{...B.shadowRootOptions,delegatesFocus:!0}),$(W,"formAssociated",!0),$(W,"adopt",[new URL("/apps/framework/build/css/g2ui-input-c
5hecklist-DbRYjVao.css",import.meta.url)]);let Q=W;export{Q as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.