acdr-ui/dist/build/mp-weixin/node-modules/wot-design-uni/components/wd-message-box/wd-message-box.js

2 lines
3.4 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";var e=Object.defineProperty,a=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,n=(a,t,l)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[t]=l;const r=require("../../../../common/vendor.js");if(!Array){(r.resolveComponent("wd-input")+r.resolveComponent("wd-button")+r.resolveComponent("wd-popup"))()}Math||((()=>"../wd-input/wd-input.js")+(()=>"../wd-button/wd-button.js")+(()=>"../wd-popup/wd-popup.js"))();const s=r.defineComponent((i=((e,a)=>{for(var t in a||(a={}))o.call(a,t)&&n(e,t,a[t]);if(l)for(var t of l(a))u.call(a,t)&&n(e,t,a[t]);return e})({},{name:"wd-message-box",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),v={props:r.messageBoxProps,setup(e){const a=e,{translate:t}=r.useTranslate("message-box"),l=r.computed((()=>`wd-message-box__container ${a.customClass}`)),o=r.computed((()=>`wd-message-box__body ${f.value?"":"is-no-title"} ${"prompt"===y.value?"is-prompt":""}`)),u=a.selector?r.messageDefaultOptionKey+a.selector:r.messageDefaultOptionKey,n=r.inject(u,r.ref(r.defaultOptions$1)),s=r.ref("");let i=null,v=null,c=null;const p=r.ref(!1),f=r.ref(""),m=r.ref(!1),d=r.ref(!0),b=r.ref(""),w=r.ref(""),y=r.ref("alert"),g=r.ref("text"),x=r.ref(""),h=r.ref(""),_=r.ref();let C=null;const O=r.ref(""),j=r.ref(!1),k=r.ref(99),P=r.ref(!0);function z(e){if(("modal"!==e||d.value)&&("prompt"!==y.value||"confirm"!==e||(_.value&&!_.value.test(String(x.value))?(j.value=!0,0):"function"!=typeof C||C(x.value)?(j.value=!1,1):(j.value=!0,0))))switch(e){case"confirm":c?c({resolve:a=>{a&&B({action:e,value:x.value})}}):B({action:e,value:x.value});break;case"cancel":D({action:e});break;default:D({action:"modal"})}}function B(e){p.value=!1,r.isFunction(i)&&i(e)}function D(e){p.value=!1,r.isFunction(v)&&v(e)}function V(e){""!==e?x.value=e:j.value=!1}return r.watch((()=>n.value),(e=>{var a;(a=e)&&(f.value=r.isDef(a.title)?a.title:"",m.value=!!r.isDef(a.showCancelButton)&&a.showCancelButton,p.value=a.show,d.value=a.closeOnClickModal,b.value=a.confirmButtonText,w.value=a.cancelButtonText,s.value=a.msg,y.value=a.type,g.value=a.inputType,x.value=a.inputValue,h.value=a.inputPlaceholder,_.value=a.inputPattern,C=a.inputValidate,i=a.onConfirm,v=a.onCancel,c=a.beforeConfirm,O.value=a.inputError,j.value=a.showErr,k.value=a.zIndex,P.value=a.lazyRender)}),{deep:!0,immediate:!0}),r.watch((()=>p.value),(e=>{!1===e&&(j.value=!1)}),{deep:!0,immediate:!0}),(e,a)=>r.e({a:f.value},f.value?{b:r.t(f.value)}:{},{c:"prompt"===y.value},"prompt"===y.value?r.e({d:r.o(V),e:r.o((e=>x.value=e)),f:r.p({type:g.value,size:"large",placeholder:h.value||"请输入",modelValue:x.value}),g:j.value},j.value?{h:r.t(O.value||r.unref(t)("inputNoValidate"))}:{}):{},{i:r.t(s.value),j:r.n(o.value),k:m.value},m.value?{l:r.t(w.value||r.unref(t)("cancel")),m:r.o((e=>z("cancel"))),n:r.p({type:"info",block:!0,"custom-style":"margin-right: 16px;"})}:{},{o:r.t(b.value||r.unref(t)("confirm")),p:r.o((e=>z("confirm"))),q:r.p({block:!0}),r:r.n("wd-message-box__actions "+(m.value?"wd-message-box__flex":"wd-message-box__block")),s:r.n(l.value),t:r.o((e=>z("modal"))),v:r.o((e=>p.value=e)),w:r.p({transition:"zoom-in","close-on-click-modal":d.value,"lazy-render":P.value,"custom-class":"wd-message-box","z-index":k.value,duration:200,modelValue:p.value})})}},a(i,t(v))));var i,v;const c=r._export_sfc(s,[["__scopeId","data-v-a548eda5"]]);wx.createComponent(c);