PageSourceSearch

https://faptap.net/assets/SelectInput.vue_vue_type_script_setup_true_lang.493d8564.js

js faptap.net collected 2026-09-25 22:12:11 UTC 3,976 bytes, 1 lines download raw bytes

1import{d as U,b as c,c as A,w as K,v as u,f as m,F as E,N as _,i as L,t as k,g as y,l as $,ac as j,af as M,j as O,n as h,R as D,m as P,Q,p as R,x as q}from"./index.16ba4ea0.js";const G=["placeholder","disabled"],H={key:0},J={key:1},Y=U({__name:"SelectInput",props:{max:{default:-1},create:{type:Boolean,default:!1},options:{},modelValue:{},placeholder:{},context:{},disabled:{type:Boolean}},emits:["update:modelValue","search","add","remove"],setup(T,{expose:B,emit:N}){const i=N,l=T,v=c(!1),o=c(""),f=c(),F=c(),g=c(!1),n=c(-1),r=e=>typeof e=="string"?e:e.label,z=e=>{const t=l.modelValue[e];l.modelValue.splice(e,1),i("update:modelValue",l.modelValue),i("remove",t)},p=e=>{var b;if(!e)return;o.value="",f.value&&(f.value.value=""),v.value=!1,n.value=-1;const t=l.options.find(d=>r(d).toLowerCase()===e.toLowerCase());if(t&&(e=r(t)),l.modelValue.some(d=>r(d).toLowerCase()===e.toLowerCase())||l.max!==-1&&l.modelValue.length>=l.max)return;const s=t!=null?t:e;l.modelValue.push(s),i("update:modelValue",l.modelValue),i("add",s),(b=f.value)==null||b.focus()},V=e=>{o.value="",e.split(",").map(t=>t.trim()).filter(Boolean).forEach(t=>p(t))},I=()=>{setTimeout(()=>{g.value=!1},150)},S=e=>{switch(e.code){case"ArrowDown":e.preventDefault(),n.value<w.value.length-1&&n.value++;break;case"ArrowUp":e.preventDefault(),n.value>-1&&n.value--;break;case"Enter":const t=w.value[n.value];if(!o.value&&!t)return;e.preventDefault(),t?p(r(t)):o.value&&l.create&&V(o.value);break;case"Backspace":if(o.value!=="")return;e.preventDefault(),l.modelValue.length>0&&(l.modelValue.splice(l.modelValue.length-1,1),i("update:modelValue",l.modelValue));break}},w=A(()=>l.options.filter(e=>{const t=r(e);return!l.modelValue.some(a=>r(a).toLowerCase()===t.toLowerCase())}).filter(e=>r(e).toLowerCase().includes(o.value.toLowerCase())));let x=-1,C=-1;return K(o,e=>{if(clearTimeout(x),clearTimeout(C),v.value=e.length>0,n.value=-1,e.length>0){if(e.includes(",")){V(e);return}x=setTimeout(()=>i("search",e),200),C=setTimeout(()=>{if(o.value===e&&e.trim()&&l.create){const t=e.trim();p(t)}},1e4)}}),B({commitInput:()=>{o.value.trim()&&l.create&&V(o.value)}}),(e,t)=>(u(),m("div",{ref_key:"referenceElement",ref:F,onClick:t[4]||(t[4]=a=>{var s;return!l.disabled&&((s=e.$refs.inputElement)==null?void 0:s.focus())}),class:R(["w-full py-1.5 px-2 focus-visible:outline-none bg-zinc-800 focus:ring-2 ring-blue-500 rounded flex gap-1.5 flex-wrap",{"ring-2 ring-blue-500":g.value,"opacity-60 pointer-events-none":l.disabled}])},[(u(!0),m(E,null,_(l.modelValue,(a,s)=>(u(),m("div",{key:s,class:"bg-zinc-700 rounded text-sm px-2.5 py-0.5 flex items-center gap-x-1 grow-0 shrink-0"},[L("span",null,k(typeof a=="string"?a:a.label),1),l.disabled?$("",!0):(u(),y(q,{key:0,onClick:b=>{var d;return z(s),(d=f.value)==null?void 0:d.focus()},name:"close",class:"text-zinc-400 h-4 w-4 -mr-1.5 hover:text-white cursor-pointer"},null,8,["onClick"]))]))),128)),j(L("input",{ref_key:"inputElement",ref:f,"onUpdate:modelValue":t[0]||(t[0]=a=>o.value=a),placeholder:l.modelValue.length?void 0:l.placeholder,disabled:l.disabled,onFocus:t[1]||(t[1]=a=>g.value=!0),onFocusout:I,onKeydown:S,class:"bg-transparent focus-visible:outline-none text-white disabled:cursor-not-allowed",type:"text"},null,40,G),[[M,o.value]]),O(Q,{modelValue:v.value,"onUpdate:modelValue":t[3]||(t[3]=a=>v.value=a),target:e.$refs.referenceElement,placement:"bottom",offset:8,class:"py-1.5 text-white"},{default:h(()=>[o.value?(u(),y(D,{key:0,active:n.value===-1,onClick:t[2]||(t[2]=a=>l.create?p(o.value):void 0)},{default:h(()=>[l.create?(u(),m("div",H,' Press Enter to add "'+k(o.value)+'" ',1)):(u(),m("div",J," No matches found "))]),_:1},8,["active"])):$("",!0),(u(!0),m(E,null,_(w.value,(a,s)=>(u(),y(D,{key:typeof a=="string"?a:a.value,active:s===n.value,onClick:b=>p(typeof a=="string"?a:a.label)},{default:h(()=>[P(k(typeof a=="string"?a:a.label),1)]),_:2},1032,["active","onClick"]))),128))]),_:1},8,["modelValue","target"])],2))}});export{Y as _};

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.