Files

1 line
2.1 KiB
JavaScript

import{k as e,rt as t,xt as n}from"./common.js";import{computed as r,createBlock as i,defineComponent as a,mergeProps as o,openBlock as s,ref as c,toHandlers as l,unref as u,useCssVars as d,watch as f}from"vue";import{Select as p}from"ant-design-vue";import{useDesign as m}from"@mfish/core/hooks";import{ThemeEnum as h}from"@mfish/core/enums";var g=a({name:`MfSelect`,__name:`index`,props:{chart:{type:Object,required:!0},chartContain:{type:Object,required:!0}},setup(a){d(e=>({v7763483c:b.value,v3e2e4374:`${x.value}px`,v4d71b16e:`${j.value-6}px`,a382bd30:w.value,aa8c3c46:T.value,v499bc0f4:`${E.value}px`,aa8fdfda:D.value,v2db03784:O.value,v9f258c04:k.value}));let g=a,{commonEvents:_,emitEvent:v}=t(g.chart,void 0,[`selectChange`]),y=r(()=>g.chart.data?.dataSet?.map(e=>({label:e.label,value:e.value||e.label}))),b=r(()=>g.chartContain?.background||(A.getTheme===h.DARK?`#141414`:`#ffffff`)),x=r(()=>g.chartContain?.border?.radius||4),S=r(()=>g.chart.options?.showSearch||!1),C=r(()=>g.chart.options?.allowClear||!1),w=r(()=>g.chart.options?.textStyle?.textColor),T=r(()=>g.chart.options?.textStyle?.font),E=r(()=>g.chart.options?.textStyle?.fontSize||14),D=r(()=>g.chart.options?.textStyle?.fontStyle?.bold?`bold`:``),O=r(()=>g.chart.options?.textStyle?.fontStyle?.italic?`italic`:``),k=r(()=>g.chart.options?.textStyle?.fontStyle?.underline?`underline`:``),A=n(),j=r(()=>g.chartContain?.dropInfo?.height),M=c(),{prefixCls:N}=m(`mf-select`);f(()=>g.chart?.data?.defaultValue,e=>{e!==void 0&&(M.value=e)},{immediate:!0});function P(t){M.value=t;let n=y.value.findIndex(e=>e.value===t);if(n===-1)v(`selectChange`,t);else{let t=e(g.chart);t?.length>n&&v(`selectChange`,t[n])}}return(e,t)=>(s(),i(u(p),o({class:u(N),value:M.value,"onUpdate:value":t[0]||=e=>M.value=e,options:y.value,onChange:P},l(u(_)),{bordered:!1,"show-search":S.value,"allow-clear":C.value,"option-filter-prop":`label`,"dropdown-style":{scale:u(A).getScale,color:w.value,fontFamily:T.value,fontSize:`${E.value}px`,fontWeight:D.value,fontStyle:O.value,textDecoration:k.value,background:b.value}}),null,16,[`class`,`value`,`options`,`show-search`,`allow-clear`,`dropdown-style`]))}});export{g as default};