UNPKG

chaite

Version:

core for chatgpt-plugin and karin-plugin-chatgpt

17 lines (16 loc) 4.17 kB
import{aK as O,d as y,aZ as h,G as a,B as m,aP as S,a9 as B,an as w,ac as P,ab as _,aL as R,ag as I,ah as C,O as f,bL as $,a8 as x,b0 as g,ar as b,X as F,c9 as K,bG as L,ae as j,ca as U,b4 as E,j as V,aj as k,cb as q}from"./index-D3SoE8bB.js";const z=O("n-popconfirm"),N={positiveText:String,negativeText:String,showIcon:{type:Boolean,default:!0},onPositiveClick:{type:Function,required:!0},onNegativeClick:{type:Function,required:!0}},T=$(N),G=y({name:"NPopconfirmPanel",props:N,setup(o){const{localeRef:n}=P("Popconfirm"),{inlineThemeDisabled:s}=_(),{mergedClsPrefixRef:t,mergedThemeRef:v,props:r}=R(z),u=f(()=>{const{common:{cubicBezierEaseInOut:e},self:{fontSize:l,iconSize:c,iconColor:d}}=v.value;return{"--n-bezier":e,"--n-font-size":l,"--n-icon-size":c,"--n-icon-color":d}}),i=s?I("popconfirm-panel",void 0,u,r):void 0;return Object.assign(Object.assign({},P("Popconfirm")),{mergedClsPrefix:t,cssVars:s?void 0:u,localizedPositiveText:f(()=>o.positiveText||n.value.positiveText),localizedNegativeText:f(()=>o.negativeText||n.value.negativeText),positiveButtonProps:C(r,"positiveButtonProps"),negativeButtonProps:C(r,"negativeButtonProps"),handlePositiveClick(e){o.onPositiveClick(e)},handleNegativeClick(e){o.onNegativeClick(e)},themeClass:i?.themeClass,onRender:i?.onRender})},render(){var o;const{mergedClsPrefix:n,showIcon:s,$slots:t}=this,v=h(t.action,()=>this.negativeText===null&&this.positiveText===null?[]:[this.negativeText!==null&&a(m,Object.assign({size:"small",onClick:this.handleNegativeClick},this.negativeButtonProps),{default:()=>this.localizedNegativeText}),this.positiveText!==null&&a(m,Object.assign({size:"small",type:"primary",onClick:this.handlePositiveClick},this.positiveButtonProps),{default:()=>this.localizedPositiveText})]);return(o=this.onRender)===null||o===void 0||o.call(this),a("div",{class:[`${n}-popconfirm__panel`,this.themeClass],style:this.cssVars},S(t.default,r=>s||r?a("div",{class:`${n}-popconfirm__body`},s?a("div",{class:`${n}-popconfirm__icon`},h(t.icon,()=>[a(B,{clsPrefix:n},{default:()=>a(w,null)})])):null,r):null),v?a("div",{class:[`${n}-popconfirm__action`]},v):null)}}),M=x("popconfirm",[g("body",` font-size: var(--n-font-size); display: flex; align-items: center; flex-wrap: nowrap; position: relative; `,[g("icon",` display: flex; font-size: var(--n-icon-size); color: var(--n-icon-color); transition: color .3s var(--n-bezier); margin: 0 8px 0 0; `)]),g("action",` display: flex; justify-content: flex-end; `,[b("&:not(:first-child)","margin-top: 8px"),x("button",[b("&:not(:last-child)","margin-right: 8px;")])])]),W=Object.assign(Object.assign(Object.assign({},j.props),q),{positiveText:String,negativeText:String,showIcon:{type:Boolean,default:!0},trigger:{type:String,default:"click"},positiveButtonProps:Object,negativeButtonProps:Object,onPositiveClick:Function,onNegativeClick:Function}),H=y({name:"Popconfirm",props:W,slots:Object,__popover__:!0,setup(o){const{mergedClsPrefixRef:n}=_(),s=j("Popconfirm","-popconfirm",M,U,o,n),t=V(null);function v(i){var e;if(!(!((e=t.value)===null||e===void 0)&&e.getMergedShow()))return;const{onPositiveClick:l,"onUpdate:show":c}=o;Promise.resolve(l?l(i):!0).then(d=>{var p;d!==!1&&((p=t.value)===null||p===void 0||p.setShow(!1),c&&k(c,!1))})}function r(i){var e;if(!(!((e=t.value)===null||e===void 0)&&e.getMergedShow()))return;const{onNegativeClick:l,"onUpdate:show":c}=o;Promise.resolve(l?l(i):!0).then(d=>{var p;d!==!1&&((p=t.value)===null||p===void 0||p.setShow(!1),c&&k(c,!1))})}return E(z,{mergedThemeRef:s,mergedClsPrefixRef:n,props:o}),{setShow(i){var e;(e=t.value)===null||e===void 0||e.setShow(i)},syncPosition(){var i;(i=t.value)===null||i===void 0||i.syncPosition()},mergedTheme:s,popoverInstRef:t,handlePositiveClick:v,handleNegativeClick:r}},render(){const{$slots:o,$props:n,mergedTheme:s}=this;return a(F,Object.assign({},K(n,T),{theme:s.peers.Popover,themeOverrides:s.peerOverrides.Popover,internalExtraClass:["popconfirm"],ref:"popoverInstRef"}),{trigger:o.trigger,default:()=>{const t=L(n,T);return a(G,Object.assign({},t,{onPositiveClick:this.handlePositiveClick,onNegativeClick:this.handleNegativeClick}),o)}})}});export{H as N};