PageSourceSearch

https://nocodb-app-agy4g.ondigitalocean.app/dashboard/_nuxt/SingleSelect.d4f103fe.js

js nocodb-app-agy4g.ondigitalocean.app collected 2026-10-03 14:57:46 UTC 6,162 bytes, 1 lines download raw bytes

1import{C as oe,f as ne,d as re,E as ce,h as ie,g as ue,b as de,c as fe,q as pe}from"./index.5263eb1d.js";import{h as ve,$ as u,r as i,i as p,c0 as me,cQ as C,aq as _e,fE as B,J as ge,K as ye,k as we,ac as be,ci as he,o as v,c as $,E as t,C as x,w as O,a as S,b4 as F,cJ as I,I as E,t as A,W,aj as ke,ct as Ce,cu as xe,b as Oe,D as Se,F as Ee,d as Ie,H as Re,f as Me,f7 as je}from"./entry.e5dabfb9.js";import{a as $e,u as Ae}from"./project.c2741cbb.js";import{u as H}from"./index.b300df54.js";import{_ as Ke}from"./index.3dcd13b0.js";import{S as Ve,_ as Ne}from"./index.e64d5d46.js";import{_ as Pe}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.15861772.js";import"./toArray.f7ca0e3c.js";import"./antInputDirective.8ac36ea7.js";import"./isMobile.e2e89480.js";import"./useMemo.1d341256.js";import"./useState.8801a9b3.js";import"./DownOutlined.883a70b4.js";import"./CheckOutlined.194a267d.js";import"./SearchOutlined.a83c7642.js";import"./FormItemContext.d045f3b9.js";const qe={key:0},ze={class:"flex gap-2 text-gray-500 items-center h-full"},De={class:"text-xs whitespace-normal"},Le=ve({__name:"SingleSelect",props:{modelValue:{},rowIndex:{},disableOptionCreation:{type:Boolean}},emits:["update:modelValue"],setup(K,{emit:U}){const r=u(oe),R=u(ne),M=u(re,i(!1)),V=u(ce,i(!1)),N=u(ie,i(!1)),m=p(()=>N.value||V.value),w=i(),s=i(!1),P=u(ue,i(!1)),q=u(de,i(!1)),J=u(fe,i(!1)),{$api:Q}=Me(),_=i(),{getMeta:G}=$e(),{hasRole:c}=me(),{isPg:X,isMysql:Y}=Ae(),b=i(),z=p(()=>!q.value&&!K.disableOptionCreation&&(c("owner",!0)||c("creator",!0)||c(C.OWNER,!0)||c(C.CREATOR,!0))),d=p(()=>{if(r!=null&&r.value.colOptions){const e=r.value.colOptions?r.value.colOptions.options.filter(a=>a.title!=="")||[]:[];for(const a of e.filter(o=>o.order===null))a.title=a.title.replace(/^'/,"").replace(/'$/,"");return e.map(a=>({...a,value:a.title}))}return[]}),Z=p(()=>(d.value??[]).every(e=>e.title!==_.value)),j=p(()=>c("owner",!0)||c("creator",!0)||c("editor",!0)||c(C.OWNER,!0)||c(C.CREATOR,!0)||c(C.EDITOR,!0)),f=p(()=>(j.value||J.value)&&m.value),g=p({get:()=>b.value??K.modelValue,set:e=>{if(e&&z.value&&(d.value??[]).every(a=>a.title!==e))return b.value=e,ee();U("update:modelValue",e||null)}});_e(s,(e,a)=>{var o,l,k,n,L,T;f.value&&(e?(T=(L=(n=w.value)==null?void 0:n.$el)==null?void 0:L.querySelector("input"))==null||T.focus():(k=(l=(o=w.value)==null?void 0:o.$el)==null?void 0:l.querySelector("input"))==null||k.blur())}),H(N,e=>{var a;switch(e.key){case"Escape":s.value=!1;break;case"Enter":f.value&&m.value&&!s.value&&(s.value=!0);break;case" ":break;default:if(!f.value){e.preventDefault();break}!(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)&&((a=e.key)==null?void 0:a.length)===1&&!je()&&(e.stopPropagation(),s.value=!0);break}}),H(s,e=>{e.key==="Escape"&&(s.value=!1)});async function ee(){var a,o;if(!b.value||q.value)return!1;const e=b.value;if(_.value="",b.value=void 0,e&&!d.value.some(l=>l.title===e))try{d.value.push({title:e,value:e,color:B.light[(d.value.length+1)%B.light.length]}),r.value.colOptions={options:d.value.map(({value:k,...n})=>n)};const l={...r.value};l.cdf&&(X(r.value.base_id)&&(l.cdf=l.cdf.substring(l.cdf.indexOf("'")+1,l.cdf.lastIndexOf("'"))),Y(r.value.base_id)||(l.cdf=l.cdf.replace(/''/g,"'"))),await Q.dbTableColumn.update(((a=r.value)==null?void 0:a.fk_column_id)||((o=r.value)==null?void 0:o.id),l),g.value=e,await G(r.value.fk_model_id,!0)}catch(l){console.log(l),ge.error(await ye(l))}}const te=()=>{var e,a,o;_.value=(o=(a=(e=w.value)==null?void 0:e.$el)==null?void 0:a.querySelector(".ant-select-selection-search-input"))==null?void 0:o.value},ae=e=>{s.value&&m.value&&e.stopPropagation(),e.key==="Enter"&&e.stopPropagation()},le=()=>{s.value=!1},y=u(pe,null),se=e=>{var a,o;if((a=e.target)!=null&&a.classList.contains("ant-select-clear")||(o=e.target)!=null&&o.closest(".ant-select-clear"))return g.value="",e.stopPropagation();y||(s.value=f.value&&!s.value)},D=()=>{s.value=f.value&&!s.value};we(()=>{y==null||y.on(D)}),be(()=>{y==null||y.on(D)}),he(document,"click",e=>{s.value&&w.value&&!w.value.$el.contains(e.target)&&(s.value=!1)},!0);const h=p(()=>d.value.find(e=>e.value===g.value));return(e,a)=>{const o=Ke,l=Ve,k=Ne;return v(),$("div",{class:E(["h-full w-full flex items-center nc-single-select",{"read-only":t(R)||t(M)}]),onClick:se},[t(m)||t(V)?(v(),x(k,{key:1,ref_key:"aselect",ref:w,value:t(g),"onUpdate:value":a[1]||(a[1]=n=>Re(g)?g.value=n:null),class:E(["w-full overflow-hidden",{"caret-transparent":!t(j)}]),"allow-clear":!t(r).rqd&&t(f),bordered:!1,open:t(s)&&t(f),disabled:t(R)||!t(f)||t(M),"show-arrow":t(j)&&!(t(R)||t(M))&&t(m)&&t(g)===null,"dropdown-class-name":`nc-dropdown-single-select-cell ${t(s)&&t(m)?"active":""}`,"show-search":t(s)&&t(m),onSelect:le,onKeydown:a[2]||(a[2]=n=>ae(n)),onSearch:te},{default:O(()=>[(v(!0),$(ke,null,Ce(t(d),n=>(v(),x(l,{key:n.title,value:n.title,"data-testid":`select-option-${t(r).title}-${e.rowIndex}`,class:E(`nc-select-option-${t(r).title}-${n.title}`),onClick:a[0]||(a[0]=xe(()=>{},["stop"]))},{default:O(()=>[Oe(o,{class:"rounded-tag",color:n.color},{default:O(()=>[S("span",{style:F({color:t(I).isReadable(n.color||"#ccc","#fff",{level:"AA",size:"large"})?"#fff":t(I).mostReadable(n.color||"#ccc",["#0b1d05","#fff"]).toHex8String(),"font-size":"13px"}),class:E({"text-sm":t(P)}
1)},A(n.title),7)]),_:2},1032,["color"])]),_:2},1032,["value","data-testid","class"]))),128)),t(_)&&t(Z)&&t(z)?(v(),x(l,{key:t(_),value:t(_)},{default:O(()=>[S("div",ze,[(v(),x(Se(t(Ee).plusThick),{class:"min-w-4"})),S("div",De,[Ie(" Create new option named "),S("strong",null,A(t(_)),1)])])]),_:1},8,["value"])):W("",!0)]),_:1},8,["value","class","allow-clear","open","disabled","show-arrow","dropdown-class-name","show-search"])):(v(),$("div",qe,[t(h)?(v(),x(o,{key:0,class:"rounded-tag",color:t(h).color},{default:O(()=>[S("span",{style:F({color:t(I).isReadable(t(h).color||"#ccc","#fff",{level:"AA",size:"large"})?"#fff":t(I).mostReadable(t(h).color||"#ccc",["#0b1d05","#fff"]).toHex8String(),"font-size":"13px"}),class:E({"text-sm":t(P)})},A(t(h).title),7)]),_:1},8,["color"])):W("",!0)]))],2)}}});const nt=Pe(Le,[["__scopeId","data-v-9b4167c9"]]);export{nt 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.