k5web/assets/dialog.096f98d5.js

51 lines
22 KiB
JavaScript
Raw Normal View History

2024-06-18 13:24:23 +00:00
import{t as Qe,_,u as ae}from"./useConfig.d327f413.js";import{h as qe,c as d,d as F,f as k,p as en,bC as nn,aI as p,bB as x,g as tn,w as Oe,o as _e,b as we,z as an,n as rn,bx as on,bn as re,bo as ln,bD as cn,bE as sn}from"./arco.949c921a.js";import{d as Se,Q as un,S as fn,T as vn,U as dn,V as mn,M as gn,W as pn,X as hn,Y as yn,Z as bn,$ as Cn,a0 as On,c as Ee,e as oe,N as W,F as K,b as _n}from"./index.e6d2773f.js";import{_ as Pe,a as wn,b as Sn,u as En}from"./index.558bb9f9.js";import{B as U}from"./index.23e0bd06.js";import{b as Pn}from"./helper.e26b6fe1.js";function N(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function le(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);e&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,a)}return t}function ie(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?le(Object(t),!0).forEach(function(a){N(n,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):le(Object(t)).forEach(function(a){Object.defineProperty(n,a,Object.getOwnPropertyDescriptor(t,a))})}return n}function Bn(n){var e=["fillOpacity","fillRule","clipRule"];return e.includes(n)?n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase():n}function D(n,e){var t=Object.keys(n.attrs).reduce((a,r)=>(a[Bn(r)]=n.attrs[r],a),{});return qe(n.tag,ie(ie({},t),e),(n.children||[]).map(a=>D(a,{})))}var kn="t",jn="zh-CN",Fn={classPrefix:kn,locale:jn};const Nn=Fn;function Dn(){var{classPrefix:n}=Nn;return{SIZE:{default:"",xs:"".concat(n,"-size-xs"),small:"".concat(n,"-size-s"),medium:"".concat(n,"-size-m"),large:"".concat(n,"-size-l"),xl:"".concat(n,"-size-xl"),block:"".concat(n,"-size-full-width")},STATUS:{loading:"".concat(n,"-is-loading"),disabled:"".concat(n,"-is-disabled"),focused:"".concat(n,"-is-focused"),success:"".concat(n,"-is-success"),error:"".concat(n,"-is-error"),warning:"".concat(n,"-is-warning"),selected:"".concat(n,"-is-selected"),active:"".concat(n,"-is-active"),checked:"".concat(n,"-is-checked"),current:"".concat(n,"-is-current"),hidden:"".concat(n,"-is-hidden"),visible:"".concat(n,"-is-visible"),expanded:"".concat(n,"-is-expanded"),indeterminate:"".concat(n,"-is-indeterminate")}}}function M(n){var e=Dn().SIZE,t=d(()=>n.value in e?e[n.value]:""),a=d(()=>n.value===void 0||n.value in e?{}:{fontSize:n.value});return{style:a,className:t}}function ce(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);e&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,a)}return t}function se(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ce(Object(t),!0).forEach(function(a){N(n,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):ce(Object(t)).forEach(function(a){Object.defineProperty(n,a,Object.getOwnPropertyDescriptor(t,a))})}return n}var Ln={tag:"svg",attrs:{fill:"none",viewBox:"0 0 24 24",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12 23a11 11 0 100-22 11 11 0 000 22zM7.5 10.59l3 3 6-6L17.91 9l-7.41 7.41L6.09 12l1.41-1.41z"}}]},xn=F({name:"CheckCircleFilledIcon",props:{size:{type:String},onClick:{type:Function}},setup(n,e){var{attrs:t}=e,a=d(()=>n.size),{className:r,style:i}=M(a),m=d(()=>["t-icon","t-icon-check-circle-filled",r.value]),u=d(()=>se(se({},i.value),t.style)),f=d(()=>({class:m.value,style:u.value,onClick:c=>{var o;return(o=n.onClick)===null||o===void 0?void 0:o.call(n,{e:c})}}));return()=>D(Ln,f.value)}});const Mn=xn;function ue(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);e&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,a)}return t}function fe(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ue(Object(t),!0).forEach(function(a){
2024-06-15 00:08:13 +00:00
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Xn(n){var e=Se("icon"),t=e.globalConfig,a={};return Object.keys(n).forEach(function(r){var i;a[r]=((i=t.value)===null||i===void 0?void 0:i[r])||n[r]}),a}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var Gn="t-display-none-element-refresh";function Rn(){var n=k(0);en(Gn,n),nn(function(){n.value+=1})}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Zn(n){var e=n==null?0:n.length;return e?n[e-1]:void 0}var Vn=Zn;/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var pe=un,Yn=mn,Jn=gn,he=pe?pe.isConcatSpreadable:void 0;function Qn(n){return Jn(n)||Yn(n)||!!(he&&n&&n[he])}var qn=Qn,et=dn,nt=qn;function Be(n,e,t,a,r){var i=-1,m=n.length;for(t||(t=nt),r||(r=[]);++i<m;){var u=n[i];e>0&&t(u)?e>1?Be(u,e-1,t,a,r):et(r,u):a||(r[r.length]=u)}return r}var tt=Be,at=tt;function rt(n){var e=n==null?0:n.length;return e?at(n,1):[]}var ot=rt,lt=ot,it=fn,ct=vn;function st(n){return ct(it(n,void 0,lt),n+"")}var ut=st;/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var ft=Sn,vt=Cn;function dt(n,e){return e.length<2?n:ft(n,vt(e,0,-1))}var mt=dt,gt=Pe,pt=Vn,ht=mt,yt=wn;function bt(n,e){return e=gt(e,n),n=ht(n,e),n==null||delete n[yt(pt(e))]}var Ct=bt,Ot=On;function _t(n){return Ot(n)?void 0:n}var wt=_t,St=pn,Et=bn,Pt=Ct,Bt=Pe,kt=hn,jt=wt,Ft=ut,Nt=yn,Dt=1,Lt=2,xt=4,Mt=Ft(function(n,e){var t={};if(n==null)return t;var a=!1;e=St(e,function(i){return i=Bt(i,n),a||(a=i.length>1),i}),kt(n,Nt(n),t),a&&(t=Et(t,Dt|Lt|xt,jt));for(var r=e.length;r--;)Pt(t,e[r]);return t}),At=Mt;/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function It(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function ye(n,e){for(var t=0;t<e.length;t++){var a=e[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,Qe(a.key),a)}}function Tt(n,e,t){return e&&ye(n.prototype,e),t&&ye(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var $t={attach:{type:[String,Function]},body:{type:[String,Function]},cancelBtn:{type:[String,Object,Function]},closeBtn:{type:[String,Boolean,Function],default:!0},closeOnEscKeydown:{type:Boolean,default:void 0},closeOnOverlayClick:{type:Boolean,default:void 0},confirmBtn:{type:[String,Object,Function]},confirmLoading:{type:Boolean,default:void 0},confirmOnEnter:Boolean,default:{type:[String,Function]},destroyOnClose:Boolean,draggable:Boolean,footer:{type:[Boolean,Function],default:!0},header:{type:[String,Boolean,Function],default:!0},mode:{type:String,default:"modal",validator:function(e){return e?["modal","modeless","normal","full-screen"].includes(e):!0}},placement:{type:String,default:"top",validator:function(e){return e?["top","center"].includes(e):!0}},preventScrollThrough:{type:Boolean,default:!0},showInAttachedElement:Boolean,showOverlay:{type:Boolean,default:!0},theme:{type:String,default:"default",validator:function(e){return e?["default","info","warning","danger","success"].includes(e):!0}},top:{type:[String,Number]},visible:Boolean,width:{type:[String,Number]},zIndex:{type:Number},onCancel:Function,onClose:Function,onCloseBtnClick:Function,onClosed:Function,onConfirm:Function,onEscKeydown:Function,onOpened:Function,onOverlayClick:Function};/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function be(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);e&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,a)}return t}function E(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?be(Object(t),!0).forEach(function(a){_(n,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):be(Object(t)).forEach(function(a){Object.defineProperty(n,a,Object.getOwnPropertyDescriptor(t,a))})}return n}function zt(n){var e=tn(),t=Ee(),a=function(c){var o,g=c.globalConfirm,h=c.theme,y=c.globalConfirmBtnTheme,O=((o=At(y,["info"]))===null||o===void 0?void 0:o[h])||"primary",w={theme:O,size:c.size,onClick:function(A){n.confirmBtnAction(A)}};return W(g)?w.content=g:K(g)&&(w=E(E({},w),g)),w},r=function(c){var o=c.globalCancel,g={theme:"default",size:c.size,onClick:function(y){n.cancelBtnAction(y)}};return W(o)?g.content=o:K(o)&&(g=E(E({},g),o)),g},i=function(c,o){var g=o.defaultButtonProps,h=o.className,y=o.confirmLoading,O=g;return W(c)?O.content=c:K(c)&&(O=E(E({},O),c)),y!==void 0&&(O.loading=y),p(U,x({class:h},O),null)},m=function(c){var o=c.confirmBtn,g=c.className,h=c.confirmLoading;if(o===null)return null;o&&e.slots.confirmBtn&&console.warn("Both $props.confirmBtn and $scopedSlots.confirmBtn exist, $props.confirmBtn is preferred.");var y=a(c);return!o&&!e.slots.confirmBtn?p(U,x({class:g,loading:h},y),null):o&&["string","object"].includes(oe(o))?i(o,{defaultButtonProps:y,className:g,confirmLoading:h}):t("confirmBtn")},u=function(c){var o=c.cancelBtn,g=c.className;if(o===null)return null;o&&e.slots.cancelBtn&&console.warn("Both $props.cancelBtn and $scopedSlots.cancelBtn exist, $props.cancelBtn is preferred.");var h=r(c);return!o&&!e.slots.cancelBtn?p(U,x({class:g},h),null):o&&["string","object"].includes(oe(o))?i(o,{defaultButtonProps:h}):t("cancelBtn")};return{getConfirmBtn:m,getCancelBtn:u}}function Wt(n){var e=!1,t=!1,a=function(u){e&&t&&n(u),e=!1,t=!1},r=function(u){e=u.target===u.currentTarget},i=function(u){t=u.target===u.currentTarget};return{onClick:a,onMousedown:r,onMouseup:i}}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function ra(){var n=6;if(typeof navigator>"u"||!navigator||/(Chrome|Safari)/i.test(navigator.userAgent))return n;var e=document.createElement("div");e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),/Firefox/.test(navigator.userAgent)&&(t-=4),Pn()<=11&&(t=12),t}function Kt(){var n=document.createElement("div");n.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(n);var e=n.offsetWidth-n.clientWidth;return document.body.removeChild(n),e}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var Ut=1e3,Ht=5e3,Xt=1,Gt=Tt(function n(){var e=this;It(this,n),_(this,"popupStack",{popup:new Set,dialog:new Set,message:new Set}),_(this,"getNextZIndex",function(t){var a=t==="message"?Array.from(e.popupStack.message).pop()||Ht:Array.from(e.popupStack.popup).pop()||Ut;return a+Xt}),_(this,"add",function(t){var a=e.getNextZIndex(t);return e.popupStack[t].add(a),t==="dialog"&&e.popupStack.popup.add(a),a}),_(this,"delete",function(t,a){e.popupStack[a].delete(t),a==="dialog"&&e.popupStack.popup.delete(t)}),_(this,"isLastDialog",function(t){return e.popupStack.dialog.size>1?t===Array.from(e.popupStack.dialog).pop():!0})}),H=new Gt;function Rt(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.visible,a=e.runOnMounted,r=k(0),i=function(){r.value=H.add(n)},m=function(){H.delete(r.value,n)},u=function(){return n==="dialog"?H.isLastDialog(r.value):!1};return Oe(function(){return t==null?void 0:t.value},function(f){f?i():m()},{immediate:!0}),a&&(_e(function(){i()}),we(function(){m()})),{zIndex:an(r),open:i,close:m,isLastDialog:u}}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Ce(n){return Number.isNaN(Number(n))?n:"".concat(Number(n),"px")}var j,Zt=function(e){j={x:e.clientX,y:e.clientY},setTimeout(function(){j=null},100)};typeof window<"u"&&window.document&&window.document.documentElement&&document.documentElement.addEventListener("click",Zt,!0);function Vt(n){var e=n,t=window.innerWidth||document.documentElement.clientWidth,a=window.innerHeight||document.documentElement.clientHeight;e.addEventListener("mousedown",function(r){var i=r.clientX-e.offsetLeft,m=r.clientY-e.offsetTop,u=e.offsetWidth,f=e.offsetHeight;if(u>t||f>a)return;function c(g){var h=g.clientX-i,y=g.clientY-m;h<0&&(h=0),y<0&&(y=0),t-e.offsetWidth-h<0&&(h=t-e.offsetWidth),a-e.offsetHeight-y<0&&(y=a-e.offsetHeight),e.style.position="absolute",e.style.left="".concat(h,"px"),e.style.top="".concat(y,"px")}function o(){document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",o)}document.addEventListener("mousemove",c),document.addEventListener("mouseup",o),document.addEventListener("dragend",o)})}var Yt=1,oa=F({name:"TDialog",directives:{draggable:function(e,t){e&&t&&t.value&&Vt(e)}},inheritAttrs:!1,props:$t,emits:["update:visible"],setup:function(e,t){var a=this,r=ae("dialog"),i=ae(),m=_n(),u=Ee(),f=k(null),c=Se("dialog"),o=c.globalConfig,g=Xn({CloseIcon:Tn,InfoCircleFilledIcon:Hn,CheckCircleFilledIcon:Mn,ErrorCircleFilledIcon:Wn}),h=g.CloseIcon,y=g.InfoCircleFilledIcon,O=g.CheckCircleFilledIcon,w=g.ErrorCircleFilledIcon,X=function(l){var s;(s=e.onConfirm)===null||s===void 0||s.call(e,{e:l})},A=function(l){var s;(s=e.onCancel)===null||s===void 0||s.call(e,{e:l}),L({e:l,trigger:"cancel"})},G=zt({confirmBtnAction:X,cancelBtnAction:A}),ke=G.getConfirmBtn,je=G.getCancelBtn,Fe=En(function(){return e.attach});Rn();var R=k(),S=k(),Z=d(function(){return e.mode==="modal"}),P=d(function(){return e.mode==="modeless"}),V=d(function(){return e.mode==="normal"}),C=d(function(){return e.mode==="full-screen"}),Ne=d(function(){return e.visible}),De=d(function(){return["".concat(r.value,"__mask"),!e.showOverlay&&"".concat(i.value,"-is-hidden")]}),Le=d(function(){return V.value?[]:C.value?["".concat(r.value,"__position_fullscreen")]:["".concat(r.value,"__position"),!!e.top&&"".concat(r.value,"--top"),"".concat(e.placement&&!e.top?"".concat(r.value,"--").concat(e.placement):"")]}),xe=d(function(){return[!V.value&&"".concat(r.value,"__wrap")]}),Me=d(function(){if(C.value)return{};var v=e.top,l={};if(v!==void 0){var s=Ce(v);l={paddingTop:s}}return l}),Y=d(function(){var v=["".concat(r.value),"".concat(r.value,"__modal-").concat(e.theme),P.value&&e.draggable&&"".concat(r.value,"--draggable")];return C.value?v.push("".concat(r.value,"__fullscreen")):v.push.apply(v,["".concat(r.value,"--default"),"".concat(r.value,"--").concat(e.placement)]),v}),J=d(function(){return C.value?{}:{width:Ce(e.width)}}),Ae=Rt("dialog",{visible:Ne}),Q=Ae.isLastDialog;Oe(function(){return e.visible},function(v){if(v){var l;(Z.value&&!e.showInAttachedElement||C.value)&&(e.preventScrollThrough&&document.body.appendChild(S.value),rn(function(){j&&f.value&&(f.value.style.transformOrigin="".concat(j.x-f.value.offsetLeft,"px ").concat(j.y-f.value.offsetTop,"px"))})),(l=document.activeElement)===null||l===void 0||l.blur()}else Ie();ee(v)});function q(){var v,l;(v=S.value.parentNode)===null||v===void 0||(l=v.removeChild)===null||l===void 0||l.call(v,S.value)}function Ie(){clearTimeout(R.value),R.value=setTimeout(function(){q()},150)}var ee=function(l){l?(document.addEventListener("keydown",te),e.confirmOnEnter&&document.addEventListener("keydown",ne)):(document.removeEventListener("keydown",te),e.confirmOnEnter&&document.removeEventListener("keydown",ne))},ne=function(l){var s=l.target;if(s.tagName.toLowerCase()!=="input"){var b=l.code;if((b==="Enter"||b==="NumpadEnter")&&Q()){var B;(B=e.onConfirm)===null||B===void 0||B.call(e,{e:l})}}},te=function(l){if(l.code==="Escape"&&Q()){var s,b;(s=e.onEscKeydown)===null||s===void 0||s.call(e,{e:l}),((b=e.closeOnEscKeydown)!==null&&b!==void 0?b:o.value.closeOnEscKeydown)&&L({e:l,trigger:"esc"})}},Te=function
html body {
overflow-y: hidden;
width: calc(100% - `.concat(l,`px);
}
`)}),we(function(){ee(!1),q()}),{COMPONENT_NAME:r,isModal:Z,isModeLess:P,isFullScreen:C,maskClass:De,dialogClass:Y,dialogStyle:J,dialogEle:f,afterEnter:Ue,afterLeave:He,hasEventOn:Xe,renderDialog:Re,teleportElement:Fe}},render:function(){var e=this,t=this.COMPONENT_NAME,a=(this.isModal||this.isFullScreen)&&p("div",{key:"mask",class:this.maskClass},null),r=this.renderDialog(),i=[a,r],m={zIndex:this.zIndex},u=["".concat(t,"__ctx"),_(_(_({},"".concat(t,"__ctx--fixed"),this.isModal||this.isFullScreen),"".concat(t,"__ctx--absolute"),this.isModal&&this.showInAttachedElement),"".concat(t,"__ctx--modeless"),this.isModeLess)];return p(cn,{disabled:!this.attach||!this.teleportElement,to:this.teleportElement},{default:function(){return[p(on,{duration:300,name:"".concat(t,"-zoom__vue"),onAfterEnter:e.afterEnter,onAfterLeave:e.afterLeave},{default:function(){return[(!e.destroyOnClose||e.visible)&&re(p("div",x({class:u,style:m},e.$attrs),[i]),[[ln,e.visible]])]}})]}})}});export{Mn as C,Wn as E,N as _,Xn as a,oa as b,ut as c,Tn as d,tt as e,Tt as f,ra as g,It as h,Rt as i,zt as j,Kt as k,Vn as l,At as o,D as r,M as u};