Files

1 line
2.7 KiB
JavaScript

import{k as e,rt as t,xt as n}from"./common.js";import{computed as r,createBlock as i,createCommentVNode as a,createTextVNode as o,defineComponent as s,mergeProps as c,openBlock as l,ref as u,toDisplayString as d,toHandlers as f,unref as p,useCssVars as m,watch as h,withCtx as g}from"vue";import{Segmented as _}from"ant-design-vue";import{useDesign as v}from"@mfish/core/hooks";import{Icon as y}from"@mfish/core/components/Icon";import{ThemeEnum as b}from"@mfish/core/enums";var x=s({name:`MfSegmented`,__name:`index`,props:{chart:{type:Object,required:!0},chartContain:{type:Object,required:!0}},setup(s){m(e=>({v0784146e:R.value,v130e28fc:`${U.value-6}px`,eccaf214:E.value,v34a788e2:D.value,v0f383882:`${O.value}px`,v34ab2c76:k.value,v30ea9970:A.value,e86dc0e8:j.value,v02f0aaec:z.value,v3efdbd5a:M.value,v179cd2aa:N.value,v099e5fa6:`${P.value}px`,v17a0763e:F.value,v98f4c4e8:I.value,v412c55f0:L.value}));let x=s,{commonEvents:S,emitEvent:C}=t(x.chart,void 0,[`titleChange`]),w=r(()=>x.chart.data?.dataSet?.map((e,t)=>({title:e.title,value:e.value||e.title,payload:{icon:e.icon,index:t}}))),T=n(),E=r(()=>x.chart.options?.textStyle?.textColor),D=r(()=>x.chart.options?.textStyle?.font),O=r(()=>x.chart.options?.textStyle?.fontSize||14),k=r(()=>x.chart.options?.textStyle?.fontStyle?.bold?`bold`:``),A=r(()=>x.chart.options?.textStyle?.fontStyle?.italic?`italic`:``),j=r(()=>x.chart.options?.textStyle?.fontStyle?.underline?`underline`:``),M=r(()=>x.chart.options?.selectStyle?.textColor||E.value),N=r(()=>x.chart.options?.selectStyle?.font||D.value),P=r(()=>x.chart.options?.selectStyle?.fontSize||O.value),F=r(()=>x.chart.options?.selectStyle?.fontStyle?.bold?`bold`:k.value),I=r(()=>x.chart.options?.selectStyle?.fontStyle?.italic?`italic`:A.value),L=r(()=>x.chart.options?.selectStyle?.fontStyle?.underline?`underline`:j.value),R=r(()=>x.chart.options?.transparent?`transparent`:T.getTheme===b.DARK?`#000000`:`#f5f5f5`),z=r(()=>x.chart.options?.selectStyle?.selectBackground||(T.getTheme===b.DARK?`#1f1f1f`:`#ffffff`)),B=r(()=>x.chart.options?.transparent||!1),V=u(``),{prefixCls:H}=v(`mf-segmented`),U=r(()=>x.chartContain?.dropInfo?.height);h(()=>x.chart?.data?.dataSet,e=>{e&&W(e)},{immediate:!0,deep:!0});function W(e){e?.length>0&&(V.value=e[0].value||e[0].title||``)}function G(t){V.value=t;let n=w.value.find(e=>e.value===t)?.payload?.index;if(n>=0){let t=e(x.chart);t?.length>n&&C(`titleChange`,t[n])}}return(e,t)=>(l(),i(p(_),c({class:p(H),style:B.value?{backgroundColor:`transparent`}:{},value:V.value,options:w.value,onChange:G,block:``},f(p(S))),{label:g(({title:e,payload:t})=>[t.icon?(l(),i(p(y),{key:0,icon:t.icon,size:O.value},null,8,[`icon`,`size`])):a(``,!0),o(` `+d(e),1)]),_:1},16,[`class`,`style`,`value`,`options`]))}});export{x as default};