"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("@aplus-frontend/antdv"),E=require("../../../ap-field/index.js");require("../../../ap-form/ap-form.vue.js");require("../../../config-provider/index.js");const h=require("../../../config-provider/hooks/use-token.js");require("../../ap-tag/index.js");const S=require("../hooks/use-view-provide.js"),q=require("../icons/line-delete.vue.js"),g=require("../style/index.js"),m=require("../utils/enum.js"),K=require("../../../config-provider/hooks/use-namespace.js"),D=require("../../../config-provider/hooks/use-locale.js"),B=require("../../ap-tag/ap-tag.vue.js"),f=require("../../../ap-form/ap-form.vue2.js"),T={class:"menu-list-content-name"},b=["title"],M={key:0,class:"menu-list-content-default"},z={class:"menu-list-content-action-delete"},I={class:"menu-list-content-edit"},P=e.defineComponent({__name:"menu-list-content",props:{view:{}},setup(w){const{b:a}=K.useNamespace("ap-view"),c=g.default("ap-view"),{token:p}=h.useToken(),{t:i}=D.useLocale(),t=w,{currentViewKey:_,changeCurrentViewKey:V,viewListCRUD:r,tableKey:s,menuOpen:v}=S.useViewInject(),o=e.ref(!1),d=e.ref(),k=()=>{V(t.view.viewKey),v.value=!1},y=()=>{r?.changeView?.({...t.view,tableKey:s.value,isDefault:!0})},N=()=>{r?.removeView?.({tableKey:s.value,viewKey:t.view.viewKey})},C=async()=>{const l=await d.value?.validate?.();r?.changeView?.({...t.view,tableKey:s.value,viewName:l?.viewName||t.view.viewName}),o.value=!1};return e.watch(()=>v.value,l=>{l&&(o.value=!1)}),(l,n)=>o.value===!1?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass({[e.unref(a)()]:!0,[e.unref(a)("menu-list-content")]:!0,[e.unref(a)("menu-list-content-active")]:t.view?.viewKey===e.unref(_),[e.unref(c)]:!0}),onClick:k},[e.createElementVNode("div",T,[e.createElementVNode("span",{title:t.view?.viewName},e.toDisplayString(t.view?.viewName),9,b)]),t.view?.viewKey!==e.unref(m.SYSTEM_VIEW_KEY)&&t.view?.isDefault?(e.openBlock(),e.createElementBlock("div",M,[e.createVNode(e.unref(B.default),{text:e.unref(i)("ap.apView.default"),size:"small",color:e.unref(p).colorPrimary},null,8,["text","color"])])):e.createCommentVNode("",!0),t.view?.viewKey!==e.unref(m.SYSTEM_VIEW_KEY)?(e.openBlock(),e.createElementBlock("div",{key:1,class:"menu-list-content-action",onClick:n[1]||(n[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(e.unref(u.Space),{size:8},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"menu-list-content-action-text",onClick:n[0]||(n[0]=e.withModifiers(x=>o.value=!0,["stop"]))},e.toDisplayString(e.unref(i)("ap.apView.rename")),1),t.view?.isDefault?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"menu-list-content-action-text",onClick:y},e.toDisplayString(e.unref(i)("ap.apView.setDefault")),1)),e.createElementVNode("div",z,[e.createVNode(e.unref(u.Popconfirm),{title:e.unref(i)("ap.apView.deleteTip"),"ok-text":e.unref(i)("ap.apView.ok"),onConfirm:N},{default:e.withCtx(()=>[e.createVNode(q.default)]),_:1},8,["title","ok-text"])])]),_:1})])):e.createCommentVNode("",!0)],2)):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass([e.unref(a)("menu-list-content"),e.unref(a)("menu-list-content-edit"),e.unref(c)]),onClick:n[3]||(n[3]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(f.default,{ref_key:"formRef",ref:d,"initial-values":{viewName:t.view?.viewName}},{default:e.withCtx(()=>[e.createElementVNode("div",I,[e.createVNode(e.unref(u.Space),{size:8},{default:e.withCtx(()=>[e.createVNode(f.default.FormItem,{name:"viewName"},{default:e.withCtx(()=>[e.createVNode(e.unref(E.ApField).Text,{maxlength:20})]),_:1}),e.createElementVNode("div",{class:"menu-list-content-action-text",onClick:C},e.toDisplayString(e.unref(i)("ap.apView.save")),1),e.createElementVNode("div",{class:"menu-list-content-action-text",onClick:n[2]||(n[2]=x=>o.value=!1)},e.toDisplayString(e.unref(i)("ap.apView.cancel")),1)]),_:1})])]),_:1},8,["initial-values"])],2))}});exports.default=P;
