2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
import{e as C,l as g,B as F,o as p,c as v,t as h,j as b,a as t,N as y,x as w,F as U,r as q,k as D,m as V,h as E,P,b as R,v as G}from"./CQHa_U7G.js";import{_ as J}from"./DlAUqK2U.js";const O={class:"relative"},W={key:0,class:"block text-sm font-medium text-slate-300 mb-1"},X={class:"relative"},Y=["value","onKeydown","placeholder"],Z={key:0,class:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 animate-spin text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Q={key:1,class:"absolute z-50 mt-1 w-full bg-slate-800 border border-slate-600 rounded-lg shadow-xl max-h-60 overflow-y-auto"},ee=["onMousedown"],te={class:"font-mono text-indigo-400"},le={class:"text-xs text-slate-500 ml-auto"},oe={key:2,class:"absolute z-50 mt-1 w-full bg-slate-800 border border-slate-600 rounded-lg shadow-xl p-3 text-sm text-slate-400"},ne=C({__name:"SmartLocationInput",props:{modelValue:{default:null},label:{default:""},placeholder:{default:"Kezdj el gépelni (irányítószám vagy város)..."},minChars:{default:2},countryCode:{default:"HU"},debounceMs:{default:300}},emits:["update:modelValue","select"],setup(s,{emit:k}){const a=s,m=k,x=g(null),d=g(""),o=g(a.modelValue),r=g([]),e=g(!1),i=g(!1),l=g(0);let z=null;const I=V(()=>o.value?`${o.value.zip_code} ${o.value.city}`:d.value),c=V(()=>{if(!d.value||d.value.length<a.minChars)return[];const n=d.value.toLowerCase();return r.value.filter(u=>u.zip_code.toLowerCase().includes(n)||u.city.toLowerCase().includes(n))});F(()=>a.modelValue,n=>{o.value=n});function $(n){const u=n.target;d.value=u.value,o.value&&(o.value=null,m("update:modelValue",null)),z&&clearTimeout(z),d.value.length>=a.minChars?z=setTimeout(()=>{L(d.value)},a.debounceMs):(r.value=[],i.value=!1)}async function L(n){if(!(!n||n.length<a.minChars)){e.value=!0;try{const u=await $fetch("/api/v1/locations/autocomplete",{params:{q:n,country_code:a.countryCode,limit:15},headers:j()});r.value=u||[],l.value=0,i.value=r.value.length>0}catch(u){console.error("Location autocomplete error:",u),r.value=[]}finally{e.value=!1}}}function j(){const n=E("access_token").value,u={"Content-Type":"application/json"};return n&&(u.Authorization=`Bearer ${n}`),u}function _(n){o.value=n,d.value="",i.value=!1,m("update:modelValue",n),m("select",n)}function B(){o.value=null,d.value="",r.value=[],i.value=!1,m("update:modelValue",null),P(()=>{x.value?.focus()})}function H(){i.value=!1}function M(){c.value.length>0&&(i.value=!0)}function N(){setTimeout(()=>{i.value=!1},200)}function S(){c.value.length>0&&(l.value=(l.value+1)%c.value.length)}function T(){c.value.length>0&&(l.value=(l.value-1+c.value.length)%c.value.length)}function K(){c.value.length>0&&l.value>=0&&_(c.value[l.value])}return(n,u)=>(p(),v("div",O,[s.label?(p(),v("label",W,h(s.label),1)):b("",!0),t("div",X,[t("input",{ref_key:"inputRef",ref:x,value:I.value,onInput:$,onFocus:M,onBlur:N,onKeydown:[y(w(S,["prevent"]),["down"]),y(w(T,["prevent"]),["up"]),y(w(K,["prevent"]),["enter"]),y(H,["escape"])],placeholder:s.placeholder,class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,Y),e.value?(p(),v("svg",Z,[...u[0]||(u[0]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},null,-1)])])):b("",!0),o.value&&!e.value?(p(),v("button",{key:1,onClick:B,class:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition",type:"button"},[...u[1]||(u[1]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])):b("",!0)]),i.value&&c.value.length>0?(p(),v("div",Q,[(p(!0),v(U,null,q(c.value,(f,A)=>(p(),v("button",{key:f.id,onMousedown:w(he=>_(f),["prevent"]),class:D(["w-full text-left px-3 py-2 text-sm transition flex items-center gap-2",A===l.value?"bg-indigo-500/20 text-white":"text-slate-300 hover:bg-slate-700"])},[t("span",te,h(f.zip_code),1),t("span",null,h(f.city),1),t("span",le,h(f.country_code),1)],42,ee))),128))])):b("",!0),i.value&&d.value.length>=s.minChars&&c.value.length===0&&!e.value?(p(),v("div",oe," Nincs találat ")):b("",!0)]))}}),se=J(ne,[["__scopeId","data-v-b43e13ca"]]),ue={class:"bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6"},ae={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},ie={class:"md:col-span-2"},re={class:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-3"},de=["value"],ce=["value"],pe=["value"],ve=["value"],me=["value"],ge=["value"],fe=["value"],be=["value"],xe=["value"],ke=C({__name:"SharedAddressForm",props:{modelValue:{default:()=>({zip:null,city:null,street_name:null,street_type:null,house_number:null,stairwell:null,floor:null,door:null,parcel_id:null,full_address_text:null,latitude:null,longitude:null})}},emits:["update:modelValue"],setup(s,{emit:k}){const a=s,m=k,x=V(()=>a.modelValue?.zip&&a.modelValue?.city?{id:0,zip_code:a.modelValue.zip,city:a.modelValue.city,country_code:"HU"}:null);function d(r){if(r){const e={...a.modelValue};e.zip=r.zip_code,e.city=r.city,m("update:modelValue",e)}}function o(r,e){const i={...a.modelValue};i[r]=e||null,m("update:modelValue",i)}return(r,e)=>{const i=se;return p(),v("div",null,[t("div",ue,[e[19]||(e[19]=t("h2",{class:"text-lg font-semibold text-white mb-4"},"Cím adatok",-1)),t("div",ae,[t("div",ie,[R(i,{"model-value":x.value,"onUpdate:modelValue":d,label:"Irányítószám / Város",placeholder:"Kezdj el gépelni (pl. 1011 vagy Budapest)..."},null,8,["model-value"]),t("div",re,[t("div",null,[e[9]||(e[9]=t("label",{class:"block text-xs font-medium text-slate-400 mb-1"},"Irányítószám (kézi)",-1)),t("input",{value:s.modelValue.zip,onInput:e[0]||(e[0]=l=>o("zip",l.target.value)),placeholder:"pl. 1151",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,de)]),t("div",null,[e[10]||(e[10]=t("label",{class:"block text-xs font-medium text-slate-400 mb-1"},"Város (kézi)",-1)),t("input",{value:s.modelValue.city,onInput:e[1]||(e[1]=l=>o("city",l.target.value)),placeholder:"pl. Budapest",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,ce)])])]),t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Utca neve",-1)),t("input",{value:s.modelValue.street_name,onInput:e[2]||(e[2]=l=>o("street_name",l.target.value)),placeholder:"pl. Egressy",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,pe)]),t("div",null,[e[13]||(e[13]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Közterület jellege",-1)),t("select",{value:s.modelValue.street_type,onChange:e[3]||(e[3]=l=>o("street_type",l.target.value)),class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},[...e[12]||(e[12]=[G('<option value="">Válassz...</option><option value="utca">utca</option><option value="út">út</option><option value="tér">tér</option><option value="körút">körút</option><option value="sugárút">sugárút</option><option value="köz">köz</option><option value="sétány">sétány</option><option value="lakópark">lakópark</option><option value="liget">liget</option><option value="erdő">erdő</option><option value="dűlő">dűlő</option><option value="major">major</option><option value="puszta">puszta</option><option value="sziget">sziget</option><option value="telep">telep</option>',16)])],40,ve)]),t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Házszám",-1)),t("input",{value:s.modelValue.house_number,onInput:e[4]||(e[4]=l=>o("house_number",l.target.value)),placeholder:"pl. 4/b",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,me)]),t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Lépcsőház",-1)),t("input",{value:s.modelValue.stairwell,onInput:e[5]||(e[5]=l=>o("stairwell",l.target.value)),placeholder:"pl. 1",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,ge)]),t("div",null,[e[16]||(e[16]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Emelet",-1)),t("input",{value:s.modelValue.floor,onInput:e[6]||(e[6]=l=>o("floor",l.target.value)),placeholder:"pl. 3",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,fe)]),t("div",null,[e[17]||(e[17]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Ajtó",-1)),t("input",{value:s.modelValue.door,onInput:e[7]||(e[7]=l=>o("door",l.target.value)),placeholder:"pl. A",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,be)]),t("div",null,[e[18]||(e[18]=t("label",{class:"block text-sm font-medium text-slate-300 mb-1"},"Helyrajzi szám (hrsz)",-1)),t("input",{value:s.modelValue.parcel_id,onInput:e[8]||(e[8]=l=>o("parcel_id",l.target.value)),placeholder:"pl. 12345/6",class:"w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"},null,40,xe)])])])])}}});export{ke as _};
|