@gopowerteam/modal-render 0.0.1 → 0.0.3

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.
@@ -2,14 +2,14 @@ import type { Component } from 'vue';
2
2
  import type { SizeOptions } from '../interfaces';
3
3
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
4
4
  id: string;
5
- formId?: string;
5
+ form?: string;
6
6
  component: Component;
7
7
  componentProps: Record<string, any>;
8
8
  width?: number | string;
9
9
  maxWidth?: number | string;
10
10
  maxHeight?: number | string;
11
11
  sizes: SizeOptions;
12
- size: 'small' | 'middle' | 'large';
12
+ size: 'small' | 'middle' | 'large' | 'fullscreen';
13
13
  title?: string;
14
14
  header?: boolean;
15
15
  footer?: boolean;
@@ -30,14 +30,14 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
30
30
  submit: (...args: any[]) => void;
31
31
  }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
32
32
  id: string;
33
- formId?: string;
33
+ form?: string;
34
34
  component: Component;
35
35
  componentProps: Record<string, any>;
36
36
  width?: number | string;
37
37
  maxWidth?: number | string;
38
38
  maxHeight?: number | string;
39
39
  sizes: SizeOptions;
40
- size: 'small' | 'middle' | 'large';
40
+ size: 'small' | 'middle' | 'large' | 'fullscreen';
41
41
  title?: string;
42
42
  header?: boolean;
43
43
  footer?: boolean;
@@ -61,7 +61,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
61
61
  closeable: boolean;
62
62
  footer: boolean;
63
63
  maskClosable: boolean;
64
- size: 'small' | 'middle' | 'large';
64
+ size: 'small' | 'middle' | 'large' | 'fullscreen';
65
65
  esc: boolean;
66
66
  draggable: boolean;
67
67
  }, {}>;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const M=Symbol("__MODAL__");function W(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function _(o){return typeof o=="function"?o():e.unref(o)}const V=typeof window<"u"&&typeof document<"u",D=Object.prototype.toString,R=o=>D.call(o)==="[object Object]",T=()=>{};function F(o,i={}){if(!e.isRef(o))return e.toRefs(o);const t=Array.isArray(o.value)?Array.from({length:o.value.length}):{};for(const n in o.value)t[n]=e.customRef(()=>({get(){return o.value[n]},set(r){var d;if((d=_(i.replaceRef))!=null?d:!0)if(Array.isArray(o.value)){const m=[...o.value];m[n]=r,o.value=m}else{const m={...o.value,[n]:r};Object.setPrototypeOf(m,Object.getPrototypeOf(o.value)),o.value=m}else o.value[n]=r}}));return t}function H(o){var i;const t=_(o);return(i=t==null?void 0:t.$el)!=null?i:t}const z=V?window:void 0;function A(...o){let i,t,n,r;if(typeof o[0]=="string"||Array.isArray(o[0])?([t,n,r]=o,i=z):[i,t,n,r]=o,!i)return T;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const d=[],y=()=>{d.forEach(f=>f()),d.length=0},m=(f,s,u,v)=>(f.addEventListener(s,u,v),()=>f.removeEventListener(s,u,v)),p=e.watch(()=>[H(i),_(r)],([f,s])=>{if(y(),!f)return;const u=R(s)?{...s}:s;d.push(...t.flatMap(v=>n.map(k=>m(f,v,k,u))))},{immediate:!0,flush:"post"}),c=()=>{p(),y()};return W(c),c}function I(o,i={}){var t,n;const{pointerTypes:r,preventDefault:d,stopPropagation:y,exact:m,onMove:p,onEnd:c,onStart:f,initialValue:s,axis:u="both",draggingElement:v=z,containerElement:k,handle:S=o}=i,g=e.ref((t=_(s))!=null?t:{x:0,y:0}),b=e.ref(),E=a=>r?r.includes(a.pointerType):!0,C=a=>{_(d)&&a.preventDefault(),_(y)&&a.stopPropagation()},x=a=>{var w;if(!E(a)||_(m)&&a.target!==_(o))return;const N=((w=_(k))!=null?w:_(o)).getBoundingClientRect(),O={x:a.clientX-N.left,y:a.clientY-N.top};(f==null?void 0:f(O,a))!==!1&&(b.value=O,C(a))},l=a=>{if(!E(a)||!b.value)return;let{x:w,y:B}=g.value;(u==="x"||u==="both")&&(w=a.clientX-b.value.x),(u==="y"||u==="both")&&(B=a.clientY-b.value.y),g.value={x:w,y:B},p==null||p(g.value,a),C(a)},h=a=>{E(a)&&b.value&&(b.value=void 0,c==null||c(g.value,a),C(a))};if(V){const a={capture:(n=i.capture)!=null?n:!0};A(S,"pointerdown",x,a),A(v,"pointermove",l,a),A(v,"pointerup",h,a)}return{...F(g),position:g,isDragging:e.computed(()=>!!b.value),style:e.computed(()=>`left:${g.value.x}px;top:${g.value.y}px;`)}}const X={class:"modal-container"},Y={class:"title font-bold"},K={class:"action"},q={key:1,class:"modal-footer space-x-2"},G=["form"],J={name:"ModalContainer",inheritAttrs:!0},Q=e.defineComponent({...J,props:{id:{},formId:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},sizes:{},size:{default:"middle"},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}},emits:["submit"],setup(o,{emit:i}){const t=o,n=i,r=e.inject(M);let d=0,y=0;const m=e.shallowRef(),p=e.shallowRef(),{x:c,y:f}=I(p,{initialValue:{x:0,y:0}});function s(){r==null||r.close(t.id)}function u(l){if(typeof l=="number")return`${l}px`;if(typeof l=="string")return l}const v=e.computed(()=>{const l={};return t.size&&(l.width=u(t.sizes[t.size])),t.width&&(l.width=u(t.width)),t.maxWidth&&(l.maxWidth=u(t.maxWidth)),t.draggable&&(l.transform=`translate(${c.value-d}px, ${f.value-y}px)`),l}),k=e.computed(()=>{const l={};return t.draggable&&(l.cursor="move"),l}),S=e.computed(()=>{var h;const l={};return t.maxHeight&&(l.maxHeight=`calc(${(h=u(t.maxWidth))==null?void 0:h.replace("%","vh")} - 50px)`),l});function g(){n("submit")}function b(){r==null||r.close(t.id)}function E(){window&&window.addEventListener("resize",()=>{e.triggerRef(m),e.triggerRef(p),d=p.value.offsetLeft,y=p.value.offsetTop})}function C(){if(t.closeable&&t.esc){const l=({key:h})=>{h==="Escape"&&(r==null||r.close(t.id),window.removeEventListener("keydown",l))};window.addEventListener("keydown",l)}}function x(){new MutationObserver(h=>{h.forEach(a=>{const w=p.value.offsetLeft,B=p.value.offsetTop;w!==d&&(d=w),B!==y&&(y=w)})}).observe(p.value,{attributes:!0,attributeFilter:["style","offsetHeight","offsetWidth","clientHeight","clientWidth"],attributeOldValue:!0})}return e.onMounted(()=>{C(),x(),E()}),(l,h)=>(e.openBlock(),e.createElementBlock("div",X,[e.createElementVNode("div",{ref_key:"wrapperRef",ref:m,class:"modal-wrapper",onClick:h[0]||(h[0]=e.withModifiers(a=>l.maskClosable&&s(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:p,class:"modal-content",style:e.normalizeStyle(v.value)},[l.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref:"",class:"modal-header",style:e.normalizeStyle(k.value)},[e.createElementVNode("div",Y,e.toDisplayString(l.title),1),e.createElementVNode("div",K,[l.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:s})):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(S.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.component),e.normalizeProps(e.guardReactiveProps(l.componentProps)),null,16))],4),l.footer?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("button",{class:"submit-button",form:l.formId,type:"submit",onClick:g}," 确定 ",8,G),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:b}," 取消 ")])):e.createCommentVNode("",!0)],4)],512)]))}});const L=(o,i)=>{const t=o.__vccOpts||o;for(const[n,r]of i)t[n]=r;return t},$=L(Q,[["__scopeId","data-v-16717585"]]),U={key:0,class:"modal-teleport"},Z={name:"ModalProvider",inheritAttrs:!0},j=e.defineComponent({...Z,props:{appendToBody:{type:Boolean,default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(o,{expose:i}){const t=e.shallowRef([]),n=e.ref(!1);async function r(c,f,s){const u=e.defineAsyncComponent(()=>Promise.resolve(c));return new Promise(v=>{t.value.push({id:Math.random().toString(32).slice(2),component:u,props:f,options:s,resolve:v,onSubmit:e.ref(()=>{})}),e.triggerRef(t)})}function d(c,f){const s=t.value.findIndex(v=>v.id===c);if(s<0)return;const u=t.value[s];u==null||u.resolve(f),t.value.splice(s,1),e.triggerRef(t)}function y(){t.value.forEach(c=>{c.resolve()}),t.value=[],e.triggerRef(t)}function m(c){return t.value.find(f=>f.id===c)}function p(c,f){const s=t.value.find(u=>u.id===c);s&&(s.onSubmit.value=f)}return e.provide(M,{open:r,close:d,closeAll:y,getElement:m,addSubmitListener:p}),i({elements:t}),e.onMounted(()=>{n.value=!0}),(c,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(c.$slots,"default",{},void 0,!0),n.value?(e.openBlock(),e.createElementBlock("div",U,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!c.appendToBody,to:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,s=>(e.openBlock(),e.createBlock($,e.mergeProps({id:s.id,key:s.id,component:s.component,"component-props":s.props,"max-height":c.maxHeight,"max-width":c.maxWidth,sizes:c.sizes},s.options,{onSubmit:s.onSubmit.value}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled"]))])):e.createCommentVNode("",!0)],64))}});const ee=L(j,[["__scopeId","data-v-171d9bdd"]]);function P(o,i){var n,r;let t=o==null?void 0:o.parent;for(;t&&((n=t==null?void 0:t.type)==null?void 0:n.name)!==i;)t=t.parent;return((r=t==null?void 0:t.type)==null?void 0:r.name)===i?t:null}function te(){const o=e.inject(M),i=e.getCurrentInstance();return{open(t,n,r){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,n||{},r||{})},close(t){var d;if(!o)throw new Error("Not Found Modal Provider Component");const n=P(i,"ModalContainer"),r=(d=n==null?void 0:n.props)==null?void 0:d.id;if(!r)throw new Error("Not Found Current Modal Container");o.close(r,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},onSubmit(t){const n=P(i,"ModalContainer");if(!(n==null?void 0:n.props.id))throw new Error("Not Found Current Modal Container")}}}function oe(o){var d;const i=e.inject(M),t=e.getCurrentInstance(),n=P(t,"ModalContainer"),r=(d=n==null?void 0:n.props)==null?void 0:d.id;i&&r&&i.addSubmitListener(r,o)}exports.ModalContainer=$;exports.ModalProvider=ee;exports.onSubmit=oe;exports.useModal=te;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const C=Symbol("__MODAL__");function O(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function g(o){return typeof o=="function"?o():e.unref(o)}const V=typeof window<"u"&&typeof document<"u",D=Object.prototype.toString,W=o=>D.call(o)==="[object Object]",T=()=>{};function F(o,s={}){if(!e.isRef(o))return e.toRefs(o);const t=Array.isArray(o.value)?Array.from({length:o.value.length}):{};for(const r in o.value)t[r]=e.customRef(()=>({get(){return o.value[r]},set(l){var d;if((d=g(s.replaceRef))!=null?d:!0)if(Array.isArray(o.value)){const m=[...o.value];m[r]=l,o.value=m}else{const m={...o.value,[r]:l};Object.setPrototypeOf(m,Object.getPrototypeOf(o.value)),o.value=m}else o.value[r]=l}}));return t}function H(o){var s;const t=g(o);return(s=t==null?void 0:t.$el)!=null?s:t}const R=V?window:void 0;function z(...o){let s,t,r,l;if(typeof o[0]=="string"||Array.isArray(o[0])?([t,r,l]=o,s=R):[s,t,r,l]=o,!s)return T;Array.isArray(t)||(t=[t]),Array.isArray(r)||(r=[r]);const d=[],y=()=>{d.forEach(u=>u()),d.length=0},m=(u,a,f,p)=>(u.addEventListener(a,f,p),()=>u.removeEventListener(a,f,p)),v=e.watch(()=>[H(s),g(l)],([u,a])=>{if(y(),!u)return;const f=W(a)?{...a}:a;d.push(...t.flatMap(p=>r.map(b=>m(u,p,b,f))))},{immediate:!0,flush:"post"}),c=()=>{v(),y()};return O(c),c}function I(o,s={}){var t,r;const{pointerTypes:l,preventDefault:d,stopPropagation:y,exact:m,onMove:v,onEnd:c,onStart:u,initialValue:a,axis:f="both",draggingElement:p=R,containerElement:b,handle:x=o}=s,h=e.ref((t=g(a))!=null?t:{x:0,y:0}),_=e.ref(),k=i=>l?l.includes(i.pointerType):!0,E=i=>{g(d)&&i.preventDefault(),g(y)&&i.stopPropagation()},M=i=>{var w;if(!k(i)||g(m)&&i.target!==g(o))return;const P=((w=g(b))!=null?w:g(o)).getBoundingClientRect(),N={x:i.clientX-P.left,y:i.clientY-P.top};(u==null?void 0:u(N,i))!==!1&&(_.value=N,E(i))},S=i=>{if(!k(i)||!_.value)return;let{x:w,y:B}=h.value;(f==="x"||f==="both")&&(w=i.clientX-_.value.x),(f==="y"||f==="both")&&(B=i.clientY-_.value.y),h.value={x:w,y:B},v==null||v(h.value,i),E(i)},n=i=>{k(i)&&_.value&&(_.value=void 0,c==null||c(h.value,i),E(i))};if(V){const i={capture:(r=s.capture)!=null?r:!0};z(x,"pointerdown",M,i),z(p,"pointermove",S,i),z(p,"pointerup",n,i)}return{...F(h),position:h,isDragging:e.computed(()=>!!_.value),style:e.computed(()=>`left:${h.value.x}px;top:${h.value.y}px;`)}}const X={class:"modal-container"},Y={class:"title font-bold"},q={class:"action"},K={key:1,class:"modal-footer space-x-2"},G=["form"],U={name:"ModalContainer",inheritAttrs:!0},J=e.defineComponent({...U,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},sizes:{},size:{default:"middle"},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}},emits:["submit"],setup(o,{emit:s}){const t=o,r=s,l=e.inject(C);let d=0,y=0;const m=e.shallowRef(),v=e.shallowRef(),c=e.shallowRef(),{x:u,y:a}=I(c,{initialValue:{x:0,y:0}});function f(){l==null||l.close(t.id)}function p(n){if(typeof n=="number")return`${n}px`;if(typeof n=="string")return n}const b=e.computed(()=>{const n={};return t.size&&(n.width=p(t.sizes[t.size])),t.width&&(n.width=p(t.width)),t.maxWidth&&(n.maxWidth=p(t.maxWidth)),t.size==="fullscreen"&&(n.maxWidth="unset",n.position="fixed",n.top=0,n.left=0,n.bottom=0,n.right=0),t.draggable&&t.size!=="fullscreen"&&(n.transform=`translate(${u.value-d}px, ${a.value-y}px)`),n}),x=e.computed(()=>{const n={};return t.draggable&&t.size!=="fullscreen"&&(n.cursor="move"),n}),h=e.computed(()=>{var i;const n={};return t.maxHeight&&(n.maxHeight=`calc(${(i=p(t.maxWidth))==null?void 0:i.replace("%","vh")} - 50px)`),t.size==="fullscreen"&&(n.maxHeight="calc(100% - 50px)"),n});function _(){const n=v.value;if(t.form&&n){const i=n.querySelector(`form[name="${t.form}"]`);i&&i.dispatchEvent(new Event("submit"))}r("submit")}function k(){l==null||l.close(t.id)}function E(){window&&window.addEventListener("resize",()=>{e.triggerRef(m),e.triggerRef(v),d=v.value.offsetLeft,y=v.value.offsetTop})}function M(){if(t.closeable&&t.esc){const n=({key:i})=>{i==="Escape"&&(l==null||l.close(t.id),window.removeEventListener("keydown",n))};window.addEventListener("keydown",n)}}function S(){d=v.value.offsetLeft,y=v.value.offsetTop}return e.onMounted(()=>{M(),E()}),e.onUnmounted(()=>{}),(n,i)=>(e.openBlock(),e.createElementBlock("div",X,[e.createElementVNode("div",{ref_key:"wrapperRef",ref:m,class:"modal-wrapper",onClick:i[0]||(i[0]=e.withModifiers(w=>n.maskClosable&&f(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:"modal-content",style:e.normalizeStyle(b.value)},[n.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:c,class:"modal-header",style:e.normalizeStyle(x.value),onMousedown:S},[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:f})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(h.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",K,[e.createElementVNode("button",{class:"submit-button",form:n.form,type:"submit",onClick:_}," 确定 ",8,G),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:k}," 取消 ")])):e.createCommentVNode("",!0)],4)],512)]))}});const $=(o,s)=>{const t=o.__vccOpts||o;for(const[r,l]of s)t[r]=l;return t},L=$(J,[["__scopeId","data-v-05b670ad"]]),Q={key:0,class:"modal-teleport"},Z={name:"ModalProvider",inheritAttrs:!0},j=e.defineComponent({...Z,props:{appendToBody:{type:Boolean,default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(o,{expose:s}){const t=e.shallowRef([]),r=e.ref(!1);async function l(c,u,a){const f=e.defineAsyncComponent(()=>Promise.resolve(c));return new Promise(p=>{t.value.push({id:Math.random().toString(32).slice(2),component:f,props:u,options:a,resolve:p,onSubmit:e.ref(()=>{})}),e.triggerRef(t)})}function d(c,u){const a=t.value.findIndex(p=>p.id===c);if(a<0)return;const f=t.value[a];f==null||f.resolve(u),t.value.splice(a,1),e.triggerRef(t)}function y(){t.value.forEach(c=>{c.resolve()}),t.value=[],e.triggerRef(t)}function m(c){return t.value.find(u=>u.id===c)}function v(c,u){const a=t.value.find(f=>f.id===c);a&&(a.onSubmit.value=u)}return e.provide(C,{open:l,close:d,closeAll:y,getElement:m,addSubmitListener:v}),s({elements:t}),e.onMounted(()=>{r.value=!0}),(c,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(c.$slots,"default",{},void 0,!0),r.value?(e.openBlock(),e.createElementBlock("div",Q,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!c.appendToBody,to:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,a=>(e.openBlock(),e.createBlock(L,e.mergeProps({id:a.id,key:a.id,component:a.component,"component-props":a.props,"max-height":c.maxHeight,"max-width":c.maxWidth,sizes:c.sizes},a.options,{onSubmit:a.onSubmit.value}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled"]))])):e.createCommentVNode("",!0)],64))}});const ee=$(j,[["__scopeId","data-v-171d9bdd"]]);function A(o,s){var r,l;let t=o==null?void 0:o.parent;for(;t&&((r=t==null?void 0:t.type)==null?void 0:r.name)!==s;)t=t.parent;return((l=t==null?void 0:t.type)==null?void 0:l.name)===s?t:null}function te(){const o=e.inject(C),s=e.getCurrentInstance();return{open(t,r,l){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,r||{},l||{})},close(t){var d;if(!o)throw new Error("Not Found Modal Provider Component");const r=A(s,"ModalContainer"),l=(d=r==null?void 0:r.props)==null?void 0:d.id;if(!l)throw new Error("Not Found Current Modal Container");o.close(l,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},onSubmit(t){const r=A(s,"ModalContainer");if(!(r==null?void 0:r.props.id))throw new Error("Not Found Current Modal Container")}}}function oe(o){var d;const s=e.inject(C),t=e.getCurrentInstance(),r=A(t,"ModalContainer"),l=(d=r==null?void 0:r.props)==null?void 0:d.id;s&&l&&s.addSubmitListener(l,o)}exports.ModalContainer=L;exports.ModalProvider=ee;exports.onSubmit=oe;exports.useModal=te;
package/dist/index.js CHANGED
@@ -1,130 +1,130 @@
1
- import { unref as Q, isRef as U, toRefs as Z, customRef as j, getCurrentScope as ee, onScopeDispose as te, ref as z, computed as A, watch as ne, defineComponent as X, inject as V, shallowRef as H, onMounted as Y, openBlock as g, createElementBlock as x, createElementVNode as C, withModifiers as oe, normalizeStyle as W, toDisplayString as re, createCommentVNode as O, createBlock as N, resolveDynamicComponent as ie, normalizeProps as se, guardReactiveProps as le, triggerRef as P, provide as ae, Fragment as R, renderSlot as ue, Teleport as ce, createVNode as de, TransitionGroup as fe, withCtx as pe, renderList as ve, mergeProps as me, defineAsyncComponent as ye, getCurrentInstance as K } from "vue";
2
- const B = Symbol("__MODAL__");
3
- function he(t) {
1
+ import { unref as J, isRef as Q, toRefs as Z, customRef as j, getCurrentScope as ee, onScopeDispose as te, ref as P, computed as S, watch as ne, defineComponent as X, inject as R, shallowRef as A, onMounted as Y, onUnmounted as oe, openBlock as _, createElementBlock as b, createElementVNode as w, withModifiers as re, normalizeStyle as W, toDisplayString as ie, createCommentVNode as z, createBlock as T, resolveDynamicComponent as se, normalizeProps as le, guardReactiveProps as ae, triggerRef as k, provide as ue, Fragment as I, renderSlot as ce, Teleport as de, createVNode as fe, TransitionGroup as pe, withCtx as me, renderList as ve, mergeProps as ye, defineAsyncComponent as he, getCurrentInstance as K } from "vue";
2
+ const $ = Symbol("__MODAL__");
3
+ function _e(t) {
4
4
  return ee() ? (te(t), !0) : !1;
5
5
  }
6
- function _(t) {
7
- return typeof t == "function" ? t() : Q(t);
6
+ function h(t) {
7
+ return typeof t == "function" ? t() : J(t);
8
8
  }
9
- const G = typeof window < "u" && typeof document < "u", _e = Object.prototype.toString, ge = (t) => _e.call(t) === "[object Object]", be = () => {
9
+ const q = typeof window < "u" && typeof document < "u", ge = Object.prototype.toString, we = (t) => ge.call(t) === "[object Object]", be = () => {
10
10
  };
11
- function we(t, i = {}) {
12
- if (!U(t))
11
+ function xe(t, s = {}) {
12
+ if (!Q(t))
13
13
  return Z(t);
14
14
  const e = Array.isArray(t.value) ? Array.from({ length: t.value.length }) : {};
15
- for (const n in t.value)
16
- e[n] = j(() => ({
15
+ for (const o in t.value)
16
+ e[o] = j(() => ({
17
17
  get() {
18
- return t.value[n];
18
+ return t.value[o];
19
19
  },
20
- set(o) {
20
+ set(r) {
21
21
  var c;
22
- if ((c = _(i.replaceRef)) != null ? c : !0)
22
+ if ((c = h(s.replaceRef)) != null ? c : !0)
23
23
  if (Array.isArray(t.value)) {
24
24
  const p = [...t.value];
25
- p[n] = o, t.value = p;
25
+ p[o] = r, t.value = p;
26
26
  } else {
27
- const p = { ...t.value, [n]: o };
27
+ const p = { ...t.value, [o]: r };
28
28
  Object.setPrototypeOf(p, Object.getPrototypeOf(t.value)), t.value = p;
29
29
  }
30
30
  else
31
- t.value[n] = o;
31
+ t.value[o] = r;
32
32
  }
33
33
  }));
34
34
  return e;
35
35
  }
36
36
  function Ce(t) {
37
- var i;
38
- const e = _(t);
39
- return (i = e == null ? void 0 : e.$el) != null ? i : e;
37
+ var s;
38
+ const e = h(t);
39
+ return (s = e == null ? void 0 : e.$el) != null ? s : e;
40
40
  }
41
- const q = G ? window : void 0;
42
- function D(...t) {
43
- let i, e, n, o;
44
- if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([e, n, o] = t, i = q) : [i, e, n, o] = t, !i)
41
+ const G = q ? window : void 0;
42
+ function N(...t) {
43
+ let s, e, o, r;
44
+ if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([e, o, r] = t, s = G) : [s, e, o, r] = t, !s)
45
45
  return be;
46
- Array.isArray(e) || (e = [e]), Array.isArray(n) || (n = [n]);
47
- const c = [], m = () => {
48
- c.forEach((d) => d()), c.length = 0;
49
- }, p = (d, s, u, v) => (d.addEventListener(s, u, v), () => d.removeEventListener(s, u, v)), f = ne(
50
- () => [Ce(i), _(o)],
51
- ([d, s]) => {
52
- if (m(), !d)
46
+ Array.isArray(e) || (e = [e]), Array.isArray(o) || (o = [o]);
47
+ const c = [], v = () => {
48
+ c.forEach((u) => u()), c.length = 0;
49
+ }, p = (u, l, d, f) => (u.addEventListener(l, d, f), () => u.removeEventListener(l, d, f)), m = ne(
50
+ () => [Ce(s), h(r)],
51
+ ([u, l]) => {
52
+ if (v(), !u)
53
53
  return;
54
- const u = ge(s) ? { ...s } : s;
54
+ const d = we(l) ? { ...l } : l;
55
55
  c.push(
56
- ...e.flatMap((v) => n.map((E) => p(d, v, E, u)))
56
+ ...e.flatMap((f) => o.map((C) => p(u, f, C, d)))
57
57
  );
58
58
  },
59
59
  { immediate: !0, flush: "post" }
60
60
  ), a = () => {
61
- f(), m();
61
+ m(), v();
62
62
  };
63
- return he(a), a;
63
+ return _e(a), a;
64
64
  }
65
- function xe(t, i = {}) {
66
- var e, n;
65
+ function Ee(t, s = {}) {
66
+ var e, o;
67
67
  const {
68
- pointerTypes: o,
68
+ pointerTypes: r,
69
69
  preventDefault: c,
70
- stopPropagation: m,
70
+ stopPropagation: v,
71
71
  exact: p,
72
- onMove: f,
72
+ onMove: m,
73
73
  onEnd: a,
74
- onStart: d,
75
- initialValue: s,
76
- axis: u = "both",
77
- draggingElement: v = q,
78
- containerElement: E,
79
- handle: $ = t
80
- } = i, h = z(
81
- (e = _(s)) != null ? e : { x: 0, y: 0 }
82
- ), b = z(), M = (l) => o ? o.includes(l.pointerType) : !0, S = (l) => {
83
- _(c) && l.preventDefault(), _(m) && l.stopPropagation();
84
- }, L = (l) => {
85
- var w;
86
- if (!M(l) || _(p) && l.target !== _(t))
74
+ onStart: u,
75
+ initialValue: l,
76
+ axis: d = "both",
77
+ draggingElement: f = G,
78
+ containerElement: C,
79
+ handle: B = t
80
+ } = s, y = P(
81
+ (e = h(l)) != null ? e : { x: 0, y: 0 }
82
+ ), g = P(), E = (i) => r ? r.includes(i.pointerType) : !0, M = (i) => {
83
+ h(c) && i.preventDefault(), h(v) && i.stopPropagation();
84
+ }, L = (i) => {
85
+ var x;
86
+ if (!E(i) || h(p) && i.target !== h(t))
87
87
  return;
88
- const F = ((w = _(E)) != null ? w : _(t)).getBoundingClientRect(), I = {
89
- x: l.clientX - F.left,
90
- y: l.clientY - F.top
88
+ const V = ((x = h(C)) != null ? x : h(t)).getBoundingClientRect(), F = {
89
+ x: i.clientX - V.left,
90
+ y: i.clientY - V.top
91
91
  };
92
- (d == null ? void 0 : d(I, l)) !== !1 && (b.value = I, S(l));
93
- }, r = (l) => {
94
- if (!M(l) || !b.value)
92
+ (u == null ? void 0 : u(F, i)) !== !1 && (g.value = F, M(i));
93
+ }, D = (i) => {
94
+ if (!E(i) || !g.value)
95
95
  return;
96
- let { x: w, y: k } = h.value;
97
- (u === "x" || u === "both") && (w = l.clientX - b.value.x), (u === "y" || u === "both") && (k = l.clientY - b.value.y), h.value = {
98
- x: w,
99
- y: k
100
- }, f == null || f(h.value, l), S(l);
101
- }, y = (l) => {
102
- M(l) && b.value && (b.value = void 0, a == null || a(h.value, l), S(l));
96
+ let { x, y: O } = y.value;
97
+ (d === "x" || d === "both") && (x = i.clientX - g.value.x), (d === "y" || d === "both") && (O = i.clientY - g.value.y), y.value = {
98
+ x,
99
+ y: O
100
+ }, m == null || m(y.value, i), M(i);
101
+ }, n = (i) => {
102
+ E(i) && g.value && (g.value = void 0, a == null || a(y.value, i), M(i));
103
103
  };
104
- if (G) {
105
- const l = { capture: (n = i.capture) != null ? n : !0 };
106
- D($, "pointerdown", L, l), D(v, "pointermove", r, l), D(v, "pointerup", y, l);
104
+ if (q) {
105
+ const i = { capture: (o = s.capture) != null ? o : !0 };
106
+ N(B, "pointerdown", L, i), N(f, "pointermove", D, i), N(f, "pointerup", n, i);
107
107
  }
108
108
  return {
109
- ...we(h),
110
- position: h,
111
- isDragging: A(() => !!b.value),
112
- style: A(
113
- () => `left:${h.value.x}px;top:${h.value.y}px;`
109
+ ...xe(y),
110
+ position: y,
111
+ isDragging: S(() => !!g.value),
112
+ style: S(
113
+ () => `left:${y.value.x}px;top:${y.value.y}px;`
114
114
  )
115
115
  };
116
116
  }
117
- const Ee = { class: "modal-container" }, Me = { class: "title font-bold" }, Se = { class: "action" }, ke = {
117
+ const Me = { class: "modal-container" }, Se = { class: "title font-bold" }, ke = { class: "action" }, Ae = {
118
118
  key: 1,
119
119
  class: "modal-footer space-x-2"
120
- }, Ae = ["form"], Pe = {
120
+ }, ze = ["form"], Pe = {
121
121
  name: "ModalContainer",
122
122
  inheritAttrs: !0
123
- }, Oe = /* @__PURE__ */ X({
123
+ }, $e = /* @__PURE__ */ X({
124
124
  ...Pe,
125
125
  props: {
126
126
  id: {},
127
- formId: {},
127
+ form: {},
128
128
  component: {},
129
129
  componentProps: {},
130
130
  width: {},
@@ -141,126 +141,129 @@ const Ee = { class: "modal-container" }, Me = { class: "title font-bold" }, Se =
141
141
  draggable: { type: Boolean, default: !1 }
142
142
  },
143
143
  emits: ["submit"],
144
- setup(t, { emit: i }) {
145
- const e = t, n = i, o = V(B);
146
- let c = 0, m = 0;
147
- const p = H(), f = H(), { x: a, y: d } = xe(f, {
144
+ setup(t, { emit: s }) {
145
+ const e = t, o = s, r = R($);
146
+ let c = 0, v = 0;
147
+ const p = A(), m = A(), a = A(), { x: u, y: l } = Ee(a, {
148
148
  initialValue: { x: 0, y: 0 }
149
149
  });
150
- function s() {
151
- o == null || o.close(e.id);
150
+ function d() {
151
+ r == null || r.close(e.id);
152
152
  }
153
- function u(r) {
154
- if (typeof r == "number")
155
- return `${r}px`;
156
- if (typeof r == "string")
157
- return r;
153
+ function f(n) {
154
+ if (typeof n == "number")
155
+ return `${n}px`;
156
+ if (typeof n == "string")
157
+ return n;
158
158
  }
159
- const v = A(() => {
160
- const r = {};
161
- return e.size && (r.width = u(e.sizes[e.size])), e.width && (r.width = u(e.width)), e.maxWidth && (r.maxWidth = u(e.maxWidth)), e.draggable && (r.transform = `translate(${a.value - c}px, ${d.value - m}px)`), r;
162
- }), E = A(() => {
163
- const r = {};
164
- return e.draggable && (r.cursor = "move"), r;
165
- }), $ = A(() => {
166
- var y;
167
- const r = {};
168
- return e.maxHeight && (r.maxHeight = `calc(${(y = u(e.maxWidth)) == null ? void 0 : y.replace("%", "vh")} - 50px)`), r;
159
+ const C = S(() => {
160
+ const n = {};
161
+ return e.size && (n.width = f(e.sizes[e.size])), e.width && (n.width = f(e.width)), e.maxWidth && (n.maxWidth = f(e.maxWidth)), e.size === "fullscreen" && (n.maxWidth = "unset", n.position = "fixed", n.top = 0, n.left = 0, n.bottom = 0, n.right = 0), e.draggable && e.size !== "fullscreen" && (n.transform = `translate(${u.value - c}px, ${l.value - v}px)`), n;
162
+ }), B = S(() => {
163
+ const n = {};
164
+ return e.draggable && e.size !== "fullscreen" && (n.cursor = "move"), n;
165
+ }), y = S(() => {
166
+ var i;
167
+ const n = {};
168
+ return e.maxHeight && (n.maxHeight = `calc(${(i = f(e.maxWidth)) == null ? void 0 : i.replace("%", "vh")} - 50px)`), e.size === "fullscreen" && (n.maxHeight = "calc(100% - 50px)"), n;
169
169
  });
170
- function h() {
171
- n("submit");
170
+ function g() {
171
+ const n = m.value;
172
+ if (e.form && n) {
173
+ const i = n.querySelector(`form[name="${e.form}"]`);
174
+ i && i.dispatchEvent(new Event("submit"));
175
+ }
176
+ o("submit");
172
177
  }
173
- function b() {
174
- o == null || o.close(e.id);
178
+ function E() {
179
+ r == null || r.close(e.id);
175
180
  }
176
181
  function M() {
177
182
  window && window.addEventListener("resize", () => {
178
- P(p), P(f), c = f.value.offsetLeft, m = f.value.offsetTop;
183
+ k(p), k(m), c = m.value.offsetLeft, v = m.value.offsetTop;
179
184
  });
180
185
  }
181
- function S() {
186
+ function L() {
182
187
  if (e.closeable && e.esc) {
183
- const r = ({ key: y }) => {
184
- y === "Escape" && (o == null || o.close(e.id), window.removeEventListener("keydown", r));
188
+ const n = ({ key: i }) => {
189
+ i === "Escape" && (r == null || r.close(e.id), window.removeEventListener("keydown", n));
185
190
  };
186
- window.addEventListener("keydown", r);
191
+ window.addEventListener("keydown", n);
187
192
  }
188
193
  }
189
- function L() {
190
- new MutationObserver((y) => {
191
- y.forEach((l) => {
192
- const w = f.value.offsetLeft, k = f.value.offsetTop;
193
- w !== c && (c = w), k !== m && (m = w);
194
- });
195
- }).observe(f.value, { attributes: !0, attributeFilter: ["style", "offsetHeight", "offsetWidth", "clientHeight", "clientWidth"], attributeOldValue: !0 });
194
+ function D() {
195
+ c = m.value.offsetLeft, v = m.value.offsetTop;
196
196
  }
197
197
  return Y(() => {
198
- S(), L(), M();
199
- }), (r, y) => (g(), x("div", Ee, [
200
- C("div", {
198
+ L(), M();
199
+ }), oe(() => {
200
+ }), (n, i) => (_(), b("div", Me, [
201
+ w("div", {
201
202
  ref_key: "wrapperRef",
202
203
  ref: p,
203
204
  class: "modal-wrapper",
204
- onClick: y[0] || (y[0] = oe((l) => r.maskClosable && s(), ["self"]))
205
+ onClick: i[0] || (i[0] = re((x) => n.maskClosable && d(), ["self"]))
205
206
  }, [
206
- C("div", {
207
+ w("div", {
207
208
  ref_key: "contentRef",
208
- ref: f,
209
+ ref: m,
209
210
  class: "modal-content",
210
- style: W(v.value)
211
+ style: W(C.value)
211
212
  }, [
212
- r.header ? (g(), x("div", {
213
+ n.header ? (_(), b("div", {
213
214
  key: 0,
214
- ref: "",
215
+ ref_key: "headerRef",
216
+ ref: a,
215
217
  class: "modal-header",
216
- style: W(E.value)
218
+ style: W(B.value),
219
+ onMousedown: D
217
220
  }, [
218
- C("div", Me, re(r.title), 1),
219
- C("div", Se, [
220
- r.closeable ? (g(), x("div", {
221
+ w("div", Se, ie(n.title), 1),
222
+ w("div", ke, [
223
+ n.closeable ? (_(), b("div", {
221
224
  key: 0,
222
225
  class: "i-icon-park-outline:close block cursor-pointer",
223
- onClick: s
224
- })) : O("", !0)
226
+ onClick: d
227
+ })) : z("", !0)
225
228
  ])
226
- ], 4)) : O("", !0),
227
- C("div", {
229
+ ], 36)) : z("", !0),
230
+ w("div", {
228
231
  class: "modal-body",
229
- style: W($.value)
232
+ style: W(y.value)
230
233
  }, [
231
- (g(), N(ie(r.component), se(le(r.componentProps)), null, 16))
234
+ (_(), T(se(n.component), le(ae(n.componentProps)), null, 16))
232
235
  ], 4),
233
- r.footer ? (g(), x("div", ke, [
234
- C("button", {
236
+ n.footer ? (_(), b("div", Ae, [
237
+ w("button", {
235
238
  class: "submit-button",
236
- form: r.formId,
239
+ form: n.form,
237
240
  type: "submit",
238
- onClick: h
239
- }, " 确定 ", 8, Ae),
240
- C("button", {
241
+ onClick: g
242
+ }, " 确定 ", 8, ze),
243
+ w("button", {
241
244
  class: "cancel-button",
242
245
  type: "button",
243
- onClick: b
246
+ onClick: E
244
247
  }, " 取消 ")
245
- ])) : O("", !0)
248
+ ])) : z("", !0)
246
249
  ], 4)
247
250
  ], 512)
248
251
  ]));
249
252
  }
250
253
  });
251
- const J = (t, i) => {
254
+ const U = (t, s) => {
252
255
  const e = t.__vccOpts || t;
253
- for (const [n, o] of i)
254
- e[n] = o;
256
+ for (const [o, r] of s)
257
+ e[o] = r;
255
258
  return e;
256
- }, ze = /* @__PURE__ */ J(Oe, [["__scopeId", "data-v-16717585"]]), Be = {
259
+ }, Be = /* @__PURE__ */ U($e, [["__scopeId", "data-v-05b670ad"]]), Le = {
257
260
  key: 0,
258
261
  class: "modal-teleport"
259
- }, $e = {
262
+ }, De = {
260
263
  name: "ModalProvider",
261
264
  inheritAttrs: !0
262
- }, Le = /* @__PURE__ */ X({
263
- ...$e,
265
+ }, Oe = /* @__PURE__ */ X({
266
+ ...De,
264
267
  props: {
265
268
  appendToBody: { type: Boolean, default: !1 },
266
269
  sizes: { default: () => ({
@@ -271,105 +274,105 @@ const J = (t, i) => {
271
274
  maxWidth: { default: "80%" },
272
275
  maxHeight: { default: "80%" }
273
276
  },
274
- setup(t, { expose: i }) {
275
- const e = H([]), n = z(!1);
276
- async function o(a, d, s) {
277
- const u = ye(
277
+ setup(t, { expose: s }) {
278
+ const e = A([]), o = P(!1);
279
+ async function r(a, u, l) {
280
+ const d = he(
278
281
  () => Promise.resolve(a)
279
282
  );
280
- return new Promise((v) => {
283
+ return new Promise((f) => {
281
284
  e.value.push({
282
285
  id: Math.random().toString(32).slice(2),
283
- component: u,
284
- props: d,
285
- options: s,
286
- resolve: v,
287
- onSubmit: z(() => {
286
+ component: d,
287
+ props: u,
288
+ options: l,
289
+ resolve: f,
290
+ onSubmit: P(() => {
288
291
  })
289
- }), P(e);
292
+ }), k(e);
290
293
  });
291
294
  }
292
- function c(a, d) {
293
- const s = e.value.findIndex((v) => v.id === a);
294
- if (s < 0)
295
+ function c(a, u) {
296
+ const l = e.value.findIndex((f) => f.id === a);
297
+ if (l < 0)
295
298
  return;
296
- const u = e.value[s];
297
- u == null || u.resolve(d), e.value.splice(s, 1), P(e);
299
+ const d = e.value[l];
300
+ d == null || d.resolve(u), e.value.splice(l, 1), k(e);
298
301
  }
299
- function m() {
302
+ function v() {
300
303
  e.value.forEach((a) => {
301
304
  a.resolve();
302
- }), e.value = [], P(e);
305
+ }), e.value = [], k(e);
303
306
  }
304
307
  function p(a) {
305
- return e.value.find((d) => d.id === a);
308
+ return e.value.find((u) => u.id === a);
306
309
  }
307
- function f(a, d) {
308
- const s = e.value.find((u) => u.id === a);
309
- s && (s.onSubmit.value = d);
310
+ function m(a, u) {
311
+ const l = e.value.find((d) => d.id === a);
312
+ l && (l.onSubmit.value = u);
310
313
  }
311
- return ae(B, {
312
- open: o,
314
+ return ue($, {
315
+ open: r,
313
316
  close: c,
314
- closeAll: m,
317
+ closeAll: v,
315
318
  getElement: p,
316
- addSubmitListener: f
317
- }), i({
319
+ addSubmitListener: m
320
+ }), s({
318
321
  elements: e
319
322
  }), Y(() => {
320
- n.value = !0;
321
- }), (a, d) => (g(), x(R, null, [
322
- ue(a.$slots, "default", {}, void 0, !0),
323
- n.value ? (g(), x("div", Be, [
324
- (g(), N(ce, {
323
+ o.value = !0;
324
+ }), (a, u) => (_(), b(I, null, [
325
+ ce(a.$slots, "default", {}, void 0, !0),
326
+ o.value ? (_(), b("div", Le, [
327
+ (_(), T(de, {
325
328
  disabled: !a.appendToBody,
326
329
  to: "body"
327
330
  }, [
328
- de(fe, { name: "modal-fade" }, {
329
- default: pe(() => [
330
- (g(!0), x(R, null, ve(e.value, (s) => (g(), N(ze, me({
331
- id: s.id,
332
- key: s.id,
333
- component: s.component,
334
- "component-props": s.props,
331
+ fe(pe, { name: "modal-fade" }, {
332
+ default: me(() => [
333
+ (_(!0), b(I, null, ve(e.value, (l) => (_(), T(Be, ye({
334
+ id: l.id,
335
+ key: l.id,
336
+ component: l.component,
337
+ "component-props": l.props,
335
338
  "max-height": a.maxHeight,
336
339
  "max-width": a.maxWidth,
337
340
  sizes: a.sizes
338
- }, s.options, {
339
- onSubmit: s.onSubmit.value
341
+ }, l.options, {
342
+ onSubmit: l.onSubmit.value
340
343
  }), null, 16, ["id", "component", "component-props", "max-height", "max-width", "sizes", "onSubmit"]))), 128))
341
344
  ]),
342
345
  _: 1
343
346
  })
344
347
  ], 8, ["disabled"]))
345
- ])) : O("", !0)
348
+ ])) : z("", !0)
346
349
  ], 64));
347
350
  }
348
351
  });
349
- const De = /* @__PURE__ */ J(Le, [["__scopeId", "data-v-171d9bdd"]]);
350
- function T(t, i) {
351
- var n, o;
352
+ const Ne = /* @__PURE__ */ U(Oe, [["__scopeId", "data-v-171d9bdd"]]);
353
+ function H(t, s) {
354
+ var o, r;
352
355
  let e = t == null ? void 0 : t.parent;
353
- for (; e && ((n = e == null ? void 0 : e.type) == null ? void 0 : n.name) !== i; )
356
+ for (; e && ((o = e == null ? void 0 : e.type) == null ? void 0 : o.name) !== s; )
354
357
  e = e.parent;
355
- return ((o = e == null ? void 0 : e.type) == null ? void 0 : o.name) === i ? e : null;
358
+ return ((r = e == null ? void 0 : e.type) == null ? void 0 : r.name) === s ? e : null;
356
359
  }
357
- function He() {
358
- const t = V(B), i = K();
360
+ function Te() {
361
+ const t = R($), s = K();
359
362
  return {
360
- open(e, n, o) {
363
+ open(e, o, r) {
361
364
  if (!t)
362
365
  throw new Error("Not Found Modal Provider Component");
363
- return t.open(e, n || {}, o || {});
366
+ return t.open(e, o || {}, r || {});
364
367
  },
365
368
  close(e) {
366
369
  var c;
367
370
  if (!t)
368
371
  throw new Error("Not Found Modal Provider Component");
369
- const n = T(i, "ModalContainer"), o = (c = n == null ? void 0 : n.props) == null ? void 0 : c.id;
370
- if (!o)
372
+ const o = H(s, "ModalContainer"), r = (c = o == null ? void 0 : o.props) == null ? void 0 : c.id;
373
+ if (!r)
371
374
  throw new Error("Not Found Current Modal Container");
372
- t.close(o, e);
375
+ t.close(r, e);
373
376
  },
374
377
  closeAll() {
375
378
  if (!t)
@@ -377,20 +380,20 @@ function He() {
377
380
  t.closeAll();
378
381
  },
379
382
  onSubmit(e) {
380
- const n = T(i, "ModalContainer");
381
- if (!(n == null ? void 0 : n.props.id))
383
+ const o = H(s, "ModalContainer");
384
+ if (!(o == null ? void 0 : o.props.id))
382
385
  throw new Error("Not Found Current Modal Container");
383
386
  }
384
387
  };
385
388
  }
386
- function Ne(t) {
389
+ function He(t) {
387
390
  var c;
388
- const i = V(B), e = K(), n = T(e, "ModalContainer"), o = (c = n == null ? void 0 : n.props) == null ? void 0 : c.id;
389
- i && o && i.addSubmitListener(o, t);
391
+ const s = R($), e = K(), o = H(e, "ModalContainer"), r = (c = o == null ? void 0 : o.props) == null ? void 0 : c.id;
392
+ s && r && s.addSubmitListener(r, t);
390
393
  }
391
394
  export {
392
- ze as ModalContainer,
393
- De as ModalProvider,
394
- Ne as onSubmit,
395
- He as useModal
395
+ Be as ModalContainer,
396
+ Ne as ModalProvider,
397
+ He as onSubmit,
398
+ Te as useModal
396
399
  };
@@ -13,8 +13,9 @@ export interface OpenModalOptions {
13
13
  header?: boolean;
14
14
  footer?: boolean;
15
15
  width?: number | string;
16
- size?: 'large' | 'middle' | 'small';
16
+ size?: 'large' | 'middle' | 'small' | 'fullscreen';
17
17
  draggable?: boolean;
18
+ form?: string;
18
19
  }
19
20
  export interface ModalElement extends OpenModalOptions {
20
21
  id: string;
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}.fixed{position:fixed}.block{display:block}.flex{display:flex}.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))}.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-16717585]{z-index:1000;position:fixed;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,.3)}.modal-content[data-v-16717585]{background:#ffffff;border-radius:5px}.modal-header[data-v-16717585]{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-16717585]{padding:20px 10px;box-sizing:border-box;max-height:10vw;overflow:auto}.modal-footer[data-v-16717585]{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-16717585]{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-16717585]{color:#fff;background-color:var(--primary-6, #2D6AFB)}.modal-footer button.submit-button[data-v-16717585]:hover{background-color:var(--primary-5, #1C4CCF)}.modal-footer button.cancel-button[data-v-16717585]{color:var(--color-text-2, #4E5969);background-color:var(--color-fill-1, #F5F5F5)}.modal-footer button.cancel-button[data-v-16717585]:hover{background-color:var(--color-fill-4, #C9CDD4)}.modal-fade-enter-active[data-v-171d9bdd],.modal-fade-leave-active[data-v-171d9bdd]{transition:all .5s ease}.modal-fade-enter-from[data-v-171d9bdd],.modal-fade-leave-to[data-v-171d9bdd]{opacity: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}.fixed{position:fixed}.block{display:block}.flex{display:flex}.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))}.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-05b670ad]{z-index:1000;position:fixed;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,.3)}.modal-content[data-v-05b670ad]{background:#ffffff;border-radius:5px}.modal-header[data-v-05b670ad]{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-05b670ad]{padding:20px 10px;box-sizing:border-box;max-height:10vw;overflow:auto}.modal-footer[data-v-05b670ad]{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-05b670ad]{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-05b670ad]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-05b670ad]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-05b670ad]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-05b670ad]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-fade-enter-active[data-v-171d9bdd],.modal-fade-leave-active[data-v-171d9bdd]{transition:all .5s ease}.modal-fade-enter-from[data-v-171d9bdd],.modal-fade-leave-to[data-v-171d9bdd]{opacity: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.1",
4
+ "version": "0.0.3",
5
5
  "author": {
6
6
  "name": "zhuchentong",
7
7
  "email": "2037630@gmail.com"