UNPKG

vue-amazing-ui

Version:

An Amazing Vue3 UI Components Library, Using TypeScript.

2 lines (1 loc) 12.5 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),k=require("../scrollbar/index.cjs"),d=require("../button/index.cjs"),E=require("../utils/index.cjs"),b={class:"dialog-root"},T={focusable:"false","data-icon":"fullscreen",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},P={focusable:"false","data-icon":"fullscreen-exit",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},$={key:1,class:"dialog-footer"},D={focusable:"false","data-icon":"fullscreen",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},O={focusable:"false","data-icon":"fullscreen-exit",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true",viewBox:"64 64 896 896"},M={key:1,class:"dialog-footer"},F=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(t,{emit:p}){const l=t,m=e.ref(),r=e.ref(null),c=e.ref(),u=e.ref(),i=e.ref("50% 50%"),n=e.ref(!1),{isSupported:v}=E.useOptionsSupported("capture"),f=p,y=e.computed(()=>typeof l.width=="number"?`${l.width}px`:l.width),S=e.computed(()=>typeof l.height=="number"?`${l.height}px`:l.height),C=e.computed(()=>typeof l.top=="number"?`${l.top}px`:l.top),x=e.computed(()=>n.value?l.transformOrigin==="mouse"?{width:"100%",transformOrigin:`${r.value?.x}px ${r.value?.y}px`}:{width:"100%",transformOrigin:i.value}:l.centered?{width:y.value,transformOrigin:i.value}:{width:y.value,transformOrigin:i.value,top:C.value}),h=e.computed(()=>n.value?{height:"100vh",...l.bodyStyle}:{height:S.value,...l.bodyStyle});e.watch(c,async a=>{a?(await e.nextTick(),m.value.focus(),l.blockScroll&&(document.documentElement.style.overflowY="hidden",document.body.style.overflowY="hidden")):l.blockScroll&&(document.documentElement.style.removeProperty("overflow-y"),document.body.style.removeProperty("overflow-y"))},{immediate:!0}),e.watchEffect(()=>{c.value=l.open}),e.onMounted(()=>{document.addEventListener("click",g,v.value?{capture:!0}:!0)}),e.onUnmounted(()=>{document.removeEventListener("click",g,v.value?{capture:!0}:!0)});function g(a){c.value||(r.value={x:a.clientX,y:a.clientY})}async function z(a){if(u.value=!0,await e.nextTick(),l.transformOrigin==="mouse"&&r.value){const o=a.getBoundingClientRect();i.value=`${r.value.x-o.left}px ${r.value.y-o.top}px`}else i.value="50% 50%"}function B(a){if(l.transformOrigin==="mouse"&&r.value){const o=a.getBoundingClientRect();i.value=`${r.value.x-o.left}px ${r.value.y-o.top}px`}else i.value="50% 50%"}function N(){u.value=!1,n.value=!1}function L(){n.value=!n.value}function s(){c.value=!1,f("update:open",!1),f("cancel")}function w(){f("ok")}return(a,o)=>(e.openBlock(),e.createElementBlock("div",b,[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,c.value]])]),_:1}),e.withDirectives(e.createElementVNode("div",{tabindex:"-1",ref_key:"dialogRef",ref:m,class:e.normalizeClass(["dialog-wrap",{"flex-centered":t.centered}]),onClick:o[0]||(o[0]=e.withModifiers(V=>l.maskClosable?s():()=>!1,["self"])),onKeydown:o[1]||(o[1]=e.withKeys(V=>l.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(["dialog-container",{"dialog-with-fullscreen":n.value}]),style:e.normalizeStyle(x.value)},[t.destroyOnClose?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["dialog-body-wrap",t.bodyClass]),style:e.normalizeStyle(h.value)},[e.createElementVNode("div",{class:e.normalizeClass(["dialog-header",{"header-with-switch":t.switchFullscreen}]),style:e.normalizeStyle(t.titleStyle)},[e.renderSlot(a.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)],!0)],6),t.switchFullscreen?(e.openBlock(),e.createElementBlock("span",{key:0,class:"fullscreen-action",onClick:L},[e.withDirectives((e.openBlock(),e.createElementBlock("svg",T,[...o[2]||(o[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,!n.value]]),e.withDirectives((e.openBlock(),e.createElementBlock("svg",P,[...o[3]||(o[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,n.value]])])):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"close-action",onClick:s},[...o[4]||(o[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(k.default),e.normalizeProps(e.guardReactiveProps(t.scrollbarProps)),{default:e.withCtx(()=>[e.createElementVNode("div",{class:"dialog-content",style:e.normalizeStyle(t.contentStyle)},[e.renderSlot(a.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.content),1)],!0)],4)]),_:3},16),t.footer?(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(a.$slots,"footer",{},()=>[e.createVNode(e.unref(d.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(d.default),e.mergeProps({type:t.okType,loading:l.confirmLoading,onClick:w},t.okProps),{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.okText),1)]),_:1},16,["type","loading"])],!0)])):e.createCommentVNode("",!0)],6)),t.destroyOnClose&&c.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["dialog-body-wrap",t.bodyClass]),style:e.normalizeStyle(h.value)},[e.createElementVNode("div",{class:e.normalizeClass(["dialog-header",{"header-with-switch":t.switchFullscreen}]),style:e.normalizeStyle(t.titleStyle)},[e.renderSlot(a.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)],!0)],6),t.switchFullscreen?(e.openBlock(),e.createElementBlock("span",{key:0,class:"fullscreen-action",onClick:L},[e.withDirectives((e.openBlock(),e.createElementBlock("svg",D,[...o[5]||(o[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,!n.value]]),e.withDirectives((e.openBlock(),e.createElementBlock("svg",O,[...o[6]||(o[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,n.value]])])):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"close-action",onClick:s},[...o[7]||(o[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(k.default),e.normalizeProps(e.guardReactiveProps(t.scrollbarProps)),{default:e.withCtx(()=>[e.createElementVNode("div",{class:"dialog-content",style:e.normalizeStyle(t.contentStyle)},[e.renderSlot(a.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.content),1)],!0)],4)]),_:3},16),t.footer?(e.openBlock(),e.createElementBlock("div",M,[e.renderSlot(a.$slots,"footer",{},()=>[e.createVNode(e.unref(d.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(d.default),e.mergeProps({type:t.okType,loading:l.confirmLoading,onClick:w},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,c.value]])]),_:3})],34),[[e.vShow,u.value]])]))}});exports.default=F;