@gopowerteam/modal-render 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,3 +92,6 @@ type __VLS_WithDefaults<P, D> = {
92
92
  default: D[K];
93
93
  }> : P[K];
94
94
  };
95
+ type __VLS_Prettify<T> = {
96
+ [K in keyof T]: T[K];
97
+ } & {};
@@ -41,3 +41,6 @@ type __VLS_WithDefaults<P, D> = {
41
41
  default: D[K];
42
42
  }> : P[K];
43
43
  };
44
+ type __VLS_Prettify<T> = {
45
+ [K in keyof T]: T[K];
46
+ } & {};
@@ -56,6 +56,9 @@ type __VLS_WithDefaults<P, D> = {
56
56
  default: D[K];
57
57
  }> : P[K];
58
58
  };
59
+ type __VLS_Prettify<T> = {
60
+ [K in keyof T]: T[K];
61
+ } & {};
59
62
  type __VLS_WithTemplateSlots<T, S> = T & {
60
63
  new (): {
61
64
  $slots: S;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const S=Symbol("__MODAL__");function R(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function b(o){return typeof o=="function"?o():e.unref(o)}const A=typeof window<"u"&&typeof document<"u",F=Object.prototype.toString,I=o=>F.call(o)==="[object Object]",H=()=>{};function W(o,s={}){if(!e.isRef(o))return e.toRefs(o);const n=Array.isArray(o.value)?Array.from({length:o.value.length}):{};for(const t in o.value)n[t]=e.customRef(()=>({get(){return o.value[t]},set(a){var i;if((i=b(s.replaceRef))!=null?i:!0)if(Array.isArray(o.value)){const y=[...o.value];y[t]=a,o.value=y}else{const y={...o.value,[t]:a};Object.setPrototypeOf(y,Object.getPrototypeOf(o.value)),o.value=y}else o.value[t]=a}}));return n}function j(o){var s;const n=b(o);return(s=n==null?void 0:n.$el)!=null?s:n}const D=A?window:void 0;function P(...o){let s,n,t,a;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,t,a]=o,s=D):[s,n,t,a]=o,!s)return H;Array.isArray(n)||(n=[n]),Array.isArray(t)||(t=[t]);const i=[],p=()=>{i.forEach(m=>m()),i.length=0},y=(m,g,l,f)=>(m.addEventListener(g,l,f),()=>m.removeEventListener(g,l,f)),_=e.watch(()=>[j(s),b(a)],([m,g])=>{if(p(),!m)return;const l=I(g)?{...g}:g;i.push(...n.flatMap(f=>t.map(c=>y(m,f,c,l))))},{immediate:!0,flush:"post"}),w=()=>{_(),p()};return R(w),w}function K(o,s={}){var n,t;const{pointerTypes:a,preventDefault:i,stopPropagation:p,exact:y,onMove:_,onEnd:w,onStart:m,initialValue:g,axis:l="both",draggingElement:f=D,containerElement:c,handle:v=o}=s,d=e.ref((n=b(g))!=null?n:{x:0,y:0}),h=e.ref(),C=u=>a?a.includes(u.pointerType):!0,B=u=>{b(i)&&u.preventDefault(),b(p)&&u.stopPropagation()},V=u=>{var E;if(!C(u)||b(y)&&u.target!==b(o))return;const x=((E=b(c))!=null?E:b(o)).getBoundingClientRect(),r={x:u.clientX-x.left,y:u.clientY-x.top};(m==null?void 0:m(r,u))!==!1&&(h.value=r,B(u))},L=u=>{if(!C(u)||!h.value)return;let{x:E,y:M}=d.value;(l==="x"||l==="both")&&(E=u.clientX-h.value.x),(l==="y"||l==="both")&&(M=u.clientY-h.value.y),d.value={x:E,y:M},_==null||_(d.value,u),B(u)},$=u=>{C(u)&&h.value&&(h.value=void 0,w==null||w(d.value,u),B(u))};if(A){const u={capture:(t=s.capture)!=null?t:!0};P(v,"pointerdown",V,u),P(f,"pointermove",L,u),P(f,"pointerup",$,u)}return{...W(d),position:d,isDragging:e.computed(()=>!!h.value),style:e.computed(()=>`left:${d.value.x}px;top:${d.value.y}px;`)}}const X=o=>(e.pushScopeId("data-v-450bcc09"),o=o(),e.popScopeId(),o),Y={class:"title font-bold"},q={class:"action"},G={key:1,class:"modal-footer space-x-2"},U=["form"],J={key:2,class:"modal-loading"},Q=X(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),Z=[Q],ee={name:"ModalContainer",inheritAttrs:!0},te=e.defineComponent({...ee,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},sizes:{},size:{default:"middle"},fullscreen:{type:Boolean},title:{},header:{type:Boolean,default:!0},footer:{type:Boolean,default:!1},closeable:{type:Boolean,default:!0},esc:{type:Boolean,default:!1},maskClosable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},mode:{default:"dialog"},type:{}},emits:["submit"],setup(o,{expose:s,emit:n}){const t=o,a=n,i=e.inject(S),p=e.ref(!1);let y=0,_=0;const w=e.shallowRef(),m=e.shallowRef(),g=e.shallowRef(),{x:l,y:f}=K(g,{initialValue:{x:0,y:0}});function c(){i==null||i.close(t.id)}function v(r){if(typeof r=="number")return`${r}px`;if(typeof r=="string")return r}const d=e.computed(()=>{const r={};return t.mode==="dialog"&&(r.justifyContent="center"),t.mode==="drawer"&&(r.justifyContent="flex-end"),r}),h=e.computed(()=>{const r={};return t.size&&(r.width=v(t.sizes[t.size])),t.width&&(r.width=v(t.width)),t.maxWidth&&(r.maxWidth=v(t.maxWidth)),t.fullscreen&&(r.maxWidth="unset",r.width="100%",r.position="fixed",r.top=0,r.left=0,r.bottom=0,r.right=0,r.borderRadius=0),t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.transform=`translate3d(${l.value-y}px, ${f.value-_}px, 0px)`),t.mode==="drawer"&&(r.borderRadius=0),r}),C=e.computed(()=>{const r={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.cursor="move"),r}),B=e.computed(()=>{var k;const r={};return t.maxHeight&&(r.maxHeight=`calc(${(k=v(t.maxHeight))==null?void 0:k.replace("%","vh")} - 50px)`),t.mode==="drawer"&&(r.maxHeight="unset",r.height=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.fullscreen&&(r.maxHeight="unset",r.height=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.type!=="component"&&(r.padding="0"),r});function V(){const r=m.value;if(t.form&&r){const k=r.querySelector(`form[name="${t.form}"]`);k&&k.dispatchEvent(new Event("submit"))}a("submit")}function L(){i==null||i.close(t.id)}function $(){window&&window.addEventListener("resize",()=>{e.triggerRef(w),e.triggerRef(m),y=m.value.offsetLeft,_=m.value.offsetTop})}function u(){if(t.closeable&&t.esc){const r=({key:k})=>{k==="Escape"&&(i==null||i.close(t.id),window.removeEventListener("keydown",r))};window.addEventListener("keydown",r)}}function E(){y=m.value.offsetLeft,_=m.value.offsetTop}e.onMounted(()=>{u(),$()}),e.onUnmounted(()=>{});function M(){return p.value=!0,()=>x()}function x(){p.value=!1}return s({showLoading:M,hideLoading:x}),(r,k)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:w,class:"modal-wrapper",style:e.normalizeStyle(d.value),onClick:k[0]||(k[0]=e.withModifiers(pe=>r.maskClosable&&c(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:m,class:e.normalizeClass(["modal-content",{[`${r.mode}-mode`]:!0}]),style:e.normalizeStyle(h.value)},[r.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:g,class:"modal-header",style:e.normalizeStyle(C.value),onMousedown:E},[e.createElementVNode("div",Y,e.toDisplayString(r.title),1),e.createElementVNode("div",q,[r.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:c})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(B.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.component),e.normalizeProps(e.guardReactiveProps(r.componentProps)),null,16))],4),r.footer?(e.openBlock(),e.createElementBlock("div",G,[e.createElementVNode("button",{class:"submit-button",form:r.form,type:"submit",onClick:V}," 确定 ",8,U),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:L}," 取消 ")])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",J,Z)):e.createCommentVNode("",!0)],6)],4))}});const z=(o,s)=>{const n=o.__vccOpts||o;for(const[t,a]of s)n[t]=a;return n},O=z(te,[["__scopeId","data-v-450bcc09"]]),oe={class:"modal-dialog"},ne={class:"dialog-body"},re={class:"dialog-title"},ie={class:"dialog-content"},le=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const s=o,n=T(),t=e.computed(()=>s.title?s.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[s.type]);async function a(){s.onOk&&await s.onOk(),n.close()}async function i(){s.onCancel&&await s.onCancel(),n.close()}return(p,y)=>(e.openBlock(),e.createElementBlock("section",oe,[e.createElementVNode("div",ne,[e.createElementVNode("div",re,e.toDisplayString(t.value),1),e.createElementVNode("div",ie,e.toDisplayString(p.content),1)]),e.createElementVNode("div",{class:"dialog-footer space-x-2",style:e.normalizeStyle(p.type==="confirm"?{"justify-content":"end"}:{"border-top":"none"})},[p.footer?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p.footer),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("button",{class:"submit-button",type:"submit",onClick:a},e.toDisplayString(p.okText),1),p.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:i},e.toDisplayString(p.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}});const se=z(le,[["__scopeId","data-v-8326e5a5"]]),ae={key:0,class:"modal-teleport"},ce={name:"ModalProvider",inheritAttrs:!0},de=e.defineComponent({...ce,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(o,{expose:s}){const n=e.shallowRef([]),t=e.ref(!1),a=e.getCurrentInstance();function i(l,f={},c={}){const v=e.defineAsyncComponent(()=>Promise.resolve(typeof l=="string"?se:l));typeof l=="string"&&(f.type=l,c.size="small",c.fullscreen=!1,c.mode="dialog",c.footer=!1,c.header=!1);const d=Math.random().toString(32).slice(2),h=new Promise(C=>{n.value.push({id:d,component:v,props:f||{},options:{...c,type:typeof l=="string"?l:"component"},resolve:C,listeners:[]}),e.triggerRef(n)});return Object.assign(h,{close:()=>p(d)})}function p(l,f){const c=n.value.findIndex(d=>d.id===l);if(c<0)return;const v=n.value[c];v==null||v.resolve(f),n.value.splice(c,1),e.triggerRef(n)}function y(){n.value.forEach(l=>{l.resolve()}),n.value=[],e.triggerRef(n)}function _(l,f){const c=n.value.find(d=>d.id===l);if(!c)return;const v=c.listeners.find(d=>d.event===f);v&&v.callback({open:i,close:d=>p(c.id,d),closeAll:y,showLoading:()=>w(c.id),hideLoading:()=>m(c.id),confirm:d=>i("confirm",d),success:d=>i("success",d),error:d=>i("error",d),warning:d=>i("warning",d),info:d=>i("info",d)})}function w(l){if(!a)return;const[f]=a.refs[`modal-container_${l}`];if(f)return f.showLoading()}function m(l){if(!a)return;const[f]=a.refs[`modal-container_${l}`];if(f)return f.hideLoading()}function g(l,f,c){const v=n.value.find(d=>d.id===l);v&&v.listeners.push({event:f,callback:c})}return e.provide(S,{open:i,close:p,closeAll:y,addEventListener:g}),s({elements:n,open:i}),e.onMounted(()=>{t.value=!0}),(l,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(l.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",ae,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!l.appendToBody,to:typeof l.appendToBody=="string"?l.appendToBody:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,c=>(e.openBlock(),e.createBlock(O,e.mergeProps({id:c.id,key:c.id,ref_for:!0,ref:`modal-container_${c.id}`,component:c.component,"component-props":c.props,"max-height":l.maxHeight,"max-width":l.maxWidth,sizes:l.sizes},c.options,{onSubmit:()=>_(c.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}});const ue=z(de,[["__scopeId","data-v-cbdbb036"]]);function N(o,s){var t,a;let n=o==null?void 0:o.parent;for(;n&&((t=n==null?void 0:n.type)==null?void 0:t.name)!==s;)n=n.parent;return((a=n==null?void 0:n.type)==null?void 0:a.name)===s?n:null}function T(){const o=e.inject(S),s=e.getCurrentInstance();function n(t,a,i){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,a,i)}return{open:n,close(t){var p;if(!o)throw new Error("Not Found Modal Provider Component");const a=N(s,"ModalContainer"),i=(p=a==null?void 0:a.props)==null?void 0:p.id;if(!i)throw new Error("Not Found Current Modal Container");o.close(i,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},showLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=N(s,"ModalContainer");if(!((i=t==null?void 0:t.props)==null?void 0:i.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.showLoading())},hideLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=N(s,"ModalContainer");if(!((i=t==null?void 0:t.props)==null?void 0:i.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.hideLoading())},confirm(t){return this.open("confirm",t)},info(t){return this.open("info",t)},error(t){return this.open("error",t)},warning(t){return this.open("warning",t)},success(t){return this.open("success",t)}}}function fe(o){var i;const s=e.inject(S),n=e.getCurrentInstance(),t=N(n,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;s&&a&&s.addEventListener(a,"submit",o)}exports.ModalContainer=O;exports.ModalKey=S;exports.ModalProvider=ue;exports.onSubmit=fe;exports.useModal=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const N=Symbol("__MODAL__");function F(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function w(o){return typeof o=="function"?o():e.unref(o)}const z=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const W=Object.prototype.toString,I=o=>W.call(o)==="[object Object]",H=()=>{};function j(o,s={}){if(!e.isRef(o))return e.toRefs(o);const r=Array.isArray(o.value)?Array.from({length:o.value.length}):{};for(const t in o.value)r[t]=e.customRef(()=>({get(){return o.value[t]},set(a){var i;if((i=w(s.replaceRef))!=null?i:!0)if(Array.isArray(o.value)){const h=[...o.value];h[t]=a,o.value=h}else{const h={...o.value,[t]:a};Object.setPrototypeOf(h,Object.getPrototypeOf(o.value)),o.value=h}else o.value[t]=a}}));return r}function G(o){var s;const r=w(o);return(s=r==null?void 0:r.$el)!=null?s:r}const D=z?window:void 0;function A(...o){let s,r,t,a;if(typeof o[0]=="string"||Array.isArray(o[0])?([r,t,a]=o,s=D):[s,r,t,a]=o,!s)return H;Array.isArray(r)||(r=[r]),Array.isArray(t)||(t=[t]);const i=[],p=()=>{i.forEach(m=>m()),i.length=0},h=(m,g,l,f)=>(m.addEventListener(g,l,f),()=>m.removeEventListener(g,l,f)),C=e.watch(()=>[G(s),w(a)],([m,g])=>{if(p(),!m)return;const l=I(g)?{...g}:g;i.push(...r.flatMap(f=>t.map(c=>h(m,f,c,l))))},{immediate:!0,flush:"post"}),E=()=>{C(),p()};return F(E),E}function K(o,s={}){var r,t;const{pointerTypes:a,preventDefault:i,stopPropagation:p,exact:h,onMove:C,onEnd:E,onStart:m,initialValue:g,axis:l="both",draggingElement:f=D,containerElement:c,handle:v=o}=s,d=e.ref((r=w(g))!=null?r:{x:0,y:0}),k=e.ref(),b=u=>a?a.includes(u.pointerType):!0,M=u=>{w(i)&&u.preventDefault(),w(p)&&u.stopPropagation()},L=u=>{var x;if(!b(u)||w(h)&&u.target!==w(o))return;const _=w(c),B=(x=_==null?void 0:_.getBoundingClientRect)==null?void 0:x.call(_),n=w(o).getBoundingClientRect(),y={x:u.clientX-(_?n.left-B.left:n.left),y:u.clientY-(_?n.top-B.top:n.top)};(m==null?void 0:m(y,u))!==!1&&(k.value=y,M(u))},$=u=>{var x;if(!b(u)||!k.value)return;const _=w(c),B=(x=_==null?void 0:_.getBoundingClientRect)==null?void 0:x.call(_),n=w(o).getBoundingClientRect();let{x:y,y:S}=d.value;(l==="x"||l==="both")&&(y=u.clientX-k.value.x,_&&(y=Math.min(Math.max(0,y),B.width-n.width))),(l==="y"||l==="both")&&(S=u.clientY-k.value.y,_&&(S=Math.min(Math.max(0,S),B.height-n.height))),d.value={x:y,y:S},C==null||C(d.value,u),M(u)},P=u=>{b(u)&&k.value&&(k.value=void 0,E==null||E(d.value,u),M(u))};if(z){const u={capture:(t=s.capture)!=null?t:!0};A(v,"pointerdown",L,u),A(f,"pointermove",$,u),A(f,"pointerup",P,u)}return{...j(d),position:d,isDragging:e.computed(()=>!!k.value),style:e.computed(()=>`left:${d.value.x}px;top:${d.value.y}px;`)}}const X=o=>(e.pushScopeId("data-v-7f0b9287"),o=o(),e.popScopeId(),o),Y={class:"title font-bold"},q={class:"action"},U={key:1,class:"modal-footer space-x-2"},J=["form"],Q={key:2,class:"modal-loading"},Z=X(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),ee=[Z],te={name:"ModalContainer",inheritAttrs:!0},oe=e.defineComponent({...te,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},sizes:{},size:{default:"middle"},fullscreen:{type:Boolean},title:{},header:{type:Boolean,default:!0},footer:{type:Boolean,default:!1},closeable:{type:Boolean,default:!0},esc:{type:Boolean,default:!1},maskClosable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},mode:{default:"dialog"},type:{}},emits:["submit"],setup(o,{expose:s,emit:r}){const t=o,a=r,i=e.inject(N),p=e.ref(!1);let h=0,C=0;const E=e.shallowRef(),m=e.shallowRef(),g=e.shallowRef(),{x:l,y:f}=K(g,{initialValue:{x:0,y:0}});function c(){i==null||i.close(t.id)}function v(n){if(typeof n=="number")return`${n}px`;if(typeof n=="string")return n}const d=e.computed(()=>{const n={};return t.mode==="dialog"&&(n.justifyContent="center"),t.mode==="drawer"&&(n.justifyContent="flex-end"),n}),k=e.computed(()=>{const n={};return t.size&&(n.width=v(t.sizes[t.size])),t.width&&(n.width=v(t.width)),t.maxWidth&&(n.maxWidth=v(t.maxWidth)),t.fullscreen&&(n.maxWidth="unset",n.width="100%",n.position="fixed",n.top=0,n.left=0,n.bottom=0,n.right=0,n.borderRadius=0),t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(n.transform=`translate3d(${l.value-h}px, ${f.value-C}px, 0px)`),t.mode==="drawer"&&(n.borderRadius=0),n}),b=e.computed(()=>{const n={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(n.cursor="move"),n}),M=e.computed(()=>{var y;const n={};return t.maxHeight&&(n.maxHeight=`calc(${(y=v(t.maxHeight))==null?void 0:y.replace("%","vh")} - 50px)`),t.mode==="drawer"&&(n.maxHeight="unset",n.height=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.fullscreen&&(n.maxHeight="unset",n.height=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.type!=="component"&&(n.padding="0"),n});function L(){const n=m.value;if(t.form&&n){const y=n.querySelector(`form[name="${t.form}"]`);y&&y.dispatchEvent(new Event("submit"))}a("submit")}function $(){i==null||i.close(t.id)}function P(){window&&window.addEventListener("resize",()=>{e.triggerRef(E),e.triggerRef(m),m.value&&(h=m.value.offsetLeft,C=m.value.offsetTop)})}function u(){if(t.closeable&&t.esc){const n=({key:y})=>{y==="Escape"&&(i==null||i.close(t.id),window.removeEventListener("keydown",n))};window.addEventListener("keydown",n)}}function x(){h=m.value.offsetLeft,C=m.value.offsetTop}e.onMounted(()=>{u(),P()}),e.onUnmounted(()=>{});function _(){return p.value=!0,()=>B()}function B(){p.value=!1}return s({showLoading:_,hideLoading:B}),(n,y)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:E,class:"modal-wrapper",style:e.normalizeStyle(d.value),onClick:y[0]||(y[0]=e.withModifiers(S=>n.maskClosable&&c(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:m,class:e.normalizeClass(["modal-content",{[`${n.mode}-mode`]:!0}]),style:e.normalizeStyle(k.value)},[n.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:g,class:"modal-header",style:e.normalizeStyle(b.value),onMousedown:x},[e.createElementVNode("div",Y,e.toDisplayString(n.title),1),e.createElementVNode("div",q,[n.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:c})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(M.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.component),e.normalizeProps(e.guardReactiveProps(n.componentProps)),null,16))],4),n.footer?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("button",{class:"submit-button",form:n.form,type:"submit",onClick:L}," 确定 ",8,J),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:$}," 取消 ")])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",Q,ee)):e.createCommentVNode("",!0)],6)],4))}});const R=(o,s)=>{const r=o.__vccOpts||o;for(const[t,a]of s)r[t]=a;return r},O=R(oe,[["__scopeId","data-v-7f0b9287"]]),ne={class:"modal-dialog"},re={class:"dialog-body"},ie={class:"dialog-title"},le={class:"dialog-content"},se=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const s=o,r=T(),t=e.computed(()=>s.title?s.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[s.type]);async function a(){s.onOk&&await s.onOk(),r.close()}async function i(){s.onCancel&&await s.onCancel(),r.close()}return(p,h)=>(e.openBlock(),e.createElementBlock("section",ne,[e.createElementVNode("div",re,[e.createElementVNode("div",ie,e.toDisplayString(t.value),1),e.createElementVNode("div",le,e.toDisplayString(p.content),1)]),e.createElementVNode("div",{class:"dialog-footer space-x-2",style:e.normalizeStyle(p.type==="confirm"?{"justify-content":"end"}:{"border-top":"none"})},[p.footer?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p.footer),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("button",{class:"submit-button",type:"submit",onClick:a},e.toDisplayString(p.okText),1),p.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:i},e.toDisplayString(p.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}});const ae=R(se,[["__scopeId","data-v-8326e5a5"]]),ce={key:0,class:"modal-teleport"},de={name:"ModalProvider",inheritAttrs:!0},ue=e.defineComponent({...de,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(o,{expose:s}){const r=e.shallowRef([]),t=e.ref(!1),a=e.getCurrentInstance();function i(l,f={},c={}){const v=e.defineAsyncComponent(()=>Promise.resolve(typeof l=="string"?ae:l));typeof l=="string"&&(f.type=l,c.size="small",c.fullscreen=!1,c.mode="dialog",c.footer=!1,c.header=!1);const d=Math.random().toString(32).slice(2),k=new Promise((b,M)=>{r.value.push({id:d,component:v,props:f||{},options:{...c,type:typeof l=="string"?l:"component"},resolve:b,reject:M,listeners:[]}),e.triggerRef(r)}).catch(b=>b==="CANCEL"?new Promise(()=>{}):Promise.reject(b));return Object.assign(k,{close:()=>p(d)})}function p(l,f){const c=r.value.findIndex(d=>d.id===l);if(c<0)return;const v=r.value[c];f===void 0?v==null||v.reject("CANCEL"):v==null||v.resolve(f),r.value.splice(c,1),e.triggerRef(r)}function h(){r.value.forEach(l=>{l.resolve()}),r.value=[],e.triggerRef(r)}function C(l,f){const c=r.value.find(d=>d.id===l);if(!c)return;const v=c.listeners.find(d=>d.event===f);v&&v.callback({open:i,close:d=>p(c.id,d),closeAll:h,showLoading:()=>E(c.id),hideLoading:()=>m(c.id),confirm:d=>i("confirm",d),success:d=>i("success",d),error:d=>i("error",d),warning:d=>i("warning",d),info:d=>i("info",d)})}function E(l){if(!a)return;const[f]=a.refs[`modal-container_${l}`];if(f)return f.showLoading()}function m(l){if(!a)return;const[f]=a.refs[`modal-container_${l}`];if(f)return f.hideLoading()}function g(l,f,c){const v=r.value.find(d=>d.id===l);v&&v.listeners.push({event:f,callback:c})}return e.provide(N,{open:i,close:p,closeAll:h,addEventListener:g}),s({elements:r,open:i}),e.onMounted(()=>{t.value=!0}),(l,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(l.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",ce,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!l.appendToBody,to:typeof l.appendToBody=="string"?l.appendToBody:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,c=>(e.openBlock(),e.createBlock(O,e.mergeProps({id:c.id,key:c.id,ref_for:!0,ref:`modal-container_${c.id}`,component:c.component,"component-props":c.props,"max-height":l.maxHeight,"max-width":l.maxWidth,sizes:l.sizes},c.options,{onSubmit:()=>C(c.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}});const fe=R(ue,[["__scopeId","data-v-4ee644e1"]]);function V(o,s){var t,a;let r=o==null?void 0:o.parent;for(;r&&((t=r==null?void 0:r.type)==null?void 0:t.name)!==s;)r=r.parent;return((a=r==null?void 0:r.type)==null?void 0:a.name)===s?r:null}function T(){const o=e.inject(N),s=e.getCurrentInstance();function r(t,a,i){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,a,i)}return{open:r,close(t){var p;if(!o)throw new Error("Not Found Modal Provider Component");const a=V(s,"ModalContainer"),i=(p=a==null?void 0:a.props)==null?void 0:p.id;if(!i)throw new Error("Not Found Current Modal Container");o.close(i,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},showLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=V(s,"ModalContainer");if(!((i=t==null?void 0:t.props)==null?void 0:i.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.showLoading())},hideLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=V(s,"ModalContainer");if(!((i=t==null?void 0:t.props)==null?void 0:i.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.hideLoading())},confirm(t){return this.open("confirm",t)},info(t){return this.open("info",t)},error(t){return this.open("error",t)},warning(t){return this.open("warning",t)},success(t){return this.open("success",t)}}}function pe(o){var i;const s=e.inject(N),r=e.getCurrentInstance(),t=V(r,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;s&&a&&s.addEventListener(a,"submit",o)}exports.ModalContainer=O;exports.ModalKey=N;exports.ModalProvider=fe;exports.onSubmit=pe;exports.useModal=T;
@@ -23,6 +23,7 @@ export interface OpenModalOptions {
23
23
  export interface ModalElement extends OpenModalOptions {
24
24
  id: string;
25
25
  resolve: (data?: any) => void;
26
+ reject: (key: 'CANCEL') => void;
26
27
  component: Component;
27
28
  props: Record<string, any>;
28
29
  options: OpenModalOptions & {
@@ -92,3 +92,6 @@ type __VLS_WithDefaults<P, D> = {
92
92
  default: D[K];
93
93
  }> : P[K];
94
94
  };
95
+ type __VLS_Prettify<T> = {
96
+ [K in keyof T]: T[K];
97
+ } & {};
@@ -41,3 +41,6 @@ type __VLS_WithDefaults<P, D> = {
41
41
  default: D[K];
42
42
  }> : P[K];
43
43
  };
44
+ type __VLS_Prettify<T> = {
45
+ [K in keyof T]: T[K];
46
+ } & {};
@@ -56,6 +56,9 @@ type __VLS_WithDefaults<P, D> = {
56
56
  default: D[K];
57
57
  }> : P[K];
58
58
  };
59
+ type __VLS_Prettify<T> = {
60
+ [K in keyof T]: T[K];
61
+ } & {};
59
62
  type __VLS_WithTemplateSlots<T, S> = T & {
60
63
  new (): {
61
64
  $slots: S;
package/dist/es/index.mjs CHANGED
@@ -1,126 +1,130 @@
1
- import { unref as Z, isRef as ee, toRefs as te, customRef as oe, getCurrentScope as ne, onScopeDispose as re, ref as N, computed as S, watch as ie, defineComponent as Y, inject as K, shallowRef as T, onMounted as U, onUnmounted as se, openBlock as h, createElementBlock as w, normalizeStyle as z, withModifiers as le, createElementVNode as y, normalizeClass as ae, toDisplayString as B, createCommentVNode as $, createBlock as F, resolveDynamicComponent as j, normalizeProps as de, guardReactiveProps as ce, triggerRef as O, pushScopeId as ue, popScopeId as fe, Fragment as X, getCurrentInstance as q, provide as pe, renderSlot as me, Teleport as ve, createVNode as ye, TransitionGroup as he, withCtx as ge, renderList as _e, mergeProps as we, defineAsyncComponent as be } from "vue";
2
- const H = Symbol("__MODAL__");
3
- function Ce(t) {
4
- return ne() ? (re(t), !0) : !1;
1
+ import { unref as ee, isRef as te, toRefs as oe, customRef as ne, getCurrentScope as ie, onScopeDispose as re, ref as N, computed as A, watch as se, defineComponent as Y, inject as j, shallowRef as T, onMounted as U, onUnmounted as le, openBlock as g, createElementBlock as k, normalizeStyle as z, withModifiers as ae, createElementVNode as y, normalizeClass as de, toDisplayString as O, createCommentVNode as P, createBlock as W, resolveDynamicComponent as J, normalizeProps as ce, guardReactiveProps as ue, triggerRef as R, pushScopeId as fe, popScopeId as pe, Fragment as X, getCurrentInstance as K, provide as me, renderSlot as ve, Teleport as he, createVNode as ye, TransitionGroup as ge, withCtx as _e, renderList as we, mergeProps as be, defineAsyncComponent as Ce } from "vue";
2
+ const F = Symbol("__MODAL__");
3
+ function ke(t) {
4
+ return ie() ? (re(t), !0) : !1;
5
5
  }
6
- function x(t) {
7
- return typeof t == "function" ? t() : Z(t);
6
+ function b(t) {
7
+ return typeof t == "function" ? t() : ee(t);
8
8
  }
9
- const J = typeof window < "u" && typeof document < "u", ke = Object.prototype.toString, xe = (t) => ke.call(t) === "[object Object]", Me = () => {
9
+ const Q = typeof window < "u" && typeof document < "u";
10
+ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
11
+ const xe = Object.prototype.toString, Me = (t) => xe.call(t) === "[object Object]", Ee = () => {
10
12
  };
11
- function Ee(t, s = {}) {
12
- if (!ee(t))
13
- return te(t);
14
- const o = Array.isArray(t.value) ? Array.from({ length: t.value.length }) : {};
13
+ function Se(t, s = {}) {
14
+ if (!te(t))
15
+ return oe(t);
16
+ const n = Array.isArray(t.value) ? Array.from({ length: t.value.length }) : {};
15
17
  for (const e in t.value)
16
- o[e] = oe(() => ({
18
+ n[e] = ne(() => ({
17
19
  get() {
18
20
  return t.value[e];
19
21
  },
20
22
  set(l) {
21
- var r;
22
- if ((r = x(s.replaceRef)) != null ? r : !0)
23
+ var i;
24
+ if ((i = b(s.replaceRef)) != null ? i : !0)
23
25
  if (Array.isArray(t.value)) {
24
- const v = [...t.value];
25
- v[e] = l, t.value = v;
26
+ const h = [...t.value];
27
+ h[e] = l, t.value = h;
26
28
  } else {
27
- const v = { ...t.value, [e]: l };
28
- Object.setPrototypeOf(v, Object.getPrototypeOf(t.value)), t.value = v;
29
+ const h = { ...t.value, [e]: l };
30
+ Object.setPrototypeOf(h, Object.getPrototypeOf(t.value)), t.value = h;
29
31
  }
30
32
  else
31
33
  t.value[e] = l;
32
34
  }
33
35
  }));
34
- return o;
36
+ return n;
35
37
  }
36
- function Se(t) {
38
+ function Le(t) {
37
39
  var s;
38
- const o = x(t);
39
- return (s = o == null ? void 0 : o.$el) != null ? s : o;
40
+ const n = b(t);
41
+ return (s = n == null ? void 0 : n.$el) != null ? s : n;
40
42
  }
41
- const Q = J ? window : void 0;
42
- function V(...t) {
43
- let s, o, e, l;
44
- if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([o, e, l] = t, s = Q) : [s, o, e, l] = t, !s)
45
- return Me;
46
- Array.isArray(o) || (o = [o]), Array.isArray(e) || (e = [e]);
47
- const r = [], f = () => {
48
- r.forEach((p) => p()), r.length = 0;
49
- }, v = (p, g, i, u) => (p.addEventListener(g, i, u), () => p.removeEventListener(g, i, u)), b = ie(
50
- () => [Se(s), x(l)],
51
- ([p, g]) => {
43
+ const Z = Q ? window : void 0;
44
+ function G(...t) {
45
+ let s, n, e, l;
46
+ if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([n, e, l] = t, s = Z) : [s, n, e, l] = t, !s)
47
+ return Ee;
48
+ Array.isArray(n) || (n = [n]), Array.isArray(e) || (e = [e]);
49
+ const i = [], f = () => {
50
+ i.forEach((p) => p()), i.length = 0;
51
+ }, h = (p, _, r, u) => (p.addEventListener(_, r, u), () => p.removeEventListener(_, r, u)), x = se(
52
+ () => [Le(s), b(l)],
53
+ ([p, _]) => {
52
54
  if (f(), !p)
53
55
  return;
54
- const i = xe(g) ? { ...g } : g;
55
- r.push(
56
- ...o.flatMap((u) => e.map((a) => v(p, u, a, i)))
56
+ const r = Me(_) ? { ..._ } : _;
57
+ i.push(
58
+ ...n.flatMap((u) => e.map((a) => h(p, u, a, r)))
57
59
  );
58
60
  },
59
61
  { immediate: !0, flush: "post" }
60
- ), C = () => {
61
- b(), f();
62
+ ), M = () => {
63
+ x(), f();
62
64
  };
63
- return Ce(C), C;
65
+ return ke(M), M;
64
66
  }
65
67
  function $e(t, s = {}) {
66
- var o, e;
68
+ var n, e;
67
69
  const {
68
70
  pointerTypes: l,
69
- preventDefault: r,
71
+ preventDefault: i,
70
72
  stopPropagation: f,
71
- exact: v,
72
- onMove: b,
73
- onEnd: C,
73
+ exact: h,
74
+ onMove: x,
75
+ onEnd: M,
74
76
  onStart: p,
75
- initialValue: g,
76
- axis: i = "both",
77
- draggingElement: u = Q,
77
+ initialValue: _,
78
+ axis: r = "both",
79
+ draggingElement: u = Z,
78
80
  containerElement: a,
79
81
  handle: m = t
80
82
  } = s, d = N(
81
- (o = x(g)) != null ? o : { x: 0, y: 0 }
82
- ), _ = N(), M = (c) => l ? l.includes(c.pointerType) : !0, L = (c) => {
83
- x(r) && c.preventDefault(), x(f) && c.stopPropagation();
84
- }, R = (c) => {
85
- var E;
86
- if (!M(c) || x(v) && c.target !== x(t))
83
+ (n = b(_)) != null ? n : { x: 0, y: 0 }
84
+ ), C = N(), E = (c) => l ? l.includes(c.pointerType) : !0, L = (c) => {
85
+ b(i) && c.preventDefault(), b(f) && c.stopPropagation();
86
+ }, H = (c) => {
87
+ var $;
88
+ if (!E(c) || b(h) && c.target !== b(t))
87
89
  return;
88
- const P = ((E = x(a)) != null ? E : x(t)).getBoundingClientRect(), n = {
89
- x: c.clientX - P.left,
90
- y: c.clientY - P.top
90
+ const w = b(a), S = ($ = w == null ? void 0 : w.getBoundingClientRect) == null ? void 0 : $.call(w), o = b(t).getBoundingClientRect(), v = {
91
+ x: c.clientX - (w ? o.left - S.left : o.left),
92
+ y: c.clientY - (w ? o.top - S.top : o.top)
91
93
  };
92
- (p == null ? void 0 : p(n, c)) !== !1 && (_.value = n, L(c));
93
- }, W = (c) => {
94
- if (!M(c) || !_.value)
95
- return;
96
- let { x: E, y: A } = d.value;
97
- (i === "x" || i === "both") && (E = c.clientX - _.value.x), (i === "y" || i === "both") && (A = c.clientY - _.value.y), d.value = {
98
- x: E,
99
- y: A
100
- }, b == null || b(d.value, c), L(c);
94
+ (p == null ? void 0 : p(v, c)) !== !1 && (C.value = v, L(c));
101
95
  }, I = (c) => {
102
- M(c) && _.value && (_.value = void 0, C == null || C(d.value, c), L(c));
96
+ var $;
97
+ if (!E(c) || !C.value)
98
+ return;
99
+ const w = b(a), S = ($ = w == null ? void 0 : w.getBoundingClientRect) == null ? void 0 : $.call(w), o = b(t).getBoundingClientRect();
100
+ let { x: v, y: B } = d.value;
101
+ (r === "x" || r === "both") && (v = c.clientX - C.value.x, w && (v = Math.min(Math.max(0, v), S.width - o.width))), (r === "y" || r === "both") && (B = c.clientY - C.value.y, w && (B = Math.min(Math.max(0, B), S.height - o.height))), d.value = {
102
+ x: v,
103
+ y: B
104
+ }, x == null || x(d.value, c), L(c);
105
+ }, V = (c) => {
106
+ E(c) && C.value && (C.value = void 0, M == null || M(d.value, c), L(c));
103
107
  };
104
- if (J) {
108
+ if (Q) {
105
109
  const c = { capture: (e = s.capture) != null ? e : !0 };
106
- V(m, "pointerdown", R, c), V(u, "pointermove", W, c), V(u, "pointerup", I, c);
110
+ G(m, "pointerdown", H, c), G(u, "pointermove", I, c), G(u, "pointerup", V, c);
107
111
  }
108
112
  return {
109
- ...Ee(d),
113
+ ...Se(d),
110
114
  position: d,
111
- isDragging: S(() => !!_.value),
112
- style: S(
115
+ isDragging: A(() => !!C.value),
116
+ style: A(
113
117
  () => `left:${d.value.x}px;top:${d.value.y}px;`
114
118
  )
115
119
  };
116
120
  }
117
- const Le = (t) => (ue("data-v-450bcc09"), t = t(), fe(), t), Ae = { class: "title font-bold" }, Pe = { class: "action" }, ze = {
121
+ const Ae = (t) => (fe("data-v-7f0b9287"), t = t(), pe(), t), Pe = { class: "title font-bold" }, Be = { class: "action" }, ze = {
118
122
  key: 1,
119
123
  class: "modal-footer space-x-2"
120
- }, Be = ["form"], Oe = {
124
+ }, Oe = ["form"], Re = {
121
125
  key: 2,
122
126
  class: "modal-loading"
123
- }, Te = /* @__PURE__ */ Le(() => /* @__PURE__ */ y("div", { class: "lds-ring" }, [
127
+ }, Te = /* @__PURE__ */ Ae(() => /* @__PURE__ */ y("div", { class: "lds-ring" }, [
124
128
  /* @__PURE__ */ y("div"),
125
129
  /* @__PURE__ */ y("div"),
126
130
  /* @__PURE__ */ y("div"),
@@ -130,7 +134,7 @@ const Le = (t) => (ue("data-v-450bcc09"), t = t(), fe(), t), Ae = { class: "titl
130
134
  ], Ne = {
131
135
  name: "ModalContainer",
132
136
  inheritAttrs: !0
133
- }, Fe = /* @__PURE__ */ Y({
137
+ }, We = /* @__PURE__ */ Y({
134
138
  ...Ne,
135
139
  props: {
136
140
  id: {},
@@ -154,135 +158,135 @@ const Le = (t) => (ue("data-v-450bcc09"), t = t(), fe(), t), Ae = { class: "titl
154
158
  type: {}
155
159
  },
156
160
  emits: ["submit"],
157
- setup(t, { expose: s, emit: o }) {
158
- const e = t, l = o, r = K(H), f = N(!1);
159
- let v = 0, b = 0;
160
- const C = T(), p = T(), g = T(), { x: i, y: u } = $e(g, {
161
+ setup(t, { expose: s, emit: n }) {
162
+ const e = t, l = n, i = j(F), f = N(!1);
163
+ let h = 0, x = 0;
164
+ const M = T(), p = T(), _ = T(), { x: r, y: u } = $e(_, {
161
165
  initialValue: { x: 0, y: 0 }
162
166
  });
163
167
  function a() {
164
- r == null || r.close(e.id);
168
+ i == null || i.close(e.id);
165
169
  }
166
- function m(n) {
167
- if (typeof n == "number")
168
- return `${n}px`;
169
- if (typeof n == "string")
170
- return n;
170
+ function m(o) {
171
+ if (typeof o == "number")
172
+ return `${o}px`;
173
+ if (typeof o == "string")
174
+ return o;
171
175
  }
172
- const d = S(() => {
173
- const n = {};
174
- return e.mode === "dialog" && (n.justifyContent = "center"), e.mode === "drawer" && (n.justifyContent = "flex-end"), n;
175
- }), _ = S(() => {
176
- const n = {};
177
- return e.size && (n.width = m(e.sizes[e.size])), e.width && (n.width = m(e.width)), e.maxWidth && (n.maxWidth = m(e.maxWidth)), e.fullscreen && (n.maxWidth = "unset", n.width = "100%", n.position = "fixed", n.top = 0, n.left = 0, n.bottom = 0, n.right = 0, n.borderRadius = 0), e.draggable && !e.fullscreen && e.mode === "dialog" && (n.transform = `translate3d(${i.value - v}px, ${u.value - b}px, 0px)`), e.mode === "drawer" && (n.borderRadius = 0), n;
178
- }), M = S(() => {
179
- const n = {};
180
- return e.draggable && !e.fullscreen && e.mode === "dialog" && (n.cursor = "move"), n;
181
- }), L = S(() => {
182
- var k;
183
- const n = {};
184
- return e.maxHeight && (n.maxHeight = `calc(${(k = m(e.maxHeight)) == null ? void 0 : k.replace("%", "vh")} - 50px)`), e.mode === "drawer" && (n.maxHeight = "unset", n.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.fullscreen && (n.maxHeight = "unset", n.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.type !== "component" && (n.padding = "0"), n;
176
+ const d = A(() => {
177
+ const o = {};
178
+ return e.mode === "dialog" && (o.justifyContent = "center"), e.mode === "drawer" && (o.justifyContent = "flex-end"), o;
179
+ }), C = A(() => {
180
+ const o = {};
181
+ return e.size && (o.width = m(e.sizes[e.size])), e.width && (o.width = m(e.width)), e.maxWidth && (o.maxWidth = m(e.maxWidth)), e.fullscreen && (o.maxWidth = "unset", o.width = "100%", o.position = "fixed", o.top = 0, o.left = 0, o.bottom = 0, o.right = 0, o.borderRadius = 0), e.draggable && !e.fullscreen && e.mode === "dialog" && (o.transform = `translate3d(${r.value - h}px, ${u.value - x}px, 0px)`), e.mode === "drawer" && (o.borderRadius = 0), o;
182
+ }), E = A(() => {
183
+ const o = {};
184
+ return e.draggable && !e.fullscreen && e.mode === "dialog" && (o.cursor = "move"), o;
185
+ }), L = A(() => {
186
+ var v;
187
+ const o = {};
188
+ return e.maxHeight && (o.maxHeight = `calc(${(v = m(e.maxHeight)) == null ? void 0 : v.replace("%", "vh")} - 50px)`), e.mode === "drawer" && (o.maxHeight = "unset", o.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.fullscreen && (o.maxHeight = "unset", o.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.type !== "component" && (o.padding = "0"), o;
185
189
  });
186
- function R() {
187
- const n = p.value;
188
- if (e.form && n) {
189
- const k = n.querySelector(`form[name="${e.form}"]`);
190
- k && k.dispatchEvent(new Event("submit"));
190
+ function H() {
191
+ const o = p.value;
192
+ if (e.form && o) {
193
+ const v = o.querySelector(`form[name="${e.form}"]`);
194
+ v && v.dispatchEvent(new Event("submit"));
191
195
  }
192
196
  l("submit");
193
197
  }
194
- function W() {
195
- r == null || r.close(e.id);
196
- }
197
198
  function I() {
199
+ i == null || i.close(e.id);
200
+ }
201
+ function V() {
198
202
  window && window.addEventListener("resize", () => {
199
- O(C), O(p), v = p.value.offsetLeft, b = p.value.offsetTop;
203
+ R(M), R(p), p.value && (h = p.value.offsetLeft, x = p.value.offsetTop);
200
204
  });
201
205
  }
202
206
  function c() {
203
207
  if (e.closeable && e.esc) {
204
- const n = ({ key: k }) => {
205
- k === "Escape" && (r == null || r.close(e.id), window.removeEventListener("keydown", n));
208
+ const o = ({ key: v }) => {
209
+ v === "Escape" && (i == null || i.close(e.id), window.removeEventListener("keydown", o));
206
210
  };
207
- window.addEventListener("keydown", n);
211
+ window.addEventListener("keydown", o);
208
212
  }
209
213
  }
210
- function E() {
211
- v = p.value.offsetLeft, b = p.value.offsetTop;
214
+ function $() {
215
+ h = p.value.offsetLeft, x = p.value.offsetTop;
212
216
  }
213
217
  U(() => {
214
- c(), I();
215
- }), se(() => {
218
+ c(), V();
219
+ }), le(() => {
216
220
  });
217
- function A() {
218
- return f.value = !0, () => P();
221
+ function w() {
222
+ return f.value = !0, () => S();
219
223
  }
220
- function P() {
224
+ function S() {
221
225
  f.value = !1;
222
226
  }
223
227
  return s({
224
- showLoading: A,
225
- hideLoading: P
226
- }), (n, k) => (h(), w("div", {
228
+ showLoading: w,
229
+ hideLoading: S
230
+ }), (o, v) => (g(), k("div", {
227
231
  ref_key: "wrapperRef",
228
- ref: C,
232
+ ref: M,
229
233
  class: "modal-wrapper",
230
234
  style: z(d.value),
231
- onClick: k[0] || (k[0] = le((je) => n.maskClosable && a(), ["self"]))
235
+ onClick: v[0] || (v[0] = ae((B) => o.maskClosable && a(), ["self"]))
232
236
  }, [
233
237
  y("div", {
234
238
  ref_key: "contentRef",
235
239
  ref: p,
236
- class: ae(["modal-content", { [`${n.mode}-mode`]: !0 }]),
237
- style: z(_.value)
240
+ class: de(["modal-content", { [`${o.mode}-mode`]: !0 }]),
241
+ style: z(C.value)
238
242
  }, [
239
- n.header ? (h(), w("div", {
243
+ o.header ? (g(), k("div", {
240
244
  key: 0,
241
245
  ref_key: "headerRef",
242
- ref: g,
246
+ ref: _,
243
247
  class: "modal-header",
244
- style: z(M.value),
245
- onMousedown: E
248
+ style: z(E.value),
249
+ onMousedown: $
246
250
  }, [
247
- y("div", Ae, B(n.title), 1),
248
- y("div", Pe, [
249
- n.closeable ? (h(), w("div", {
251
+ y("div", Pe, O(o.title), 1),
252
+ y("div", Be, [
253
+ o.closeable ? (g(), k("div", {
250
254
  key: 0,
251
255
  class: "i-icon-park-outline:close block cursor-pointer",
252
256
  onClick: a
253
- })) : $("", !0)
257
+ })) : P("", !0)
254
258
  ])
255
- ], 36)) : $("", !0),
259
+ ], 36)) : P("", !0),
256
260
  y("div", {
257
261
  class: "modal-body",
258
262
  style: z(L.value)
259
263
  }, [
260
- (h(), F(j(n.component), de(ce(n.componentProps)), null, 16))
264
+ (g(), W(J(o.component), ce(ue(o.componentProps)), null, 16))
261
265
  ], 4),
262
- n.footer ? (h(), w("div", ze, [
266
+ o.footer ? (g(), k("div", ze, [
263
267
  y("button", {
264
268
  class: "submit-button",
265
- form: n.form,
269
+ form: o.form,
266
270
  type: "submit",
267
- onClick: R
268
- }, " 确定 ", 8, Be),
271
+ onClick: H
272
+ }, " 确定 ", 8, Oe),
269
273
  y("button", {
270
274
  class: "cancel-button",
271
275
  type: "button",
272
- onClick: W
276
+ onClick: I
273
277
  }, " 取消 ")
274
- ])) : $("", !0),
275
- f.value ? (h(), w("div", Oe, De)) : $("", !0)
278
+ ])) : P("", !0),
279
+ f.value ? (g(), k("div", Re, De)) : P("", !0)
276
280
  ], 6)
277
281
  ], 4));
278
282
  }
279
283
  });
280
- const G = (t, s) => {
281
- const o = t.__vccOpts || t;
284
+ const q = (t, s) => {
285
+ const n = t.__vccOpts || t;
282
286
  for (const [e, l] of s)
283
- o[e] = l;
284
- return o;
285
- }, He = /* @__PURE__ */ G(Fe, [["__scopeId", "data-v-450bcc09"]]), Re = { class: "modal-dialog" }, We = { class: "dialog-body" }, Ie = { class: "dialog-title" }, Ve = { class: "dialog-content" }, Xe = /* @__PURE__ */ Y({
287
+ n[e] = l;
288
+ return n;
289
+ }, Fe = /* @__PURE__ */ q(We, [["__scopeId", "data-v-7f0b9287"]]), He = { class: "modal-dialog" }, Ie = { class: "dialog-body" }, Ve = { class: "dialog-title" }, Ge = { class: "dialog-content" }, Xe = /* @__PURE__ */ Y({
286
290
  __name: "modal-dialog",
287
291
  props: {
288
292
  type: {},
@@ -295,7 +299,7 @@ const G = (t, s) => {
295
299
  footer: {}
296
300
  },
297
301
  setup(t) {
298
- const s = t, o = Ue(), e = S(() => s.title ? s.title : {
302
+ const s = t, n = Ue(), e = A(() => s.title ? s.title : {
299
303
  confirm: "提示",
300
304
  info: "提示",
301
305
  warning: "警告",
@@ -303,45 +307,45 @@ const G = (t, s) => {
303
307
  success: "成功"
304
308
  }[s.type]);
305
309
  async function l() {
306
- s.onOk && await s.onOk(), o.close();
310
+ s.onOk && await s.onOk(), n.close();
307
311
  }
308
- async function r() {
309
- s.onCancel && await s.onCancel(), o.close();
312
+ async function i() {
313
+ s.onCancel && await s.onCancel(), n.close();
310
314
  }
311
- return (f, v) => (h(), w("section", Re, [
312
- y("div", We, [
313
- y("div", Ie, B(e.value), 1),
314
- y("div", Ve, B(f.content), 1)
315
+ return (f, h) => (g(), k("section", He, [
316
+ y("div", Ie, [
317
+ y("div", Ve, O(e.value), 1),
318
+ y("div", Ge, O(f.content), 1)
315
319
  ]),
316
320
  y("div", {
317
321
  class: "dialog-footer space-x-2",
318
322
  style: z(f.type === "confirm" ? { "justify-content": "end" } : { "border-top": "none" })
319
323
  }, [
320
- f.footer ? (h(), F(j(f.footer), { key: 0 })) : (h(), w(X, { key: 1 }, [
324
+ f.footer ? (g(), W(J(f.footer), { key: 0 })) : (g(), k(X, { key: 1 }, [
321
325
  y("button", {
322
326
  class: "submit-button",
323
327
  type: "submit",
324
328
  onClick: l
325
- }, B(f.okText), 1),
326
- f.type === "confirm" ? (h(), w("button", {
329
+ }, O(f.okText), 1),
330
+ f.type === "confirm" ? (g(), k("button", {
327
331
  key: 0,
328
332
  class: "cancel-button",
329
333
  type: "button",
330
- onClick: r
331
- }, B(f.cancelText), 1)) : $("", !0)
334
+ onClick: i
335
+ }, O(f.cancelText), 1)) : P("", !0)
332
336
  ], 64))
333
337
  ], 4)
334
338
  ]));
335
339
  }
336
340
  });
337
- const Ye = /* @__PURE__ */ G(Xe, [["__scopeId", "data-v-8326e5a5"]]), Ke = {
341
+ const Ye = /* @__PURE__ */ q(Xe, [["__scopeId", "data-v-8326e5a5"]]), je = {
338
342
  key: 0,
339
343
  class: "modal-teleport"
340
- }, qe = {
344
+ }, Ke = {
341
345
  name: "ModalProvider",
342
346
  inheritAttrs: !0
343
- }, Ge = /* @__PURE__ */ Y({
344
- ...qe,
347
+ }, qe = /* @__PURE__ */ Y({
348
+ ...Ke,
345
349
  props: {
346
350
  appendToBody: { type: [Boolean, String], default: !1 },
347
351
  sizes: { default: () => ({
@@ -353,145 +357,147 @@ const Ye = /* @__PURE__ */ G(Xe, [["__scopeId", "data-v-8326e5a5"]]), Ke = {
353
357
  maxHeight: { default: "80%" }
354
358
  },
355
359
  setup(t, { expose: s }) {
356
- const o = T([]), e = N(!1), l = q();
357
- function r(i, u = {}, a = {}) {
358
- const m = be(
359
- () => Promise.resolve(typeof i == "string" ? Ye : i)
360
+ const n = T([]), e = N(!1), l = K();
361
+ function i(r, u = {}, a = {}) {
362
+ const m = Ce(
363
+ () => Promise.resolve(typeof r == "string" ? Ye : r)
360
364
  );
361
- typeof i == "string" && (u.type = i, a.size = "small", a.fullscreen = !1, a.mode = "dialog", a.footer = !1, a.header = !1);
362
- const d = Math.random().toString(32).slice(2), _ = new Promise((M) => {
363
- o.value.push({
365
+ typeof r == "string" && (u.type = r, a.size = "small", a.fullscreen = !1, a.mode = "dialog", a.footer = !1, a.header = !1);
366
+ const d = Math.random().toString(32).slice(2), C = new Promise((E, L) => {
367
+ n.value.push({
364
368
  id: d,
365
369
  component: m,
366
370
  props: u || {},
367
371
  options: {
368
372
  ...a,
369
- type: typeof i == "string" ? i : "component"
373
+ type: typeof r == "string" ? r : "component"
370
374
  },
371
- resolve: M,
375
+ resolve: E,
376
+ reject: L,
372
377
  listeners: []
373
- }), O(o);
374
- });
375
- return Object.assign(_, {
378
+ }), R(n);
379
+ }).catch((E) => E === "CANCEL" ? new Promise(() => {
380
+ }) : Promise.reject(E));
381
+ return Object.assign(C, {
376
382
  close: () => f(d)
377
383
  });
378
384
  }
379
- function f(i, u) {
380
- const a = o.value.findIndex((d) => d.id === i);
385
+ function f(r, u) {
386
+ const a = n.value.findIndex((d) => d.id === r);
381
387
  if (a < 0)
382
388
  return;
383
- const m = o.value[a];
384
- m == null || m.resolve(u), o.value.splice(a, 1), O(o);
389
+ const m = n.value[a];
390
+ u === void 0 ? m == null || m.reject("CANCEL") : m == null || m.resolve(u), n.value.splice(a, 1), R(n);
385
391
  }
386
- function v() {
387
- o.value.forEach((i) => {
388
- i.resolve();
389
- }), o.value = [], O(o);
392
+ function h() {
393
+ n.value.forEach((r) => {
394
+ r.resolve();
395
+ }), n.value = [], R(n);
390
396
  }
391
- function b(i, u) {
392
- const a = o.value.find((d) => d.id === i);
397
+ function x(r, u) {
398
+ const a = n.value.find((d) => d.id === r);
393
399
  if (!a)
394
400
  return;
395
401
  const m = a.listeners.find((d) => d.event === u);
396
402
  m && m.callback({
397
- open: r,
403
+ open: i,
398
404
  close: (d) => f(a.id, d),
399
- closeAll: v,
400
- showLoading: () => C(a.id),
405
+ closeAll: h,
406
+ showLoading: () => M(a.id),
401
407
  hideLoading: () => p(a.id),
402
- confirm: (d) => r("confirm", d),
403
- success: (d) => r("success", d),
404
- error: (d) => r("error", d),
405
- warning: (d) => r("warning", d),
406
- info: (d) => r("info", d)
408
+ confirm: (d) => i("confirm", d),
409
+ success: (d) => i("success", d),
410
+ error: (d) => i("error", d),
411
+ warning: (d) => i("warning", d),
412
+ info: (d) => i("info", d)
407
413
  });
408
414
  }
409
- function C(i) {
415
+ function M(r) {
410
416
  if (!l)
411
417
  return;
412
- const [u] = l.refs[`modal-container_${i}`];
418
+ const [u] = l.refs[`modal-container_${r}`];
413
419
  if (u)
414
420
  return u.showLoading();
415
421
  }
416
- function p(i) {
422
+ function p(r) {
417
423
  if (!l)
418
424
  return;
419
- const [u] = l.refs[`modal-container_${i}`];
425
+ const [u] = l.refs[`modal-container_${r}`];
420
426
  if (u)
421
427
  return u.hideLoading();
422
428
  }
423
- function g(i, u, a) {
424
- const m = o.value.find((d) => d.id === i);
429
+ function _(r, u, a) {
430
+ const m = n.value.find((d) => d.id === r);
425
431
  m && m.listeners.push({
426
432
  event: u,
427
433
  callback: a
428
434
  });
429
435
  }
430
- return pe(H, {
431
- open: r,
436
+ return me(F, {
437
+ open: i,
432
438
  close: f,
433
- closeAll: v,
434
- addEventListener: g
439
+ closeAll: h,
440
+ addEventListener: _
435
441
  }), s({
436
- elements: o,
437
- open: r
442
+ elements: n,
443
+ open: i
438
444
  }), U(() => {
439
445
  e.value = !0;
440
- }), (i, u) => (h(), w(X, null, [
441
- me(i.$slots, "default", {}, void 0, !0),
442
- e.value ? (h(), w("div", Ke, [
443
- (h(), F(ve, {
444
- disabled: !i.appendToBody,
445
- to: typeof i.appendToBody == "string" ? i.appendToBody : "body"
446
+ }), (r, u) => (g(), k(X, null, [
447
+ ve(r.$slots, "default", {}, void 0, !0),
448
+ e.value ? (g(), k("div", je, [
449
+ (g(), W(he, {
450
+ disabled: !r.appendToBody,
451
+ to: typeof r.appendToBody == "string" ? r.appendToBody : "body"
446
452
  }, [
447
- ye(he, { name: "modal-fade" }, {
448
- default: ge(() => [
449
- (h(!0), w(X, null, _e(o.value, (a) => (h(), F(He, we({
453
+ ye(ge, { name: "modal-fade" }, {
454
+ default: _e(() => [
455
+ (g(!0), k(X, null, we(n.value, (a) => (g(), W(Fe, be({
450
456
  id: a.id,
451
457
  key: a.id,
452
458
  ref_for: !0,
453
459
  ref: `modal-container_${a.id}`,
454
460
  component: a.component,
455
461
  "component-props": a.props,
456
- "max-height": i.maxHeight,
457
- "max-width": i.maxWidth,
458
- sizes: i.sizes
462
+ "max-height": r.maxHeight,
463
+ "max-width": r.maxWidth,
464
+ sizes: r.sizes
459
465
  }, a.options, {
460
- onSubmit: () => b(a.id, "submit")
466
+ onSubmit: () => x(a.id, "submit")
461
467
  }), null, 16, ["id", "component", "component-props", "max-height", "max-width", "sizes", "onSubmit"]))), 128))
462
468
  ]),
463
469
  _: 1
464
470
  })
465
471
  ], 8, ["disabled", "to"]))
466
- ])) : $("", !0)
472
+ ])) : P("", !0)
467
473
  ], 64));
468
474
  }
469
475
  });
470
- const Qe = /* @__PURE__ */ G(Ge, [["__scopeId", "data-v-cbdbb036"]]);
476
+ const Qe = /* @__PURE__ */ q(qe, [["__scopeId", "data-v-4ee644e1"]]);
471
477
  function D(t, s) {
472
478
  var e, l;
473
- let o = t == null ? void 0 : t.parent;
474
- for (; o && ((e = o == null ? void 0 : o.type) == null ? void 0 : e.name) !== s; )
475
- o = o.parent;
476
- return ((l = o == null ? void 0 : o.type) == null ? void 0 : l.name) === s ? o : null;
479
+ let n = t == null ? void 0 : t.parent;
480
+ for (; n && ((e = n == null ? void 0 : n.type) == null ? void 0 : e.name) !== s; )
481
+ n = n.parent;
482
+ return ((l = n == null ? void 0 : n.type) == null ? void 0 : l.name) === s ? n : null;
477
483
  }
478
484
  function Ue() {
479
- const t = K(H), s = q();
480
- function o(e, l, r) {
485
+ const t = j(F), s = K();
486
+ function n(e, l, i) {
481
487
  if (!t)
482
488
  throw new Error("Not Found Modal Provider Component");
483
- return t.open(e, l, r);
489
+ return t.open(e, l, i);
484
490
  }
485
491
  return {
486
- open: o,
492
+ open: n,
487
493
  close(e) {
488
494
  var f;
489
495
  if (!t)
490
496
  throw new Error("Not Found Modal Provider Component");
491
- const l = D(s, "ModalContainer"), r = (f = l == null ? void 0 : l.props) == null ? void 0 : f.id;
492
- if (!r)
497
+ const l = D(s, "ModalContainer"), i = (f = l == null ? void 0 : l.props) == null ? void 0 : f.id;
498
+ if (!i)
493
499
  throw new Error("Not Found Current Modal Container");
494
- t.close(r, e);
500
+ t.close(i, e);
495
501
  },
496
502
  closeAll() {
497
503
  if (!t)
@@ -499,20 +505,20 @@ function Ue() {
499
505
  t.closeAll();
500
506
  },
501
507
  showLoading() {
502
- var r;
508
+ var i;
503
509
  if (!t)
504
510
  throw new Error("Not Found Modal Provider Component");
505
511
  const e = D(s, "ModalContainer");
506
- if (!((r = e == null ? void 0 : e.props) == null ? void 0 : r.id))
512
+ if (!((i = e == null ? void 0 : e.props) == null ? void 0 : i.id))
507
513
  throw new Error("Not Found Current Modal Container");
508
514
  e != null && e.exposed && (e == null || e.exposed.showLoading());
509
515
  },
510
516
  hideLoading() {
511
- var r;
517
+ var i;
512
518
  if (!t)
513
519
  throw new Error("Not Found Modal Provider Component");
514
520
  const e = D(s, "ModalContainer");
515
- if (!((r = e == null ? void 0 : e.props) == null ? void 0 : r.id))
521
+ if (!((i = e == null ? void 0 : e.props) == null ? void 0 : i.id))
516
522
  throw new Error("Not Found Current Modal Container");
517
523
  e != null && e.exposed && (e == null || e.exposed.hideLoading());
518
524
  },
@@ -534,13 +540,13 @@ function Ue() {
534
540
  };
535
541
  }
536
542
  function Ze(t) {
537
- var r;
538
- const s = K(H), o = q(), e = D(o, "ModalContainer"), l = (r = e == null ? void 0 : e.props) == null ? void 0 : r.id;
543
+ var i;
544
+ const s = j(F), n = K(), e = D(n, "ModalContainer"), l = (i = e == null ? void 0 : e.props) == null ? void 0 : i.id;
539
545
  s && l && s.addEventListener(l, "submit", t);
540
546
  }
541
547
  export {
542
- He as ModalContainer,
543
- H as ModalKey,
548
+ Fe as ModalContainer,
549
+ F as ModalKey,
544
550
  Qe as ModalProvider,
545
551
  Ze as onSubmit,
546
552
  Ue as useModal
@@ -23,6 +23,7 @@ export interface OpenModalOptions {
23
23
  export interface ModalElement extends OpenModalOptions {
24
24
  id: string;
25
25
  resolve: (data?: any) => void;
26
+ reject: (key: 'CANCEL') => void;
26
27
  component: Component;
27
28
  props: Record<string, any>;
28
29
  options: OpenModalOptions & {
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- *,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-icon-park-outline\:close{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 48 48' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='m8 8l32 32M8 40L40 8'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.resize{resize:both}.space-x-2>:not([hidden])~:not([hidden]){--un-space-x-reverse:0;margin-left:calc(.5rem * calc(1 - var(--un-space-x-reverse)));margin-right:calc(.5rem * var(--un-space-x-reverse))}.border{border-width:1px}.px{padding-left:1rem;padding-right:1rem}.font-bold{font-weight:700}.outline{outline-style:solid}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.ease{transition-timing-function:cubic-bezier(.4,0,.2,1)}.modal-wrapper[data-v-450bcc09]{z-index:1000;position:fixed;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:rgba(0,0,0,.3)}.modal-content[data-v-450bcc09]{background:#ffffff;border-radius:5px;position:relative}.modal-header[data-v-450bcc09]{box-sizing:border-box;padding:10px;height:50px;display:flex;justify-content:space-between;align-items:center;border-bottom:solid 1px var(--color-border-1, #e8e8e8)}.modal-body[data-v-450bcc09]{padding:20px 10px;box-sizing:border-box;max-height:10vw;overflow:auto}.modal-footer[data-v-450bcc09]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:end;padding:10px}.modal-footer button[data-v-450bcc09]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.modal-footer button.submit-button[data-v-450bcc09]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-450bcc09]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-450bcc09]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-450bcc09]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-loading[data-v-450bcc09]{position:absolute;z-index:1001;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#0000001a}.modal-loading .lds-ring[data-v-450bcc09]{display:inline-block;position:relative;width:80px;height:80px}.modal-loading .lds-ring div[data-v-450bcc09]{box-sizing:border-box;display:block;position:absolute;width:48px;height:48px;margin:8px;border:5px solid #fff;border-radius:50%;animation:lds-ring-450bcc09 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.modal-loading .lds-ring div[data-v-450bcc09]:nth-child(1){animation-delay:-.45s}.modal-loading .lds-ring div[data-v-450bcc09]:nth-child(2){animation-delay:-.3s}.modal-loading .lds-ring div[data-v-450bcc09]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-450bcc09{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.dialog-body[data-v-8326e5a5]{padding:20px 10px 10px}.dialog-title[data-v-8326e5a5]{padding:5px;font-weight:700;font-size:16px}.dialog-content[data-v-8326e5a5]{padding:5px}.dialog-footer[data-v-8326e5a5]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:center;align-items:center;padding:0 10px}.dialog-footer button[data-v-8326e5a5]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.dialog-footer button.submit-button[data-v-8326e5a5]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.dialog-footer button.submit-button[data-v-8326e5a5]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.dialog-footer button.cancel-button[data-v-8326e5a5]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.dialog-footer button.cancel-button[data-v-8326e5a5]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-fade-enter-active[data-v-cbdbb036],.modal-fade-leave-active[data-v-cbdbb036]{transition:opacity .5s ease}.modal-fade-enter-active[data-v-cbdbb036] .modal-content.drawer-mode,.modal-fade-leave-active[data-v-cbdbb036] .modal-content.drawer-mode{transition:transform .5s ease}.modal-fade-enter-from[data-v-cbdbb036],.modal-fade-leave-to[data-v-cbdbb036]{opacity:0}.modal-fade-enter-from[data-v-cbdbb036] .modal-content.drawer-mode,.modal-fade-leave-to[data-v-cbdbb036] .modal-content.drawer-mode{transform:translate3d(100%,0,0)}
1
+ *,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-icon-park-outline\:close{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 48 48' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='m8 8l32 32M8 40L40 8'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.resize{resize:both}.space-x-2>:not([hidden])~:not([hidden]){--un-space-x-reverse:0;margin-left:calc(.5rem * calc(1 - var(--un-space-x-reverse)));margin-right:calc(.5rem * var(--un-space-x-reverse))}.border{border-width:1px}.px{padding-left:1rem;padding-right:1rem}.font-bold{font-weight:700}.outline{outline-style:solid}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.ease{transition-timing-function:cubic-bezier(.4,0,.2,1)}.modal-wrapper[data-v-7f0b9287]{z-index:1000;position:fixed;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:rgba(0,0,0,.3)}.modal-content[data-v-7f0b9287]{background:#ffffff;border-radius:5px;position:relative}.modal-header[data-v-7f0b9287]{box-sizing:border-box;padding:10px;height:50px;display:flex;justify-content:space-between;align-items:center;border-bottom:solid 1px var(--color-border-1, #e8e8e8)}.modal-body[data-v-7f0b9287]{padding:20px 10px;box-sizing:border-box;max-height:10vw;overflow:auto}.modal-footer[data-v-7f0b9287]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:end;padding:10px}.modal-footer button[data-v-7f0b9287]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.modal-footer button.submit-button[data-v-7f0b9287]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-7f0b9287]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-7f0b9287]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-7f0b9287]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-loading[data-v-7f0b9287]{position:absolute;z-index:1001;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#0000001a}.modal-loading .lds-ring[data-v-7f0b9287]{display:inline-block;position:relative;width:80px;height:80px}.modal-loading .lds-ring div[data-v-7f0b9287]{box-sizing:border-box;display:block;position:absolute;width:48px;height:48px;margin:8px;border:5px solid #fff;border-radius:50%;animation:lds-ring-7f0b9287 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.modal-loading .lds-ring div[data-v-7f0b9287]:nth-child(1){animation-delay:-.45s}.modal-loading .lds-ring div[data-v-7f0b9287]:nth-child(2){animation-delay:-.3s}.modal-loading .lds-ring div[data-v-7f0b9287]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-7f0b9287{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.dialog-body[data-v-8326e5a5]{padding:20px 10px 10px}.dialog-title[data-v-8326e5a5]{padding:5px;font-weight:700;font-size:16px}.dialog-content[data-v-8326e5a5]{padding:5px}.dialog-footer[data-v-8326e5a5]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:center;align-items:center;padding:0 10px}.dialog-footer button[data-v-8326e5a5]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.dialog-footer button.submit-button[data-v-8326e5a5]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.dialog-footer button.submit-button[data-v-8326e5a5]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.dialog-footer button.cancel-button[data-v-8326e5a5]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.dialog-footer button.cancel-button[data-v-8326e5a5]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-fade-enter-active[data-v-4ee644e1],.modal-fade-leave-active[data-v-4ee644e1]{transition:opacity .5s ease}.modal-fade-enter-active[data-v-4ee644e1] .modal-content.drawer-mode,.modal-fade-leave-active[data-v-4ee644e1] .modal-content.drawer-mode{transition:transform .5s ease}.modal-fade-enter-from[data-v-4ee644e1],.modal-fade-leave-to[data-v-4ee644e1]{opacity:0}.modal-fade-enter-from[data-v-4ee644e1] .modal-content.drawer-mode,.modal-fade-leave-to[data-v-4ee644e1] .modal-content.drawer-mode{transform:translate3d(100%,0,0)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gopowerteam/modal-render",
3
3
  "type": "module",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "author": {
6
6
  "name": "zhuchentong",
7
7
  "email": "2037630@gmail.com"
@@ -42,6 +42,11 @@
42
42
  "dist",
43
43
  "README.md"
44
44
  ],
45
+ "scripts": {
46
+ "dev": "vite build --watch",
47
+ "build": "vite build",
48
+ "npm:publish": "npm run build && npm publish --access publish"
49
+ },
45
50
  "peerDependencies": {
46
51
  "vue": "^3.0.0"
47
52
  },
@@ -64,10 +69,5 @@
64
69
  "publishConfig": {
65
70
  "registry": "https://registry.npmjs.org",
66
71
  "access": "public"
67
- },
68
- "scripts": {
69
- "dev": "vite build --watch",
70
- "build": "vite build",
71
- "npm:publish": "npm run build && npm publish --access publish"
72
72
  }
73
- }
73
+ }