@aplus-frontend/ui
Version:
2 lines (1 loc) • 4.94 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),z=require("@ant-design/icons-vue"),v=require("@aplus-frontend/antdv"),i=require("lodash-unified"),T=require("../../ap-action/index.js");require("../../config-provider/index.js");const $=require("./style/index.js"),q=require("../../config-provider/hooks/use-locale.js"),A=require("../../config-provider/hooks/use-namespace.js"),V=["onClick"],D=e.defineComponent({__name:"ApExpandAlert",props:{type:{default:"warning"},data:{default:()=>[]},prefix:{default:""},tipTitle:{default:""},mapLabel:{},separator:{default:"|"},separatorStyle:{default:()=>({})},contentStyle:{default:()=>({})},prefixStyle:{default:()=>({})},rows:{default:2},defaultExpand:{type:Boolean,default:!0},showIcon:{type:Boolean,default:!0},closable:{type:Boolean},afterClose:{}},emits:["choose","expand","close"],setup(C,{expose:g,emit:B}){const u=B,r=C,{t:m}=q.useLocale(),S=e.computed(()=>{if(r.type!="card")return r.type}),l=e.ref(""),s=e.ref(null),w=e.computed(()=>({fontWeight:"400",wordBreak:"break-all",overflow:"hidden",display:"-webkit-box",webkitLineClamp:l.value,webkitBoxOrient:"vertical",lineHeight:"18px"}));function x(){l.value==="1"?(l.value="",u("expand","expand")):(l.value="1",u("expand","collapse"))}const b=e.computed(()=>l.value==="1"?m("ap.apExpandAlert.expand"):m("ap.apExpandAlert.collapse")),c=e.ref(!0),y=e.computed(()=>l.value!=="1");function p(t){t?l.value="":l.value="1"}const k=e.ref(!1);function E(t){u("close",t),k.value=!0}e.watch(()=>r.data,()=>{l.value="",e.nextTick(()=>{if(s.value){const t=Number(s.value.clientHeight),o=Number(parseInt(s.value.style.lineHeight));t<o*Number(r.rows)&&y.value?c.value=!1:c.value=!0}})},{immediate:!0}),e.watch(()=>r.defaultExpand,t=>{t?e.nextTick(()=>{p(t)}):e.nextTick(()=>{p(t)})},{immediate:!0}),e.onMounted(()=>{e.watch(()=>r.contentStyle,t=>{i.isNil(t.lineHeight)||e.nextTick(()=>{const o=document.querySelector(`#${d} .ant-alert-action`),n=document.querySelector(`#${d} .ant-alert-icon`);o&&o.setAttribute("style",`line-height: ${t.lineHeight}`),n&&n.setAttribute("style",`line-height: ${t.lineHeight}`)})},{deep:!0,immediate:!0,flush:"post"})});const{b:h,e:a}=A.useNamespace("ap-expand-alert"),N=$.default("ap-expand-alert"),d=`${h()}-key-${Date.now()}-${(Math.random()*1e6).toFixed(0)}`;return g({setExpand:p}),(t,o)=>k.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,id:d,class:e.normalizeClass([e.unref(h)(),e.unref(N)])},[e.createVNode(e.unref(v.Alert),{type:S.value,"show-icon":t.showIcon,closable:t.closable,class:e.normalizeClass([e.unref(a)("antAlert"),t.type=="card"?"card-alert":""]),"after-close":t.afterClose,onClose:E},{action:e.withCtx(()=>[c.value?(e.openBlock(),e.createBlock(e.unref(T.ApActionItem),{key:0,size:"small",style:{"font-size":"12px","padding-left":"16px"},onClick:o[0]||(o[0]=n=>x())},{default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(a)("expandText"))},e.toDisplayString(b.value),3),e.createVNode(e.unref(z.DownOutlined),{class:e.normalizeClass(y.value?e.unref(a)("expandIcon"):e.unref(a)("collapseIcon"))},null,8,["class"])]),_:1})):e.createCommentVNode("",!0)]),message:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"ellipsisBoxRef",ref:s,style:e.normalizeStyle({...w.value,...t.contentStyle}),class:e.normalizeClass(e.unref(a)("alertContent"))},[e.renderSlot(t.$slots,"default",{},()=>[e.unref(i.isString)(t.prefix)?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(a)("prefix")),style:e.normalizeStyle(t.prefixStyle)},e.toDisplayString(t.prefix),7)):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.prefix),{key:1,style:e.normalizeStyle(t.prefixStyle)},null,8,["style"])),e.unref(i.isString)(t.data)?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(e.unref(a)("text"))},e.toDisplayString(t.data),3)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:3},e.renderList(t.data,(n,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:f},[e.createVNode(e.unref(v.Tooltip),{title:t.tipTitle?t.tipTitle:null},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"item",{record:n,index:f},()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(a)("showItem")),onClick:I=>t.$emit("choose",n)},e.toDisplayString(t.mapLabel?n[t.mapLabel]:n),11,V)])]),_:2},1032,["title"]),f!==t.data.length-1?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(a)("spliter")),style:e.normalizeStyle(t.separatorStyle)},[e.unref(i.isString)(t.separator)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.separator),1)],64)):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.separator),{key:1}))],6)):e.createCommentVNode("",!0)],64))),128))])],6)]),_:3},8,["type","show-icon","closable","class","after-close"])],2))}});exports.default=D;