Files
andronevskaya/site/assets/83669f75-69d5-4838-94c5-4a50ac105bb4-CXKKP5ld.js
2026-02-18 15:43:09 +03:00

2 lines
7.9 KiB
JavaScript

import{_ as se,c as w,o as f,b,a as E,p as d,t as B,n as V,q as ue,v as we,s as fe,F as be,r as ve,d as v,e as g,w as X,f as _e,g as ye,k as ge,u as he,h as _}from"./main-D6qyxymd.js";import{e as me,a as Ce,b as Se,c as ke,d as pe,f as Oe,g as Le}from"./wwElement-DQHs103p.js";import{s as Pe}from"./wwSection-CQpGyXbr.js";const D={props:{content:{type:Object,required:!0},uid:{type:String,required:!0}},emits:["trigger-event"],setup(e,{emit:l}){const o=v(()=>!1),n=g(null),L=g(null),P=g(null),a=g(!1),h=g(!1),p=g(""),H=g(!1),T=g({}),{value:I,setValue:z}=wwLib.wwVariable.useComponentVariable({uid:e.uid,name:"value",type:"any",defaultValue:v(()=>e.content.initialValue??null)}),k=v(()=>{var A,Q,K,G,J;const t=Array.isArray((A=e.content)==null?void 0:A.options)?e.content.options.slice():[],r=(Q=e.content)==null?void 0:Q.labelPropertyPath,i=(K=e.content)==null?void 0:K.valuePropertyPath,y=(G=e.content)==null?void 0:G.iconPropertyPath,C=(J=e.content)==null?void 0:J.parentPropertyPath,x=t.map((c,u)=>{var W;const s=r?wwLib.wwUtils.resolveObjectPropertyPath(c,r):c.label??"",S=i?wwLib.wwUtils.resolveObjectPropertyPath(c,i):c.value??c.id??null,de=(W=e.content)!=null&&W.enableIcons&&y?wwLib.wwUtils.resolveObjectPropertyPath(c,y):c.icon??null;return{_raw:c,_ww_key:S!=null?String(S):`__idx_${u}`,label:s??"",value:S,icon:de,_parentRaw:C?wwLib.wwUtils.resolveObjectPropertyPath(c,C):c.parent_id??c.parent}});if(e.content.enableNoValue&&x.unshift({_raw:null,_ww_key:"__no_value",label:e.content.noValueLabel||"Not selected",value:null,icon:null,_parentRaw:null,level:0}),!e.content.showHierarchy||!e.content.parentPropertyPath)return x.map(c=>({...c,level:0}));const O=Object.create(null);x.forEach(c=>{const u=c._ww_key;O[u]={...c,children:[],level:0}});const U=[];x.forEach(c=>{const u=c._ww_key,s=c._parentRaw,S=s==null?null:String(s);S&&O[S]?O[S].children.push(O[u]):U.push(O[u])});const N=[],q=(c,u=0)=>{for(const s of c)s.level=u,N.push(s),s.children&&s.children.length&&q(s.children,u+1)};return q(U,0),N}),$=v(()=>{if(!e.content.enableSearch||!p.value)return k.value;const t=p.value.toLowerCase();return k.value.filter(r=>String(r.label||"").toLowerCase().includes(t))}),F=async()=>{const{getIcon:t}=wwLib.useIcons(),r={};for(const i of k.value)if(i.icon)try{r[i.icon]=await t(i.icon)}catch{r[i.icon]=""}T.value=r};X(()=>k.value,F,{deep:!0}),_e(F);const ee=v(()=>k.value.find(t=>String(t.value)===String(I.value))||null),M=t=>String(t.value)===String(I.value),ne=v(()=>({fontFamily:e.content.fontFamily||"inherit",fontSize:e.content.fontSize||"14px"})),te=v(()=>({backgroundColor:e.content.triggerBackgroundColor||"#fff",borderColor:h.value?e.content.focusBorderColor||"#4a90e2":e.content.borderColor||"#ddd",borderRadius:e.content.inputBorderRadius||"4px",padding:e.content.triggerPadding||"8px 12px"})),oe=v(()=>({backgroundColor:e.content.menuBackgroundColor||"#fff",borderColor:e.content.menuBorderColor||e.content.borderColor||"#ddd"})),ce=v(()=>({borderColor:a.value?e.content.focusBorderColor||"#4a90e2":e.content.borderColor||"#ddd"})),le=t=>{var i,y,C;const r=M(t);return{padding:((i=e.content)==null?void 0:i.optionPadding)||"8px 12px",...r?{backgroundColor:((y=e.content)==null?void 0:y.selectedOptionBgColor)||"#e6f0fd",color:((C=e.content)==null?void 0:C.selectedOptionTextColor)||"#4a90e2"}:{}}},ae=()=>{o.value||e.content.disabled||(h.value?j():re())},re=async()=>{h.value=!0,p.value="",await ge(),m(),e.content.enableSearch&&P.value&&P.value.focus(),document.addEventListener("click",R),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)},j=()=>{h.value=!1,document.removeEventListener("click",R),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)},m=()=>{if(!n.value||!L.value)return;const t=n.value.getBoundingClientRect(),r=L.value.offsetHeight,y=window.innerHeight-t.bottom,C=t.top;H.value=y<r&&C>y},R=t=>{n.value&&!n.value.contains(t.target)&&j()},ie=t=>{o.value||(z(t.value),l("trigger-event",{name:"change",event:{value:t.value}}),j())};return X(()=>e.content.initialValue,t=>{t!=null&&String(I.value)!==String(t)&&(z(t),l("trigger-event",{name:"initValueChange",event:{value:t}}))}),ye(()=>{document.removeEventListener("click",R),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),{dropdownRef:n,menuRef:L,searchInputRef:P,isOpen:h,isDropUp:H,searchQuery:p,selectedOption:ee,displayOptions:k,filteredDisplayOptions:$,toggleDropdown:ae,selectOption:ie,isOptionSelected:M,containerStyle:ne,triggerStyle:te,menuStyle:oe,searchInputStyle:ce,getOptionStyle:le,iconHTML:T,searchInputFocused:a}}},Y=()=>{he(e=>({b21ee978:e.content.focusBorderColor||"#4a90e2",e9f2cb7a:e.content.caretIconSize||"16px","0dd0ef27":e.content.selectedOptionBgColor||"#e6f0fd","56611a97":e.content.selectedOptionTextColor||"#4a90e2","1146aa2b":e.content.optionHoverColor||"#f5f5f5"}))},Z=D.setup;D.setup=Z?(e,l)=>(Y(),Z(e,l)):Y;const xe={class:"dropdown-value"},Be=["placeholder"],Ve={class:"dropdown-options"},Ie=["onClick"],je={key:0,class:"option-icon"},Re=["innerHTML"];function Ee(e,l,o,n,L,P){return f(),w("div",{class:V(["dropdown-with-search",{"is-open":n.isOpen,"is-disabled":o.content.disabled}]),ref:"dropdownRef",style:d(n.containerStyle)},[b("div",{class:V(["dropdown-trigger",{"is-active":n.isOpen}]),onClick:l[0]||(l[0]=(...a)=>n.toggleDropdown&&n.toggleDropdown(...a)),style:d(n.triggerStyle)},[b("div",xe,[n.selectedOption?(f(),w("span",{key:0,style:d({color:o.content.triggerTextColor||"#000"})},B(n.selectedOption.label),5)):(f(),w("span",{key:1,class:"placeholder",style:d({color:o.content.placeholderColor||"#999",fontStyle:o.content.placeholderFontStyle||"normal"})},B(o.content.enableNoValue?o.content.noValueLabel||"Not selected":o.content.placeholder||"Select an option"),5))]),b("div",{class:"dropdown-icon",style:d({color:o.content.triggerTextColor||"#666666",width:o.content.caretIconSize||"16px",height:o.content.caretIconSize||"16px"})},l[5]||(l[5]=[b("svg",{viewBox:"0 0 24 24",fill:"none"},[b("path",{d:"M6 9L12 15L18 9",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)]),4)],6),n.isOpen?(f(),w("div",{key:0,class:V(["dropdown-menu",{"dropdown-menu-up":n.isDropUp}]),style:d(n.menuStyle),ref:"menuRef"},[o.content.enableSearch?(f(),w("div",{key:0,class:"dropdown-search",style:d({borderColor:o.content.menuBorderColor||o.content.borderColor||"#dddddd"})},[ue(b("input",{type:"text","onUpdate:modelValue":l[1]||(l[1]=a=>n.searchQuery=a),placeholder:o.content.searchPlaceholder||"Search...",onClick:l[2]||(l[2]=fe(()=>{},["stop"])),ref:"searchInputRef",style:d(n.searchInputStyle),onFocus:l[3]||(l[3]=a=>n.searchInputFocused=!0),onBlur:l[4]||(l[4]=a=>n.searchInputFocused=!1)},null,44,Be),[[we,n.searchQuery]])],4)):E("",!0),b("div",Ve,[n.displayOptions.length?(f(!0),w(be,{key:0},ve(n.filteredDisplayOptions,(a,h)=>(f(),w("div",{key:a._ww_key||h,class:V(["dropdown-option",{"is-selected":n.isOptionSelected(a)}]),onClick:p=>n.selectOption(a),style:d(n.getOptionStyle(a))},[o.content.enableIcons&&a.icon?(f(),w("div",je,[b("span",{innerHTML:n.iconHTML[a.icon]},null,8,Re)])):E("",!0),b("span",{style:d({marginLeft:o.content.showHierarchy?(a.level||0)*16+"px":"0"})},B(a.label),5)],14,Ie))),128)):(f(),w("div",{key:1,class:"dropdown-no-results",style:d({color:o.content.placeholderColor||"#999999"})},B(o.content.noResultsText||"No options found"),5))])],6)):E("",!0)],6)}const De=se(D,[["render",Ee],["__scopeId","data-v-9297e891"]]);_.component("wwobject-1b1e2173-9b78-42cc-a8ee-a6167caea340",me);_.component("wwobject-537c88ea-5165-4131-9824-cc192f472ace",De);_.component("wwobject-59dca300-db78-42e4-a7a6-0cbf22d3cc82",Ce);_.component("wwobject-b783dc65-d528-4f74-8c14-e27c934c39b1",Se);_.component("wwobject-bf59c8e7-14c9-4c03-a739-8bd7d14031a4",ke);_.component("wwobject-c6c0c00e-49fd-4cb9-bd78-5bc09945721e",pe);_.component("wwobject-d7904e9d-fc9a-4d80-9e32-728e097879ad",Oe);_.component("wwobject-deb10a01-5eef-4aa1-9017-1b51c2ad6fd0",Le);_.component("section-99586bd3-2b15-4d6b-a025-6a50d07ca845",Pe);