UNPKG

vue-amazing-ui

Version:

An Amazing Vue3 UI Components Library, Using TypeScript.

2 lines (1 loc) 12.4 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),g=require("../scrollbar/index.cjs"),c=require("../button/index.cjs"),E={class:"m-dialog-root"},b={focusable:"false","data-icon":"fullscreen",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},T={focusable:"false","data-icon":"fullscreen-exit",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},P={key:1,class:"dialog-footer"},$={focusable:"false","data-icon":"fullscreen",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},D={focusable:"false","data-icon":"fullscreen-exit",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},O={key:1,class:"dialog-footer"},M=e.defineComponent({__name:"Dialog",props:{width:{default:520},height:{default:"auto"},title:{default:void 0},titleStyle:{default:()=>({})},content:{default:void 0},contentStyle:{default:()=>({})},bodyClass:{default:void 0},bodyStyle:{default:()=>({})},scrollbarProps:{default:()=>({})},cancelText:{default:"取消"},cancelProps:{default:()=>({})},okText:{default:"确定"},okType:{default:"primary"},okProps:{default:()=>({})},footer:{type:Boolean,default:!0},destroyOnClose:{type:Boolean,default:!1},switchFullscreen:{type:Boolean,default:!1},centered:{type:Boolean,default:!1},top:{default:100},transformOrigin:{default:"mouse"},confirmLoading:{type:Boolean,default:!1},blockScroll:{type:Boolean,default:!0},keyboard:{type:Boolean,default:!0},maskClosable:{type:Boolean,default:!0},maskStyle:{default:()=>({})},open:{type:Boolean,default:!1}},emits:["update:open","cancel","ok"],setup(L,{emit:w}){const o=L,f=e.ref(),r=e.ref(null),n=e.ref(),d=e.ref(),i=e.ref("50% 50%"),a=e.ref(!1),u=w,m=e.computed(()=>typeof o.width=="number"?`${o.width}px`:o.width),k=e.computed(()=>typeof o.height=="number"?`${o.height}px`:o.height),C=e.computed(()=>typeof o.top=="number"?`${o.top}px`:o.top),S=e.computed(()=>{var t,l;return a.value?o.transformOrigin==="mouse"?{width:"100%",transformOrigin:`${(t=r.value)==null?void 0:t.x}px ${(l=r.value)==null?void 0:l.y}px`}:{width:"100%",transformOrigin:i.value}:o.centered?{width:m.value,transformOrigin:i.value}:{width:m.value,transformOrigin:i.value,top:C.value}}),v=e.computed(()=>a.value?{height:"100vh",...o.bodyStyle}:{height:k.value,...o.bodyStyle});e.watch(n,async t=>{t?(await e.nextTick(),f.value.focus(),o.blockScroll&&(document.documentElement.style.overflowY="hidden",document.body.style.overflowY="hidden")):o.blockScroll&&(document.documentElement.style.removeProperty("overflow-y"),document.body.style.removeProperty("overflow-y"))},{immediate:!0}),e.watchEffect(()=>{n.value=o.open}),e.onMounted(()=>{document.addEventListener("click",p,!0)}),e.onUnmounted(()=>{document.removeEventListener("click",p,!0)});function p(t){n.value||(r.value={x:t.clientX,y:t.clientY})}async function z(t){if(d.value=!0,await e.nextTick(),o.transformOrigin==="mouse"&&r.value){const l=t.getBoundingClientRect();i.value=`${r.value.x-l.left}px ${r.value.y-l.top}px`}else i.value="50% 50%"}function B(t){if(o.transformOrigin==="mouse"&&r.value){const l=t.getBoundingClientRect();i.value=`${r.value.x-l.left}px ${r.value.y-l.top}px`}else i.value="50% 50%"}function N(){d.value=!1,a.value=!1}function y(){a.value=!a.value}function s(){n.value=!1,u("update:open",!1),u("cancel")}function h(){u("ok")}return(t,l)=>(e.openBlock(),e.createElementBlock("div",E,[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:"dialog-mask",style:e.normalizeStyle(t.maskStyle)},null,4),[[e.vShow,n.value]])]),_:1}),e.withDirectives(e.createElementVNode("div",{tabindex:"-1",ref_key:"dialogRef",ref:f,class:e.normalizeClass(["m-dialog-wrap",{"flex-centered":t.centered}]),onClick:l[0]||(l[0]=e.withModifiers(V=>o.maskClosable?s():()=>!1,["self"])),onKeydown:l[1]||(l[1]=e.withKeys(V=>o.keyboard?s():()=>!1,["esc"]))},[e.createVNode(e.Transition,{name:"zoom","enter-from-class":"zoom-enter","enter-active-class":"zoom-enter","enter-to-class":"zoom-enter zoom-enter-active","leave-from-class":"zoom-leave","leave-active-class":"zoom-leave zoom-leave-active","leave-to-class":"zoom-leave zoom-leave-active",onBeforeEnter:z,onBeforeLeave:B,onAfterLeave:N},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["m-dialog",{"dialog-with-fullscreen":a.value}]),style:e.normalizeStyle(S.value)},[t.destroyOnClose?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["dialog-body-wrap",t.bodyClass]),style:e.normalizeStyle(v.value)},[e.createElementVNode("div",{class:e.normalizeClass(["dialog-header",{"header-with-switch":t.switchFullscreen}]),style:e.normalizeStyle(t.titleStyle)},[e.renderSlot(t.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)],!0)],6),t.switchFullscreen?(e.openBlock(),e.createElementBlock("span",{key:0,class:"fullscreen-action",onClick:y},[e.withDirectives((e.openBlock(),e.createElementBlock("svg",b,l[2]||(l[2]=[e.createElementVNode("path",{d:"M290 236.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L169 160c-5.1-.6-9.5 3.7-8.9 8.9L179 329.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L370 423.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L290 236.4zm352.7 187.3c3.1 3.1 8.2 3.1 11.3 0l133.7-133.6 43.7 43.7a8.01 8.01 0 0013.6-4.7L863.9 169c.6-5.1-3.7-9.5-8.9-8.9L694.8 179c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L600.3 370a8.03 8.03 0 000 11.3l42.4 42.4zM845 694.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L654 600.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L734 787.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L855 864c5.1.6 9.5-3.7 8.9-8.9L845 694.9zm-463.7-94.6a8.03 8.03 0 00-11.3 0L236.3 733.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L160.1 855c-.6 5.1 3.7 9.5 8.9 8.9L329.2 845c6.6-.8 9.4-8.9 4.7-13.6L290 787.6 423.7 654c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.4z"},null,-1)]),512)),[[e.vShow,!a.value]]),e.withDirectives((e.openBlock(),e.createElementBlock("svg",T,l[3]||(l[3]=[e.createElementVNode("path",{d:"M391 240.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L200 146.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L280 333.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L401 410c5.1.6 9.5-3.7 8.9-8.9L391 240.9zm10.1 373.2L240.8 633c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L146.3 824a8.03 8.03 0 000 11.3l42.4 42.3c3.1 3.1 8.2 3.1 11.3 0L333.7 744l43.7 43.7A8.01 8.01 0 00391 783l18.9-160.1c.6-5.1-3.7-9.4-8.8-8.8zm221.8-204.2L783.2 391c6.6-.8 9.4-8.9 4.7-13.6L744 333.6 877.7 200c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.3a8.03 8.03 0 00-11.3 0L690.3 279.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L614.1 401c-.6 5.2 3.7 9.5 8.8 8.9zM744 690.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L623 614c-5.1-.6-9.5 3.7-8.9 8.9L633 783.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L824 877.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L744 690.4z"},null,-1)]),512)),[[e.vShow,a.value]])])):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"close-action",onClick:s},l[4]||(l[4]=[e.createElementVNode("svg",{width:"1em",height:"1em",fill:"currentColor",viewBox:"64 64 896 896","data-icon":"close","aria-hidden":"true",focusable:"false"},[e.createElementVNode("path",{d:"M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"})],-1)])),e.createVNode(e.unref(g.default),e.normalizeProps(e.guardReactiveProps(t.scrollbarProps)),{default:e.withCtx(()=>[e.createElementVNode("div",{class:"dialog-content",style:e.normalizeStyle(t.contentStyle)},[e.renderSlot(t.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.content),1)],!0)],4)]),_:3},16),t.footer?(e.openBlock(),e.createElementBlock("div",P,[e.renderSlot(t.$slots,"footer",{},()=>[e.createVNode(e.unref(c.default),e.mergeProps({class:"mr8",onClick:s},t.cancelProps),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.cancelText),1)]),_:1},16),e.createVNode(e.unref(c.default),e.mergeProps({type:t.okType,loading:o.confirmLoading,onClick:h},t.okProps),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.okText),1)]),_:1},16,["type","loading"])],!0)])):e.createCommentVNode("",!0)],6)),t.destroyOnClose&&n.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["dialog-body-wrap",t.bodyClass]),style:e.normalizeStyle(v.value)},[e.createElementVNode("div",{class:e.normalizeClass(["dialog-header",{"header-with-switch":t.switchFullscreen}]),style:e.normalizeStyle(t.titleStyle)},[e.renderSlot(t.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)],!0)],6),t.switchFullscreen?(e.openBlock(),e.createElementBlock("span",{key:0,class:"fullscreen-action",onClick:y},[e.withDirectives((e.openBlock(),e.createElementBlock("svg",$,l[5]||(l[5]=[e.createElementVNode("path",{d:"M290 236.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L169 160c-5.1-.6-9.5 3.7-8.9 8.9L179 329.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L370 423.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L290 236.4zm352.7 187.3c3.1 3.1 8.2 3.1 11.3 0l133.7-133.6 43.7 43.7a8.01 8.01 0 0013.6-4.7L863.9 169c.6-5.1-3.7-9.5-8.9-8.9L694.8 179c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L600.3 370a8.03 8.03 0 000 11.3l42.4 42.4zM845 694.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L654 600.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L734 787.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L855 864c5.1.6 9.5-3.7 8.9-8.9L845 694.9zm-463.7-94.6a8.03 8.03 0 00-11.3 0L236.3 733.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L160.1 855c-.6 5.1 3.7 9.5 8.9 8.9L329.2 845c6.6-.8 9.4-8.9 4.7-13.6L290 787.6 423.7 654c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.4z"},null,-1)]),512)),[[e.vShow,!a.value]]),e.withDirectives((e.openBlock(),e.createElementBlock("svg",D,l[6]||(l[6]=[e.createElementVNode("path",{d:"M391 240.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L200 146.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L280 333.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L401 410c5.1.6 9.5-3.7 8.9-8.9L391 240.9zm10.1 373.2L240.8 633c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L146.3 824a8.03 8.03 0 000 11.3l42.4 42.3c3.1 3.1 8.2 3.1 11.3 0L333.7 744l43.7 43.7A8.01 8.01 0 00391 783l18.9-160.1c.6-5.1-3.7-9.4-8.8-8.8zm221.8-204.2L783.2 391c6.6-.8 9.4-8.9 4.7-13.6L744 333.6 877.7 200c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.3a8.03 8.03 0 00-11.3 0L690.3 279.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L614.1 401c-.6 5.2 3.7 9.5 8.8 8.9zM744 690.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L623 614c-5.1-.6-9.5 3.7-8.9 8.9L633 783.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L824 877.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L744 690.4z"},null,-1)]),512)),[[e.vShow,a.value]])])):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"close-action",onClick:s},l[7]||(l[7]=[e.createElementVNode("svg",{width:"1em",height:"1em",fill:"currentColor",viewBox:"64 64 896 896","data-icon":"close","aria-hidden":"true",focusable:"false"},[e.createElementVNode("path",{d:"M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"})],-1)])),e.createVNode(e.unref(g.default),e.normalizeProps(e.guardReactiveProps(t.scrollbarProps)),{default:e.withCtx(()=>[e.createElementVNode("div",{class:"dialog-content",style:e.normalizeStyle(t.contentStyle)},[e.renderSlot(t.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.content),1)],!0)],4)]),_:3},16),t.footer?(e.openBlock(),e.createElementBlock("div",O,[e.renderSlot(t.$slots,"footer",{},()=>[e.createVNode(e.unref(c.default),e.mergeProps({class:"mr8",onClick:s},t.cancelProps),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.cancelText),1)]),_:1},16),e.createVNode(e.unref(c.default),e.mergeProps({type:t.okType,loading:o.confirmLoading,onClick:h},t.okProps),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.okText),1)]),_:1},16,["type","loading"])],!0)])):e.createCommentVNode("",!0)],6)):e.createCommentVNode("",!0)],6),[[e.vShow,n.value]])]),_:3})],34),[[e.vShow,d.value]])]))}});exports.default=M;