vue-devui 1.0.0-alpha.5 → 1.0.0-beta.11
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.
- package/README.md +31 -36
- package/accordion/index.d.ts +7 -0
- package/accordion/index.es.js +508 -1
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +175 -1
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/anchor/index.es.js +263 -1
- package/anchor/index.umd.js +1 -1
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +301 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.d.ts +7 -0
- package/back-top/index.es.js +128 -0
- package/back-top/index.umd.js +1 -0
- package/back-top/package.json +7 -0
- package/back-top/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +95 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/breadcrumb/index.es.js +127 -1
- package/breadcrumb/index.umd.js +1 -1
- package/button/index.d.ts +7 -0
- package/button/index.es.js +392 -1
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +61 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +329 -1
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1343 -1
- package/cascader/index.umd.js +1 -1
- package/cascader/style.css +1 -1
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +377 -1
- package/checkbox/index.umd.js +1 -1
- package/comment/index.d.ts +7 -0
- package/comment/index.es.js +85 -0
- package/comment/index.umd.js +1 -0
- package/comment/package.json +7 -0
- package/comment/style.css +1 -0
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +176 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker/index.d.ts +7 -0
- package/date-picker/index.es.js +1172 -1
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.d.ts +7 -0
- package/dragdrop/index.es.js +32 -0
- package/dragdrop/index.umd.js +1 -0
- package/dragdrop/package.json +7 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +287 -0
- package/drawer/index.umd.js +1 -0
- package/drawer/package.json +7 -0
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +527 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +5857 -1
- package/editable-select/index.umd.js +27 -1
- package/editable-select/style.css +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +2244 -0
- package/form/index.umd.js +1 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +163 -1
- package/fullscreen/index.umd.js +1 -1
- package/gantt/index.d.ts +7 -0
- package/gantt/index.es.js +535 -0
- package/gantt/index.umd.js +1 -0
- package/gantt/package.json +7 -0
- package/gantt/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +269 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +75 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +480 -1
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +190 -1
- package/input/index.umd.js +1 -1
- package/input-icon/index.d.ts +7 -0
- package/input-icon/index.es.js +332 -0
- package/input-icon/index.umd.js +1 -0
- package/input-icon/package.json +7 -0
- package/input-icon/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +240 -1
- package/input-number/index.umd.js +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +100 -0
- package/layout/index.umd.js +1 -0
- package/layout/package.json +7 -0
- package/layout/style.css +1 -0
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +256 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +1225 -1
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nav-sprite/index.es.js +742 -0
- package/nav-sprite/index.umd.js +1 -0
- package/nav-sprite/package.json +7 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Toast.js +3 -0
- package/nuxt/components/ToastService.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +368 -1
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -34
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +642 -1
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +205 -1
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +236 -1
- package/popover/index.umd.js +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +153 -1
- package/progress/index.umd.js +3 -1
- package/quadrant-diagram/index.d.ts +7 -0
- package/quadrant-diagram/index.es.js +489 -1
- package/quadrant-diagram/index.umd.js +1 -1
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +225 -1
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +220 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.d.ts +7 -0
- package/read-tip/index.es.js +258 -0
- package/read-tip/index.umd.js +1 -0
- package/read-tip/package.json +7 -0
- package/read-tip/style.css +1 -0
- package/result/index.d.ts +7 -0
- package/result/index.es.js +119 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.d.ts +7 -0
- package/ripple/index.es.js +181 -1
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +543 -1
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +706 -1
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +297 -1
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +199 -1
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +636 -1
- package/splitter/index.umd.js +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +280 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +42 -1
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +239 -1
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/sticky/index.es.js +197 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +100 -1
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1828 -1
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +195 -1
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +131 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/tag-input/index.d.ts +7 -0
- package/tag-input/index.es.js +329 -1
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +132 -0
- package/textarea/index.umd.js +1 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/time-axis/index.d.ts +7 -0
- package/time-axis/index.es.js +299 -0
- package/time-axis/index.umd.js +1 -0
- package/time-axis/package.json +7 -0
- package/time-axis/style.css +1 -0
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +1255 -1
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.d.ts +7 -0
- package/toast/index.es.js +2060 -1
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +171 -1
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +1725 -1
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +907 -1
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/tree-select/index.d.ts +7 -0
- package/tree-select/index.es.js +528 -0
- package/tree-select/index.umd.js +1 -0
- package/tree-select/package.json +7 -0
- package/tree-select/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +2834 -1
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +27743 -1
- package/vue-devui.umd.js +29 -1
package/modal/index.es.js
CHANGED
|
@@ -1 +1,1225 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,i=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,r=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&i(e,n,t[n]);if(o)for(var n of o(t))a.call(t,n)&&i(e,n,t[n]);return e},d=(e,o)=>t(e,n(o)),s=("undefined"!=typeof require&&require,(e,t)=>{var n={};for(var i in e)l.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&o)for(var i of o(e))t.indexOf(i)<0&&a.call(e,i)&&(n[i]=e[i]);return n}),u=(e,t,n)=>(i(e,"symbol"!=typeof t?t+"":t,n),n);import{defineComponent as c,createVNode as p,Teleport as f,Transition as y,renderSlot as v,isVNode as b,computed as m,onMounted as g,watch as h,onUnmounted as w,withDirectives as C,vShow as x,ref as k,reactive as S,getCurrentInstance as B,nextTick as E,toRef as O,onBeforeUnmount as V,isRef as L,h as $,render as j,readonly as M,mergeProps as R}from"vue";const Y={width:{type:String,default:"300px"},maxHeight:{type:String},zIndex:{type:Number,default:1050},backdropZIndex:{type:Number,default:1049},placement:{type:String,default:"center"},offsetX:{type:String,default:"0px"},offsetY:{type:String,default:"0px"},showAnimation:{type:Boolean,default:!0},backdropCloseable:{type:Boolean,default:!1},bodyScrollable:{type:Boolean,default:!0},escapeable:{type:Boolean,default:!0},onClose:{type:Function},beforeHidden:{type:[Object,Function]},modelValue:{type:Boolean},"onUpdate:modelValue":{type:Function}};const I=c({setup:(e,t)=>()=>{let e;return p(f,{to:"#d-overlay-anchor"},{default:()=>{return[p(y,{name:"devui-overlay-fade"},(n=e=v(t.slots,"default"),"function"==typeof n||"[object Object]"===Object.prototype.toString.call(n)&&!b(n)?e:{default:()=>[e]}))];var n}})}}),z={visible:{type:Boolean},"onUpdate:visible":{type:Function},backgroundBlock:{type:Boolean,default:!1},backgroundClass:{type:String,default:""},backgroundStyle:{type:[String,Object]},backdropClick:{type:Function},backdropClose:{type:Boolean,default:!0}};function X(e){const t=m((()=>["devui-overlay-background","devui-overlay-background__color",e.backgroundClass])),n=m((()=>"devui-overlay"));return g((()=>{const t=document.body,n=t.style.overflow,o=t.style.position;h([()=>e.visible,()=>e.backgroundBlock],(([e,l])=>{if(l){const l=t.getBoundingClientRect().y;e?(t.style.overflowY="scroll",t.style.position=e?"fixed":"",t.style.top=`${l}px`):(t.style.overflowY=n,t.style.position=o,t.style.top="",window.scrollTo(0,-l))}})),w((()=>{document.body.style.overflow=n}))})),{backgroundClass:t,overlayClass:n,handleBackdropClick:t=>{var n,o;t.preventDefault(),null==(n=e.backdropClick)||n.call(e),e.backdropClose&&(null==(o=e["onUpdate:visible"])||o.call(e,!1))},handleOverlayBubbleCancel:e=>e.cancelBubble=!0}}const H=c({name:"DFixedOverlay",props:d(r({},z),{overlayStyle:{type:Object,default:void 0}}),setup(e,t){const{backgroundClass:n,overlayClass:o,handleBackdropClick:l,handleOverlayBubbleCancel:a}=X(e);return()=>p(I,null,{default:()=>[C(p("div",{class:n.value,style:e.backgroundStyle,onClick:l},[p("div",{class:o.value,style:e.overlayStyle,onClick:a},[v(t.slots,"default")])]),[[x,e.visible]])]})}}),D=c({name:"DFlexibleOverlay",props:r({origin:{type:Object,require:!0},position:{type:Object,default:()=>({originX:"left",originY:"top",overlayX:"left",overlayY:"top"})}},z),emits:["onUpdate:visible"],setup(e,t){const n=k(null),o=S({position:"absolute"}),l=B();g((async()=>{await E();const t=n.value;if(!t)return;const a=function(e){if(e instanceof Element)return e;if(L(e))return function(e){if(e instanceof Element)return e;if(e&&"object"==typeof e&&e.$el instanceof Element)return e.$el;return null}(e.value);return e}(e.origin);if(!a)return;const i=t=>{const n=function(e,t,n){const o=function(e,t){let n,o;if("center"==t.originX)n=e.left+e.width/2;else{const o=e.left,l=e.right;n="left"==t.originX?o:l}o="center"==t.originY?e.top+e.height/2:"top"==t.originY?e.top:e.bottom;return{x:n,y:o}}(function(e){if(e instanceof Element)return e.getBoundingClientRect();const t=e.width||0,n=e.height||0;return{top:e.y,bottom:e.y+n,left:e.x,right:e.x+t,height:n,width:t}}(n),e);let l;l=t instanceof HTMLElement?t.getBoundingClientRect():t;return function(e,t,n){let o;const{width:l,height:a}=t;o="center"==n.overlayX?e.x-l/2:"left"==n.overlayX?e.x:e.x-l;let i;i="center"==n.overlayY?e.y-a/2:"top"==n.overlayY?e.y:e.y-a;return{x:o,y:i}}(o,l,e)}(e.position,t,a);o.left=`${n.x}px`,o.top=`${n.y}px`},r=()=>i(t.getBoundingClientRect());h(O(e,"visible"),((e,t,n)=>{var o;e?(o=r,window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),window.addEventListener("orientationchange",o)):U(r),n((()=>{U(r)}))})),h(O(e,"position"),(()=>{r()}));const d=new ResizeObserver((e=>{i(e[0].contentRect)}));if(d.observe(t),V((()=>{d.disconnect()}),l),a instanceof Element){const e=new MutationObserver(r);e.observe(a,{attributeFilter:["style"]}),V((()=>{e.disconnect()}),l)}}),l);const{backgroundClass:a,overlayClass:i,handleBackdropClick:r,handleOverlayBubbleCancel:d}=X(e);return()=>p(I,null,{default:()=>[C(p("div",{class:a.value,onClick:r},[p("div",{ref:n,class:i.value,style:o,onClick:d},[v(t.slots,"default")])]),[[x,e.visible]])]})}});function U(e){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}const F="undefined"!=typeof window;D.install=function(e){e.component(D.name,D)},H.install=function(e){e.component(H.name,H)};var N=c({name:"DModal",props:Y,emits:["onUpdate:modelValue"],setup(e,t){const n=m((()=>!e.showAnimation||e.modelValue)),o=t=>{var n;const o=e["onUpdate:modelValue"];if(t)null==o||o(t);else{const t=e.beforeHidden,l=t=>{var n;t&&(null==o||o(!1),null==(n=e.onClose)||n.call(e))},a=null==(n="function"==typeof t?t():t)||n;a instanceof Promise?a.then(l):l(a)}};return t.expose({onVisibleChange:o}),()=>p(H,{visible:e.modelValue,"onUpdate:visible":o,backgroundClass:"devui-modal-wrapper",backgroundBlock:!e.bodyScrollable,backdropClose:e.backdropCloseable},{default:()=>[p(y,{name:"devui-modal-wipe"},{default:()=>{var e,o;return[n.value?null==(o=(e=t.slots).default)?void 0:o.call(e):null]}})]})}});class P{constructor(e){this.anchorContainer=e}renderModal(e,t,n){const o=$(this.component(),t,n);return j(o,e),o}renderNull(e){setTimeout((()=>{j(null,e)}),500)}}class T extends P{component(){return N}open(e={}){const t=document.createElement("div");this.anchorContainer.appendChild(t);const n=e,{content:o}=n,l=s(n,["content"]),a=e=>{e||u()},i=(e,n=a)=>this.renderModal(t,d(r({},e),{modelValue:!0,"onUpdate:modelValue":n}),{default:o}),u=()=>{var e,n;null==(n=(e=i(l,(e=>{e?i(l):(this.renderModal(t,d(r({},l),{modelValue:!1})),this.renderNull(t))})).component.exposed).onVisibleChange)||n.call(e,!1)};return this.renderModal(t,{modelValue:!1}),i(l),{hide:u}}}u(T,"token","MODAL_SERVICE_TOKEN");const A={width:{type:String,default:"300px"},maxHeight:{type:String},zIndex:{type:Number,default:1050},backdropZIndex:{type:Number,default:1049},placement:{type:String,default:"center"},offsetX:{type:String,default:"0px"},offsetY:{type:String,default:"0px"},title:{type:String},showAnimation:{type:Boolean,default:!0},backdropCloseable:{type:Boolean,default:!1},bodyScrollable:{type:Boolean,default:!0},escapeable:{type:Boolean,default:!0},onClose:{type:Function},beforeHidden:{type:[Promise,Function]},buttons:{type:Array,default:[]},dialogType:{type:String,default:"standard"},modelValue:{type:Boolean},"onUpdate:modelValue":{type:Function}},_=(e,t,n)=>e<t?t:e>n?n:e;var q=c({name:"DIcon",props:{name:{type:String,required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}},setup:e=>r({},e),render(){const{name:e,size:t,color:n,classPrefix:o}=this;return p("i",{class:`${o} ${o}-${e}`,style:{fontSize:t,color:n}},null)}});q.install=function(e){e.component(q.name,q)};var Z=c({name:"DButton",props:{type:{type:String,default:"button"},btnStyle:{type:String,default:"primary"},size:{type:String,default:"md"},position:{type:String,default:"default"},bordered:{type:Boolean,default:!1},icon:{type:String,default:""},showLoading:{type:Boolean,default:!1},width:{type:String},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},onClick:{type:Function}},setup(e,t){const n=k(null),o=t=>{var n;e.showLoading||null==(n=e.onClick)||n.call(e,t)},l=m((()=>t.slots.default)),a=m((()=>{const{btnStyle:t,size:n,position:o,bordered:a,icon:i}=e;return`${`devui-btn devui-btn-${t} devui-btn-${n} devui-btn-${o}`} ${a?"bordered":""} ${i&&!l.value&&"primary"!==t?"d-btn-icon":""} ${i?"d-btn-icon-wrap":""}`})),i=m((()=>{if(!e.icon)return;const t="devui-icon-fix icon";return l.value?`${t} clear-right-5`:t}));return()=>{var l,r;const{icon:d,type:s,disabled:u,showLoading:c,width:f}=e;return p("div",R({class:"devui-btn-host"},t.attrs),[p("button",{class:a.value,type:s,disabled:u,style:{width:f},onClick:o},[d?p(q,{name:e.icon,class:i.value},null):null,p("span",{class:"button-content",ref:n},[null==(r=(l=t.slots).default)?void 0:r.call(l)])])])}}});Z.install=function(e){e.component(Z.name,Z)};var K=c({name:"DModal",inheritAttrs:!1,props:A,emits:["onUpdate:modelValue"],setup(e,t){const{movingX:n,movingY:o,handleRef:l,moveElRef:a,reset:i}=((e=!0)=>{const t=k(0),n=k(0),o=k(),l=k(),a=L(e)?e:k(e);return h([l,o],(([e,o],l,i)=>{if(!(o instanceof HTMLElement&&e instanceof HTMLElement))return;o.style.cursor="all-scroll";let r=0,d=0,s=0,u=0,c=e.getBoundingClientRect(),p=document.body.getBoundingClientRect(),f=!1;const y=l=>{if(l.preventDefault(),!a.value)return;r=l.clientX,d=l.clientY;const i=o.getBoundingClientRect();(o===l.target||o.contains(l.target))&&i.x<r&&i.y<d&&i.width+i.x>=r&&i.height+i.y>=d&&(f=!0,s=t.value,u=n.value,p=document.body.getBoundingClientRect(),c=e.getBoundingClientRect())},v=e=>{if(e.preventDefault(),!f)return;const o=s+e.clientX-r,l=u+e.clientY-d,a=c.x-s,i=c.y-u;t.value=_(o,-a,p.width-c.width-a),n.value=_(l,-i,p.height-c.height-i)},b=e=>{e.preventDefault(),f&&(f=!1)};window.addEventListener("mousedown",y),window.addEventListener("mousemove",v),window.addEventListener("mouseup",b),i((()=>{window.removeEventListener("mousedown",y),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b)}))})),{movingX:M(t),movingY:M(n),handleRef:o,moveElRef:l,reset:()=>{t.value=0,n.value=0}}})();h((()=>e.modelValue),(e=>{e&&i()}));const r=m((()=>({position:"relative",left:`${n.value}px`,top:`${o.value}px`}))),d=m((()=>({width:e.width,maxHeight:e.maxHeight,transform:`translate(${e.offsetX}, ${e.offsetY})`,zIndex:e.zIndex}))),s=m((()=>{switch(e.dialogType){case"standard":return"";case"info":return"icon-info-o";case"success":return"icon-right-o";case"warning":return"icon-warning-o";case"failed":return"icon-error-o";default:return""}})),u=m((()=>e.buttons.map(((e,t)=>{const{btnStyle:n,disabled:o,handler:l,text:a}=e;return p(Z,{key:t,style:{display:"inline-block",margin:"0 5px"},btnStyle:n,disabled:o,onClick:l},"function"==typeof(i=a)||"[object Object]"===Object.prototype.toString.call(i)&&!b(i)?a:{default:()=>[a]});var i})))),c=k(),f=()=>{var e,t;null==(t=null==(e=c.value)?void 0:e.onVisibleChange)||t.call(e,!1)};return t.expose({closeModal:f}),()=>p(N,{ref:c,width:e.width,maxHeight:e.maxHeight,offsetX:e.offsetX,offsetY:e.offsetY,zIndex:e.zIndex,backdropZIndex:e.backdropZIndex,backdropCloseable:e.backdropCloseable,bodyScrollable:e.bodyScrollable,placement:e.placement,onClose:e.onClose,beforeHidden:e.beforeHidden,modelValue:e.modelValue,"onUpdate:modelValue":e["onUpdate:modelValue"]},{default:()=>{var n,o;return[p("div",{class:"devui-modal-content",style:[d.value,r.value],ref:a},[p("div",{class:"devui-modal-header",ref:l},[s.value?p(q,{name:s.value,size:"24px",class:"header-alert-icon"},null):null,p("span",null,[e.title]),p(Z,{class:"btn-close",icon:"close",btnStyle:"text-dark",onClick:f},null)]),p("div",{class:"devui-modal-body"},[null==(o=(n=t.slots).default)?void 0:o.call(n)]),p("div",{class:"devui-modal-footer"},[u.value])])]}})}});class G extends P{component(){return K}open(e={}){const t=document.createElement("div");this.anchorContainer.appendChild(t);const n=e,{content:o}=n,l=s(n,["content"]),a=e=>{e||u()},i=(e,n=a)=>this.renderModal(t,d(r({},e),{modelValue:!0,"onUpdate:modelValue":n}),{default:o}),u=()=>{var e,n;null==(n=(e=i(l,(e=>{e?i(l):(this.renderModal(t,d(r({},l),{modelValue:!1})),this.renderNull(t))})).component.exposed).closeModal)||n.call(e)};return this.renderModal(t,{modelValue:!1}),i(l),{hide:u,updateButtonOptions:e=>{const t=l,{buttons:n}=t,o=s(t,["buttons"]),a=n.map(((t,n)=>r(r({},t),e[n])));i(d(r({},o),{buttons:a}))}}}}u(G,"token","DIALOG_SERVICE_TOKEN"),N.install=function(e){e.component(N.name,N)};var J={title:"Modal 弹窗",category:"反馈",status:void 0,install(e){if(e.use(N),!F)return;let t=document.getElementById("d-modal-anchors-container");t||(t=document.createElement("div"),t.setAttribute("id","d-modal-anchors-container"),document.body.appendChild(t)),e.provide(T.token,new T(t)),e.provide(G.token,new G(t))}};export{N as Modal,J as default};
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __publicField = (obj, key, value) => {
|
|
33
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
36
|
+
import { defineComponent, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, withDirectives, vShow, ref, reactive, toRef, isRef, h, render, readonly, mergeProps, resolveDirective } from "vue";
|
|
37
|
+
const modalProps = {
|
|
38
|
+
width: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "300px"
|
|
41
|
+
},
|
|
42
|
+
maxHeight: {
|
|
43
|
+
type: String
|
|
44
|
+
},
|
|
45
|
+
zIndex: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 1050
|
|
48
|
+
},
|
|
49
|
+
backdropZIndex: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 1049
|
|
52
|
+
},
|
|
53
|
+
placement: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "center"
|
|
56
|
+
},
|
|
57
|
+
offsetX: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: "0px"
|
|
60
|
+
},
|
|
61
|
+
offsetY: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: "0px"
|
|
64
|
+
},
|
|
65
|
+
showAnimation: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
backdropCloseable: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
},
|
|
73
|
+
bodyScrollable: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true
|
|
76
|
+
},
|
|
77
|
+
escapeable: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: true
|
|
80
|
+
},
|
|
81
|
+
onClose: {
|
|
82
|
+
type: Function
|
|
83
|
+
},
|
|
84
|
+
beforeHidden: {
|
|
85
|
+
type: [Object, Function]
|
|
86
|
+
},
|
|
87
|
+
modelValue: {
|
|
88
|
+
type: Boolean
|
|
89
|
+
},
|
|
90
|
+
"onUpdate:modelValue": {
|
|
91
|
+
type: Function
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var overlay = "";
|
|
95
|
+
function _isSlot$1(s) {
|
|
96
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
97
|
+
}
|
|
98
|
+
const CommonOverlay = defineComponent({
|
|
99
|
+
setup(props, ctx) {
|
|
100
|
+
return () => {
|
|
101
|
+
let _slot;
|
|
102
|
+
return createVNode(Teleport, {
|
|
103
|
+
"to": "#d-overlay-anchor"
|
|
104
|
+
}, {
|
|
105
|
+
default: () => [createVNode(Transition, {
|
|
106
|
+
"name": "devui-overlay-fade"
|
|
107
|
+
}, _isSlot$1(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
108
|
+
default: () => [_slot]
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const overlayProps = {
|
|
115
|
+
visible: {
|
|
116
|
+
type: Boolean
|
|
117
|
+
},
|
|
118
|
+
backgroundBlock: {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
default: false
|
|
121
|
+
},
|
|
122
|
+
backgroundClass: {
|
|
123
|
+
type: String,
|
|
124
|
+
default: ""
|
|
125
|
+
},
|
|
126
|
+
backgroundStyle: {
|
|
127
|
+
type: [String, Object]
|
|
128
|
+
},
|
|
129
|
+
onBackdropClick: {
|
|
130
|
+
type: Function
|
|
131
|
+
},
|
|
132
|
+
backdropClose: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
default: true
|
|
135
|
+
},
|
|
136
|
+
hasBackdrop: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: true
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
142
|
+
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
143
|
+
overlayStyle: {
|
|
144
|
+
type: [String, Object],
|
|
145
|
+
default: void 0
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const flexibleOverlayProps = __spreadValues({
|
|
149
|
+
origin: {
|
|
150
|
+
type: Object,
|
|
151
|
+
require: true
|
|
152
|
+
},
|
|
153
|
+
position: {
|
|
154
|
+
type: Object,
|
|
155
|
+
default: () => ({
|
|
156
|
+
originX: "left",
|
|
157
|
+
originY: "top",
|
|
158
|
+
overlayX: "left",
|
|
159
|
+
overlayY: "top"
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}, overlayProps);
|
|
163
|
+
function useOverlayLogic(props, ctx) {
|
|
164
|
+
const backgroundClass = computed(() => {
|
|
165
|
+
return [
|
|
166
|
+
"devui-overlay-background",
|
|
167
|
+
props.backgroundClass,
|
|
168
|
+
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
169
|
+
];
|
|
170
|
+
});
|
|
171
|
+
const overlayClass = computed(() => {
|
|
172
|
+
return "devui-overlay";
|
|
173
|
+
});
|
|
174
|
+
const handleBackdropClick = (event) => {
|
|
175
|
+
var _a;
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
178
|
+
if (props.backdropClose) {
|
|
179
|
+
ctx.emit("update:visible", false);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
183
|
+
onMounted(() => {
|
|
184
|
+
const body = document.body;
|
|
185
|
+
const originOverflow = body.style.overflow;
|
|
186
|
+
const originPosition = body.style.position;
|
|
187
|
+
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
188
|
+
if (backgroundBlock) {
|
|
189
|
+
const top = body.getBoundingClientRect().y;
|
|
190
|
+
if (visible) {
|
|
191
|
+
body.style.overflowY = "scroll";
|
|
192
|
+
body.style.position = visible ? "fixed" : "";
|
|
193
|
+
body.style.top = `${top}px`;
|
|
194
|
+
} else {
|
|
195
|
+
body.style.overflowY = originOverflow;
|
|
196
|
+
body.style.position = originPosition;
|
|
197
|
+
body.style.top = "";
|
|
198
|
+
window.scrollTo(0, -top);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
onUnmounted(() => {
|
|
203
|
+
document.body.style.overflow = originOverflow;
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
backgroundClass,
|
|
208
|
+
overlayClass,
|
|
209
|
+
handleBackdropClick,
|
|
210
|
+
handleOverlayBubbleCancel
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const FixedOverlay = defineComponent({
|
|
214
|
+
name: "DFixedOverlay",
|
|
215
|
+
props: fixedOverlayProps,
|
|
216
|
+
emits: overlayEmits,
|
|
217
|
+
setup(props, ctx) {
|
|
218
|
+
const {
|
|
219
|
+
backgroundClass,
|
|
220
|
+
overlayClass,
|
|
221
|
+
handleBackdropClick,
|
|
222
|
+
handleOverlayBubbleCancel
|
|
223
|
+
} = useOverlayLogic(props, ctx);
|
|
224
|
+
return () => createVNode(CommonOverlay, null, {
|
|
225
|
+
default: () => [withDirectives(createVNode("div", {
|
|
226
|
+
"class": backgroundClass.value,
|
|
227
|
+
"style": props.backgroundStyle,
|
|
228
|
+
"onClick": handleBackdropClick
|
|
229
|
+
}, [createVNode("div", {
|
|
230
|
+
"class": overlayClass.value,
|
|
231
|
+
"style": props.overlayStyle,
|
|
232
|
+
"onClick": handleOverlayBubbleCancel
|
|
233
|
+
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
function isComponent(target) {
|
|
238
|
+
return !!(target == null ? void 0 : target.$el);
|
|
239
|
+
}
|
|
240
|
+
function getElement(element) {
|
|
241
|
+
if (element instanceof Element) {
|
|
242
|
+
return element;
|
|
243
|
+
}
|
|
244
|
+
if (element && typeof element === "object" && element.$el instanceof Element) {
|
|
245
|
+
return element.$el;
|
|
246
|
+
}
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
const FlexibleOverlay = defineComponent({
|
|
250
|
+
name: "DFlexibleOverlay",
|
|
251
|
+
props: flexibleOverlayProps,
|
|
252
|
+
emits: overlayEmits,
|
|
253
|
+
setup(props, ctx) {
|
|
254
|
+
const overlayRef = ref(null);
|
|
255
|
+
const positionedStyle = reactive({
|
|
256
|
+
position: "absolute"
|
|
257
|
+
});
|
|
258
|
+
onMounted(async () => {
|
|
259
|
+
const handleRectChange = (position, rect, origin) => {
|
|
260
|
+
const point = calculatePosition(position, rect, origin);
|
|
261
|
+
positionedStyle.left = `${point.x}px`;
|
|
262
|
+
positionedStyle.top = `${point.y}px`;
|
|
263
|
+
};
|
|
264
|
+
const locationElements = computed(() => {
|
|
265
|
+
const overlay2 = overlayRef.value;
|
|
266
|
+
const origin = getOrigin(props.origin);
|
|
267
|
+
if (!overlay2 || !origin) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
origin,
|
|
272
|
+
overlay: overlay2
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
const visibleRef = toRef(props, "visible");
|
|
276
|
+
const positionRef = toRef(props, "position");
|
|
277
|
+
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
278
|
+
if (!visible || !locationElements2) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const {
|
|
282
|
+
origin,
|
|
283
|
+
overlay: overlay2
|
|
284
|
+
} = locationElements2;
|
|
285
|
+
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
286
|
+
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
287
|
+
onInvalidate(() => {
|
|
288
|
+
unsubscriptions.forEach((fn) => fn());
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
const {
|
|
293
|
+
backgroundClass,
|
|
294
|
+
overlayClass,
|
|
295
|
+
handleBackdropClick,
|
|
296
|
+
handleOverlayBubbleCancel
|
|
297
|
+
} = useOverlayLogic(props);
|
|
298
|
+
return () => createVNode(CommonOverlay, null, {
|
|
299
|
+
default: () => [withDirectives(createVNode("div", {
|
|
300
|
+
"style": props.backgroundStyle,
|
|
301
|
+
"class": backgroundClass.value,
|
|
302
|
+
"onClick": handleBackdropClick
|
|
303
|
+
}, [createVNode("div", {
|
|
304
|
+
"ref": overlayRef,
|
|
305
|
+
"class": overlayClass.value,
|
|
306
|
+
"style": positionedStyle,
|
|
307
|
+
"onClick": handleOverlayBubbleCancel
|
|
308
|
+
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
function getOrigin(origin) {
|
|
313
|
+
if (origin instanceof Element) {
|
|
314
|
+
return origin;
|
|
315
|
+
}
|
|
316
|
+
if (isRef(origin)) {
|
|
317
|
+
return getElement(origin.value);
|
|
318
|
+
}
|
|
319
|
+
if (isComponent(origin)) {
|
|
320
|
+
return getElement(origin);
|
|
321
|
+
}
|
|
322
|
+
return origin;
|
|
323
|
+
}
|
|
324
|
+
function calculatePosition(position, rect, origin) {
|
|
325
|
+
const originRect = getOriginRect(origin);
|
|
326
|
+
const originPoint = getOriginRelativePoint(originRect, position);
|
|
327
|
+
return getOverlayPoint(originPoint, rect, position);
|
|
328
|
+
}
|
|
329
|
+
function getOriginRect(origin) {
|
|
330
|
+
if (origin instanceof Element) {
|
|
331
|
+
return origin.getBoundingClientRect();
|
|
332
|
+
}
|
|
333
|
+
const width = origin.width || 0;
|
|
334
|
+
const height = origin.height || 0;
|
|
335
|
+
return {
|
|
336
|
+
top: origin.y,
|
|
337
|
+
bottom: origin.y + height,
|
|
338
|
+
left: origin.x,
|
|
339
|
+
right: origin.x + width,
|
|
340
|
+
height,
|
|
341
|
+
width
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function getOverlayPoint(originPoint, rect, position) {
|
|
345
|
+
let x;
|
|
346
|
+
const {
|
|
347
|
+
width,
|
|
348
|
+
height
|
|
349
|
+
} = rect;
|
|
350
|
+
if (position.overlayX == "center") {
|
|
351
|
+
x = originPoint.x - width / 2;
|
|
352
|
+
} else {
|
|
353
|
+
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
354
|
+
}
|
|
355
|
+
let y;
|
|
356
|
+
if (position.overlayY == "center") {
|
|
357
|
+
y = originPoint.y - height / 2;
|
|
358
|
+
} else {
|
|
359
|
+
y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
x,
|
|
363
|
+
y
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function getOriginRelativePoint(originRect, position) {
|
|
367
|
+
let x;
|
|
368
|
+
if (position.originX == "center") {
|
|
369
|
+
x = originRect.left + originRect.width / 2;
|
|
370
|
+
} else {
|
|
371
|
+
const startX = originRect.left;
|
|
372
|
+
const endX = originRect.right;
|
|
373
|
+
x = position.originX == "left" ? startX : endX;
|
|
374
|
+
}
|
|
375
|
+
let y;
|
|
376
|
+
if (position.originY == "center") {
|
|
377
|
+
y = originRect.top + originRect.height / 2;
|
|
378
|
+
} else {
|
|
379
|
+
y = position.originY == "top" ? originRect.top : originRect.bottom;
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
x,
|
|
383
|
+
y
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function subscribeLayoutEvent(event) {
|
|
387
|
+
window.addEventListener("scroll", event, true);
|
|
388
|
+
window.addEventListener("resize", event);
|
|
389
|
+
window.addEventListener("orientationchange", event);
|
|
390
|
+
return () => {
|
|
391
|
+
window.removeEventListener("scroll", event, true);
|
|
392
|
+
window.removeEventListener("resize", event);
|
|
393
|
+
window.removeEventListener("orientationchange", event);
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function subscribeOverlayResize(overlay2, callback) {
|
|
397
|
+
if (overlay2 instanceof Element) {
|
|
398
|
+
const resizeObserver = new ResizeObserver(callback);
|
|
399
|
+
resizeObserver.observe(overlay2);
|
|
400
|
+
return () => resizeObserver.disconnect();
|
|
401
|
+
}
|
|
402
|
+
return () => {
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function subscribeOriginResize(origin, callback) {
|
|
406
|
+
if (origin instanceof Element) {
|
|
407
|
+
const observer = new MutationObserver(callback);
|
|
408
|
+
observer.observe(origin, {
|
|
409
|
+
attributeFilter: ["style"]
|
|
410
|
+
});
|
|
411
|
+
return () => observer.disconnect();
|
|
412
|
+
}
|
|
413
|
+
return () => {
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const inBrowser = typeof window !== "undefined";
|
|
417
|
+
FlexibleOverlay.install = function(app) {
|
|
418
|
+
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
419
|
+
};
|
|
420
|
+
FixedOverlay.install = function(app) {
|
|
421
|
+
app.component(FixedOverlay.name, FixedOverlay);
|
|
422
|
+
};
|
|
423
|
+
var modal = "";
|
|
424
|
+
var Modal = defineComponent({
|
|
425
|
+
name: "DModal",
|
|
426
|
+
props: modalProps,
|
|
427
|
+
emits: ["onUpdate:modelValue"],
|
|
428
|
+
setup(props, ctx) {
|
|
429
|
+
const animatedVisible = computed(() => {
|
|
430
|
+
return props.showAnimation ? props.modelValue : true;
|
|
431
|
+
});
|
|
432
|
+
const onVisibleChange = (value) => {
|
|
433
|
+
var _a;
|
|
434
|
+
const update = props["onUpdate:modelValue"];
|
|
435
|
+
if (value) {
|
|
436
|
+
update == null ? void 0 : update(value);
|
|
437
|
+
} else {
|
|
438
|
+
const beforeHidden = props.beforeHidden;
|
|
439
|
+
const close = (enabledClose) => {
|
|
440
|
+
var _a2;
|
|
441
|
+
if (enabledClose) {
|
|
442
|
+
update == null ? void 0 : update(false);
|
|
443
|
+
(_a2 = props.onClose) == null ? void 0 : _a2.call(props);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const result = (_a = typeof beforeHidden === "function" ? beforeHidden() : beforeHidden) != null ? _a : true;
|
|
447
|
+
if (result instanceof Promise) {
|
|
448
|
+
result.then(close);
|
|
449
|
+
} else {
|
|
450
|
+
close(result);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
ctx.expose({
|
|
455
|
+
onVisibleChange
|
|
456
|
+
});
|
|
457
|
+
return () => createVNode(FixedOverlay, {
|
|
458
|
+
"visible": props.modelValue,
|
|
459
|
+
"onUpdate:visible": onVisibleChange,
|
|
460
|
+
"backgroundClass": "devui-modal-wrapper",
|
|
461
|
+
"backgroundBlock": !props.bodyScrollable,
|
|
462
|
+
"backdropClose": props.backdropCloseable
|
|
463
|
+
}, {
|
|
464
|
+
default: () => [createVNode(Transition, {
|
|
465
|
+
"name": "devui-modal-wipe"
|
|
466
|
+
}, {
|
|
467
|
+
default: () => {
|
|
468
|
+
var _a, _b;
|
|
469
|
+
return [animatedVisible.value ? (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a) : null];
|
|
470
|
+
}
|
|
471
|
+
})]
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
class CommonModalService {
|
|
476
|
+
constructor(anchorContainer) {
|
|
477
|
+
this.anchorContainer = anchorContainer;
|
|
478
|
+
}
|
|
479
|
+
renderModal(anchor, props, children) {
|
|
480
|
+
const vnode = h(this.component(), props, children);
|
|
481
|
+
render(vnode, anchor);
|
|
482
|
+
return vnode;
|
|
483
|
+
}
|
|
484
|
+
renderNull(anchor) {
|
|
485
|
+
setTimeout(() => {
|
|
486
|
+
render(null, anchor);
|
|
487
|
+
}, 500);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
class ModalService extends CommonModalService {
|
|
491
|
+
component() {
|
|
492
|
+
return Modal;
|
|
493
|
+
}
|
|
494
|
+
open(props = {}) {
|
|
495
|
+
const anchor = document.createElement("div");
|
|
496
|
+
this.anchorContainer.appendChild(anchor);
|
|
497
|
+
const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
|
|
498
|
+
const needHideOrNot = (value) => {
|
|
499
|
+
if (!value) {
|
|
500
|
+
hide();
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
|
|
504
|
+
return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
|
|
505
|
+
modelValue: true,
|
|
506
|
+
"onUpdate:modelValue": onUpdateModelValue
|
|
507
|
+
}), { default: content });
|
|
508
|
+
};
|
|
509
|
+
const hide = () => {
|
|
510
|
+
var _a2, _b;
|
|
511
|
+
const vnode = renderOrigin(resProps, (value) => {
|
|
512
|
+
if (!value) {
|
|
513
|
+
this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
|
|
514
|
+
this.renderNull(anchor);
|
|
515
|
+
} else {
|
|
516
|
+
renderOrigin(resProps);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
(_b = (_a2 = vnode.component.exposed).onVisibleChange) == null ? void 0 : _b.call(_a2, false);
|
|
520
|
+
};
|
|
521
|
+
this.renderModal(anchor, { modelValue: false });
|
|
522
|
+
renderOrigin(resProps);
|
|
523
|
+
return { hide };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
__publicField(ModalService, "token", "MODAL_SERVICE_TOKEN");
|
|
527
|
+
const dialogProps = {
|
|
528
|
+
width: {
|
|
529
|
+
type: String,
|
|
530
|
+
default: "300px"
|
|
531
|
+
},
|
|
532
|
+
maxHeight: {
|
|
533
|
+
type: String
|
|
534
|
+
},
|
|
535
|
+
zIndex: {
|
|
536
|
+
type: Number,
|
|
537
|
+
default: 1050
|
|
538
|
+
},
|
|
539
|
+
backdropZIndex: {
|
|
540
|
+
type: Number,
|
|
541
|
+
default: 1049
|
|
542
|
+
},
|
|
543
|
+
placement: {
|
|
544
|
+
type: String,
|
|
545
|
+
default: "center"
|
|
546
|
+
},
|
|
547
|
+
offsetX: {
|
|
548
|
+
type: String,
|
|
549
|
+
default: "0px"
|
|
550
|
+
},
|
|
551
|
+
offsetY: {
|
|
552
|
+
type: String,
|
|
553
|
+
default: "0px"
|
|
554
|
+
},
|
|
555
|
+
title: {
|
|
556
|
+
type: String
|
|
557
|
+
},
|
|
558
|
+
showAnimation: {
|
|
559
|
+
type: Boolean,
|
|
560
|
+
default: true
|
|
561
|
+
},
|
|
562
|
+
backdropCloseable: {
|
|
563
|
+
type: Boolean,
|
|
564
|
+
default: false
|
|
565
|
+
},
|
|
566
|
+
bodyScrollable: {
|
|
567
|
+
type: Boolean,
|
|
568
|
+
default: true
|
|
569
|
+
},
|
|
570
|
+
escapeable: {
|
|
571
|
+
type: Boolean,
|
|
572
|
+
default: true
|
|
573
|
+
},
|
|
574
|
+
onClose: {
|
|
575
|
+
type: Function
|
|
576
|
+
},
|
|
577
|
+
beforeHidden: {
|
|
578
|
+
type: [Promise, Function]
|
|
579
|
+
},
|
|
580
|
+
buttons: {
|
|
581
|
+
type: Array,
|
|
582
|
+
default: []
|
|
583
|
+
},
|
|
584
|
+
dialogType: {
|
|
585
|
+
type: String,
|
|
586
|
+
default: "standard"
|
|
587
|
+
},
|
|
588
|
+
modelValue: {
|
|
589
|
+
type: Boolean
|
|
590
|
+
},
|
|
591
|
+
"onUpdate:modelValue": {
|
|
592
|
+
type: Function
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const useMoveable = (moveable = true) => {
|
|
596
|
+
const movingX = ref(0);
|
|
597
|
+
const movingY = ref(0);
|
|
598
|
+
const reset = () => {
|
|
599
|
+
movingX.value = 0;
|
|
600
|
+
movingY.value = 0;
|
|
601
|
+
};
|
|
602
|
+
const handleRef = ref();
|
|
603
|
+
const moveElRef = ref();
|
|
604
|
+
const enabledMoving = isRef(moveable) ? moveable : ref(moveable);
|
|
605
|
+
watch([moveElRef, handleRef], ([container, target], ov, onInvalidate) => {
|
|
606
|
+
if (!(target instanceof HTMLElement && container instanceof HTMLElement)) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
target.style.cursor = "all-scroll";
|
|
610
|
+
let startX = 0;
|
|
611
|
+
let startY = 0;
|
|
612
|
+
let prevMovingX = 0;
|
|
613
|
+
let prevMovingY = 0;
|
|
614
|
+
let containerRect = container.getBoundingClientRect();
|
|
615
|
+
let bodyRect = document.body.getBoundingClientRect();
|
|
616
|
+
let isDown = false;
|
|
617
|
+
const handleMouseDown = (event) => {
|
|
618
|
+
event.preventDefault();
|
|
619
|
+
if (!enabledMoving.value) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
startX = event.clientX;
|
|
623
|
+
startY = event.clientY;
|
|
624
|
+
const targetRect = target.getBoundingClientRect();
|
|
625
|
+
if ((target === event.target || target.contains(event.target)) && targetRect.x < startX && targetRect.y < startY && targetRect.width + targetRect.x >= startX && targetRect.height + targetRect.y >= startY) {
|
|
626
|
+
isDown = true;
|
|
627
|
+
prevMovingX = movingX.value;
|
|
628
|
+
prevMovingY = movingY.value;
|
|
629
|
+
bodyRect = document.body.getBoundingClientRect();
|
|
630
|
+
containerRect = container.getBoundingClientRect();
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
const handleMouseMove = (event) => {
|
|
634
|
+
event.preventDefault();
|
|
635
|
+
if (!isDown) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
const currentX = prevMovingX + event.clientX - startX;
|
|
639
|
+
const currentY = prevMovingY + event.clientY - startY;
|
|
640
|
+
const containerOriginX = containerRect.x - prevMovingX;
|
|
641
|
+
const containerOriginY = containerRect.y - prevMovingY;
|
|
642
|
+
movingX.value = getRangeValueOf(currentX, -containerOriginX, bodyRect.width - containerRect.width - containerOriginX);
|
|
643
|
+
movingY.value = getRangeValueOf(currentY, -containerOriginY, bodyRect.height - containerRect.height - containerOriginY);
|
|
644
|
+
};
|
|
645
|
+
const handleMouseUp = (event) => {
|
|
646
|
+
event.preventDefault();
|
|
647
|
+
if (!isDown) {
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
isDown = false;
|
|
651
|
+
};
|
|
652
|
+
window.addEventListener("mousedown", handleMouseDown);
|
|
653
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
654
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
655
|
+
onInvalidate(() => {
|
|
656
|
+
window.removeEventListener("mousedown", handleMouseDown);
|
|
657
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
658
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
return {
|
|
662
|
+
movingX: readonly(movingX),
|
|
663
|
+
movingY: readonly(movingY),
|
|
664
|
+
handleRef,
|
|
665
|
+
moveElRef,
|
|
666
|
+
reset
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
const getRangeValueOf = (value, min, max) => {
|
|
670
|
+
if (value < min) {
|
|
671
|
+
return min;
|
|
672
|
+
}
|
|
673
|
+
if (value > max) {
|
|
674
|
+
return max;
|
|
675
|
+
}
|
|
676
|
+
return value;
|
|
677
|
+
};
|
|
678
|
+
var Icon = defineComponent({
|
|
679
|
+
name: "DIcon",
|
|
680
|
+
props: {
|
|
681
|
+
name: {
|
|
682
|
+
type: String,
|
|
683
|
+
required: true
|
|
684
|
+
},
|
|
685
|
+
size: {
|
|
686
|
+
type: String,
|
|
687
|
+
default: "inherit"
|
|
688
|
+
},
|
|
689
|
+
color: {
|
|
690
|
+
type: String,
|
|
691
|
+
default: "inherit"
|
|
692
|
+
},
|
|
693
|
+
classPrefix: {
|
|
694
|
+
type: String,
|
|
695
|
+
default: "icon"
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
setup(props) {
|
|
699
|
+
return __spreadValues({}, props);
|
|
700
|
+
},
|
|
701
|
+
render() {
|
|
702
|
+
const {
|
|
703
|
+
name,
|
|
704
|
+
size,
|
|
705
|
+
color,
|
|
706
|
+
classPrefix
|
|
707
|
+
} = this;
|
|
708
|
+
return /^((https?):)?\/\//.test(name) ? createVNode("img", {
|
|
709
|
+
"src": name,
|
|
710
|
+
"alt": name.split("/")[name.split("/").length - 1],
|
|
711
|
+
"style": {
|
|
712
|
+
width: size,
|
|
713
|
+
verticalAlign: "text-bottom"
|
|
714
|
+
}
|
|
715
|
+
}, null) : createVNode("i", {
|
|
716
|
+
"class": `${classPrefix} ${classPrefix}-${name}`,
|
|
717
|
+
"style": {
|
|
718
|
+
fontSize: size,
|
|
719
|
+
color
|
|
720
|
+
}
|
|
721
|
+
}, null);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
Icon.install = function(app) {
|
|
725
|
+
app.component(Icon.name, Icon);
|
|
726
|
+
};
|
|
727
|
+
const buttonProps = {
|
|
728
|
+
type: {
|
|
729
|
+
type: String,
|
|
730
|
+
default: "button"
|
|
731
|
+
},
|
|
732
|
+
btnStyle: {
|
|
733
|
+
type: String,
|
|
734
|
+
default: "primary"
|
|
735
|
+
},
|
|
736
|
+
size: {
|
|
737
|
+
type: String,
|
|
738
|
+
default: "md"
|
|
739
|
+
},
|
|
740
|
+
position: {
|
|
741
|
+
type: String,
|
|
742
|
+
default: "default"
|
|
743
|
+
},
|
|
744
|
+
bordered: {
|
|
745
|
+
type: Boolean,
|
|
746
|
+
default: false
|
|
747
|
+
},
|
|
748
|
+
icon: {
|
|
749
|
+
type: String,
|
|
750
|
+
default: ""
|
|
751
|
+
},
|
|
752
|
+
showLoading: {
|
|
753
|
+
type: Boolean,
|
|
754
|
+
default: false
|
|
755
|
+
},
|
|
756
|
+
width: {
|
|
757
|
+
type: String
|
|
758
|
+
},
|
|
759
|
+
disabled: {
|
|
760
|
+
type: Boolean,
|
|
761
|
+
default: false
|
|
762
|
+
},
|
|
763
|
+
autofocus: {
|
|
764
|
+
type: Boolean,
|
|
765
|
+
default: false
|
|
766
|
+
},
|
|
767
|
+
onClick: {
|
|
768
|
+
type: Function
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
var button = "";
|
|
772
|
+
var Button = defineComponent({
|
|
773
|
+
name: "DButton",
|
|
774
|
+
props: buttonProps,
|
|
775
|
+
setup(props, ctx) {
|
|
776
|
+
const buttonContent = ref(null);
|
|
777
|
+
const onClick = (e) => {
|
|
778
|
+
var _a;
|
|
779
|
+
if (props.showLoading) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
(_a = props.onClick) == null ? void 0 : _a.call(props, e);
|
|
783
|
+
};
|
|
784
|
+
const hasContent = computed(() => ctx.slots.default);
|
|
785
|
+
const btnClass = computed(() => {
|
|
786
|
+
const {
|
|
787
|
+
btnStyle,
|
|
788
|
+
size,
|
|
789
|
+
position,
|
|
790
|
+
bordered,
|
|
791
|
+
icon
|
|
792
|
+
} = props;
|
|
793
|
+
const origin = `devui-btn devui-btn-${btnStyle} devui-btn-${size} devui-btn-${position}`;
|
|
794
|
+
const borderedClass = bordered ? "bordered" : "";
|
|
795
|
+
const btnIcon = !!icon && !hasContent.value && btnStyle !== "primary" ? "d-btn-icon" : "";
|
|
796
|
+
const btnIconWrap = !!icon ? "d-btn-icon-wrap" : "";
|
|
797
|
+
return `${origin} ${borderedClass} ${btnIcon} ${btnIconWrap}`;
|
|
798
|
+
});
|
|
799
|
+
const iconClass = computed(() => {
|
|
800
|
+
if (!props.icon) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const origin = "devui-icon-fix icon";
|
|
804
|
+
if (hasContent.value) {
|
|
805
|
+
return `${origin} clear-right-5`;
|
|
806
|
+
} else {
|
|
807
|
+
return origin;
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
return () => {
|
|
811
|
+
var _a, _b;
|
|
812
|
+
const {
|
|
813
|
+
icon,
|
|
814
|
+
type,
|
|
815
|
+
disabled,
|
|
816
|
+
showLoading,
|
|
817
|
+
width
|
|
818
|
+
} = props;
|
|
819
|
+
return withDirectives(createVNode("div", mergeProps({
|
|
820
|
+
"class": "devui-btn-host"
|
|
821
|
+
}, ctx.attrs), [createVNode("button", {
|
|
822
|
+
"class": btnClass.value,
|
|
823
|
+
"type": type,
|
|
824
|
+
"disabled": disabled,
|
|
825
|
+
"style": {
|
|
826
|
+
width
|
|
827
|
+
},
|
|
828
|
+
"onClick": onClick
|
|
829
|
+
}, [!!icon ? createVNode(Icon, {
|
|
830
|
+
"name": icon,
|
|
831
|
+
"class": iconClass.value
|
|
832
|
+
}, null) : null, createVNode("span", {
|
|
833
|
+
"class": "button-content",
|
|
834
|
+
"ref": buttonContent
|
|
835
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])])]), [[resolveDirective("dLoading"), showLoading]]);
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
class View {
|
|
840
|
+
constructor() {
|
|
841
|
+
__publicField(this, "top", "50%");
|
|
842
|
+
__publicField(this, "left", "50%");
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const componentProps = {
|
|
846
|
+
message: String,
|
|
847
|
+
backdrop: Boolean,
|
|
848
|
+
view: {
|
|
849
|
+
type: Object,
|
|
850
|
+
default: () => new View()
|
|
851
|
+
},
|
|
852
|
+
zIndex: Number,
|
|
853
|
+
isFull: {
|
|
854
|
+
type: Boolean,
|
|
855
|
+
default: false
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
class LoadingProps {
|
|
859
|
+
constructor() {
|
|
860
|
+
__publicField(this, "target");
|
|
861
|
+
__publicField(this, "message");
|
|
862
|
+
__publicField(this, "loadingTemplateRef");
|
|
863
|
+
__publicField(this, "backdrop", true);
|
|
864
|
+
__publicField(this, "positionType", "relative");
|
|
865
|
+
__publicField(this, "view", new View());
|
|
866
|
+
__publicField(this, "zIndex");
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
var loading = "";
|
|
870
|
+
var Loading = defineComponent({
|
|
871
|
+
name: "DLoading",
|
|
872
|
+
inheritAttrs: false,
|
|
873
|
+
props: componentProps,
|
|
874
|
+
setup(props) {
|
|
875
|
+
const style = {
|
|
876
|
+
top: props.view.top,
|
|
877
|
+
left: props.view.left,
|
|
878
|
+
zIndex: props.zIndex
|
|
879
|
+
};
|
|
880
|
+
if (!props.message) {
|
|
881
|
+
style.background = "none";
|
|
882
|
+
}
|
|
883
|
+
const isShow = ref(false);
|
|
884
|
+
const open = () => {
|
|
885
|
+
isShow.value = true;
|
|
886
|
+
};
|
|
887
|
+
const close = () => {
|
|
888
|
+
isShow.value = false;
|
|
889
|
+
};
|
|
890
|
+
return {
|
|
891
|
+
style,
|
|
892
|
+
isShow,
|
|
893
|
+
open,
|
|
894
|
+
close
|
|
895
|
+
};
|
|
896
|
+
},
|
|
897
|
+
render() {
|
|
898
|
+
var _a;
|
|
899
|
+
const {
|
|
900
|
+
isShow,
|
|
901
|
+
isFull,
|
|
902
|
+
backdrop,
|
|
903
|
+
style,
|
|
904
|
+
message,
|
|
905
|
+
$slots
|
|
906
|
+
} = this;
|
|
907
|
+
return isShow && createVNode("div", {
|
|
908
|
+
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
909
|
+
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
910
|
+
"class": "devui-loading-wrapper"
|
|
911
|
+
}, [backdrop ? createVNode("div", {
|
|
912
|
+
"class": "devui-loading-mask"
|
|
913
|
+
}, null) : null, createVNode("div", {
|
|
914
|
+
"style": style,
|
|
915
|
+
"class": "devui-loading-area"
|
|
916
|
+
}, [createVNode("div", {
|
|
917
|
+
"class": "devui-busy-default-spinner"
|
|
918
|
+
}, [createVNode("div", {
|
|
919
|
+
"class": "devui-loading-bar1"
|
|
920
|
+
}, null), createVNode("div", {
|
|
921
|
+
"class": "devui-loading-bar2"
|
|
922
|
+
}, null), createVNode("div", {
|
|
923
|
+
"class": "devui-loading-bar3"
|
|
924
|
+
}, null), createVNode("div", {
|
|
925
|
+
"class": "devui-loading-bar4"
|
|
926
|
+
}, null)]), message ? createVNode("span", {
|
|
927
|
+
"class": "devui-loading-text"
|
|
928
|
+
}, [message]) : null])])]);
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
932
|
+
function createComponent(Component, props, children = null) {
|
|
933
|
+
const vnode = h(Component, __spreadValues({}, props), children);
|
|
934
|
+
const container = document.createElement("div");
|
|
935
|
+
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
936
|
+
render(vnode, container);
|
|
937
|
+
return vnode.component;
|
|
938
|
+
}
|
|
939
|
+
function unmountComponent(ComponnetInstance) {
|
|
940
|
+
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
941
|
+
}
|
|
942
|
+
const loadingConstructor = defineComponent(Loading);
|
|
943
|
+
const cacheInstance = new WeakSet();
|
|
944
|
+
const isEmpty = (val) => {
|
|
945
|
+
if (!val)
|
|
946
|
+
return true;
|
|
947
|
+
if (Array.isArray(val))
|
|
948
|
+
return val.length === 0;
|
|
949
|
+
if (val instanceof Set || val instanceof Map)
|
|
950
|
+
return val.size === 0;
|
|
951
|
+
if (val instanceof Promise)
|
|
952
|
+
return false;
|
|
953
|
+
if (typeof val === "object") {
|
|
954
|
+
try {
|
|
955
|
+
return Object.keys(val).length === 0;
|
|
956
|
+
} catch (e) {
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
return false;
|
|
961
|
+
};
|
|
962
|
+
const getType = (vari) => {
|
|
963
|
+
return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
|
|
964
|
+
};
|
|
965
|
+
const isPromise = (value) => {
|
|
966
|
+
const type = getType(value);
|
|
967
|
+
switch (type) {
|
|
968
|
+
case "promise":
|
|
969
|
+
return [value];
|
|
970
|
+
case "array":
|
|
971
|
+
if (value.some((val) => getType(val) !== "promise")) {
|
|
972
|
+
console.error(new TypeError("Binding values should all be of type Promise"));
|
|
973
|
+
return "error";
|
|
974
|
+
}
|
|
975
|
+
return value;
|
|
976
|
+
default:
|
|
977
|
+
return false;
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
const unmount = (el) => {
|
|
981
|
+
cacheInstance.delete(el);
|
|
982
|
+
el.instance.proxy.close();
|
|
983
|
+
unmountComponent(el.instance);
|
|
984
|
+
};
|
|
985
|
+
const toggleLoading = (el, binding) => {
|
|
986
|
+
if (binding.value) {
|
|
987
|
+
const vals = isPromise(binding.value);
|
|
988
|
+
if (vals === "error")
|
|
989
|
+
return;
|
|
990
|
+
el.instance.proxy.open();
|
|
991
|
+
el.appendChild(el.mask);
|
|
992
|
+
cacheInstance.add(el);
|
|
993
|
+
if (vals) {
|
|
994
|
+
Promise.all(vals).catch((err) => {
|
|
995
|
+
console.error(new Error("Promise handling errors"), err);
|
|
996
|
+
}).finally(() => {
|
|
997
|
+
unmount(el);
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
} else {
|
|
1001
|
+
unmount(el);
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
const removeAttribute = (el) => {
|
|
1005
|
+
el.removeAttribute("zindex");
|
|
1006
|
+
el.removeAttribute("positiontype");
|
|
1007
|
+
el.removeAttribute("backdrop");
|
|
1008
|
+
el.removeAttribute("message");
|
|
1009
|
+
el.removeAttribute("view");
|
|
1010
|
+
el.removeAttribute("loadingtemplateref");
|
|
1011
|
+
};
|
|
1012
|
+
const handleProps = (el, vprops) => {
|
|
1013
|
+
const props = __spreadValues(__spreadValues({}, new LoadingProps()), vprops);
|
|
1014
|
+
const loadingTemplateRef = props.loadingTemplateRef;
|
|
1015
|
+
const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
|
|
1016
|
+
el.style.position = props.positionType;
|
|
1017
|
+
el.options = props;
|
|
1018
|
+
el.instance = loadingInstance;
|
|
1019
|
+
el.mask = loadingInstance.proxy.$el;
|
|
1020
|
+
};
|
|
1021
|
+
const loadingDirective = {
|
|
1022
|
+
mounted: function(el, binding, vnode) {
|
|
1023
|
+
handleProps(el, vnode.props);
|
|
1024
|
+
removeAttribute(el);
|
|
1025
|
+
!isEmpty(binding.value) && toggleLoading(el, binding);
|
|
1026
|
+
},
|
|
1027
|
+
updated: function(el, binding, vnode) {
|
|
1028
|
+
if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el))
|
|
1029
|
+
return;
|
|
1030
|
+
!cacheInstance.has(el) && handleProps(el, vnode.props);
|
|
1031
|
+
removeAttribute(el);
|
|
1032
|
+
toggleLoading(el, binding);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
defineComponent(Loading);
|
|
1036
|
+
Button.install = function(app) {
|
|
1037
|
+
app.directive("dLoading", loadingDirective);
|
|
1038
|
+
app.component(Button.name, Button);
|
|
1039
|
+
};
|
|
1040
|
+
function _isSlot(s) {
|
|
1041
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1042
|
+
}
|
|
1043
|
+
var Dialog = defineComponent({
|
|
1044
|
+
name: "DModal",
|
|
1045
|
+
inheritAttrs: false,
|
|
1046
|
+
props: dialogProps,
|
|
1047
|
+
emits: ["onUpdate:modelValue"],
|
|
1048
|
+
setup(props, ctx) {
|
|
1049
|
+
const {
|
|
1050
|
+
movingX,
|
|
1051
|
+
movingY,
|
|
1052
|
+
handleRef,
|
|
1053
|
+
moveElRef,
|
|
1054
|
+
reset
|
|
1055
|
+
} = useMoveable();
|
|
1056
|
+
watch(() => props.modelValue, (value) => {
|
|
1057
|
+
if (value) {
|
|
1058
|
+
reset();
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
const movingStyle = computed(() => ({
|
|
1062
|
+
position: "relative",
|
|
1063
|
+
left: `${movingX.value}px`,
|
|
1064
|
+
top: `${movingY.value}px`
|
|
1065
|
+
}));
|
|
1066
|
+
const containerStyle = computed(() => ({
|
|
1067
|
+
width: props.width,
|
|
1068
|
+
maxHeight: props.maxHeight,
|
|
1069
|
+
transform: `translate(${props.offsetX}, ${props.offsetY})`,
|
|
1070
|
+
zIndex: props.zIndex
|
|
1071
|
+
}));
|
|
1072
|
+
const iconName = computed(() => {
|
|
1073
|
+
switch (props.dialogType) {
|
|
1074
|
+
case "standard":
|
|
1075
|
+
return "";
|
|
1076
|
+
case "info":
|
|
1077
|
+
return "icon-info-o";
|
|
1078
|
+
case "success":
|
|
1079
|
+
return "icon-right-o";
|
|
1080
|
+
case "warning":
|
|
1081
|
+
return "icon-warning-o";
|
|
1082
|
+
case "failed":
|
|
1083
|
+
return "icon-error-o";
|
|
1084
|
+
default:
|
|
1085
|
+
return "";
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
const buttonsRef = computed(() => {
|
|
1089
|
+
return props.buttons.map((buttonProps2, index2) => {
|
|
1090
|
+
const {
|
|
1091
|
+
btnStyle,
|
|
1092
|
+
disabled,
|
|
1093
|
+
handler,
|
|
1094
|
+
text
|
|
1095
|
+
} = buttonProps2;
|
|
1096
|
+
return createVNode(Button, {
|
|
1097
|
+
"key": index2,
|
|
1098
|
+
"style": {
|
|
1099
|
+
display: "inline-block",
|
|
1100
|
+
margin: "0 5px"
|
|
1101
|
+
},
|
|
1102
|
+
"btnStyle": btnStyle,
|
|
1103
|
+
"disabled": disabled,
|
|
1104
|
+
"onClick": handler
|
|
1105
|
+
}, _isSlot(text) ? text : {
|
|
1106
|
+
default: () => [text]
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1110
|
+
const modalRef = ref();
|
|
1111
|
+
const closeModal = () => {
|
|
1112
|
+
var _a, _b;
|
|
1113
|
+
(_b = (_a = modalRef.value) == null ? void 0 : _a.onVisibleChange) == null ? void 0 : _b.call(_a, false);
|
|
1114
|
+
};
|
|
1115
|
+
ctx.expose({
|
|
1116
|
+
closeModal
|
|
1117
|
+
});
|
|
1118
|
+
return () => createVNode(Modal, {
|
|
1119
|
+
"ref": modalRef,
|
|
1120
|
+
"width": props.width,
|
|
1121
|
+
"maxHeight": props.maxHeight,
|
|
1122
|
+
"offsetX": props.offsetX,
|
|
1123
|
+
"offsetY": props.offsetY,
|
|
1124
|
+
"zIndex": props.zIndex,
|
|
1125
|
+
"backdropZIndex": props.backdropZIndex,
|
|
1126
|
+
"backdropCloseable": props.backdropCloseable,
|
|
1127
|
+
"bodyScrollable": props.bodyScrollable,
|
|
1128
|
+
"placement": props.placement,
|
|
1129
|
+
"onClose": props.onClose,
|
|
1130
|
+
"beforeHidden": props.beforeHidden,
|
|
1131
|
+
"modelValue": props.modelValue,
|
|
1132
|
+
"onUpdate:modelValue": props["onUpdate:modelValue"]
|
|
1133
|
+
}, {
|
|
1134
|
+
default: () => {
|
|
1135
|
+
var _a, _b;
|
|
1136
|
+
return [createVNode("div", {
|
|
1137
|
+
"class": "devui-modal-content",
|
|
1138
|
+
"style": [containerStyle.value, movingStyle.value],
|
|
1139
|
+
"ref": moveElRef
|
|
1140
|
+
}, [createVNode("div", {
|
|
1141
|
+
"class": "devui-modal-header",
|
|
1142
|
+
"ref": handleRef
|
|
1143
|
+
}, [!!iconName.value ? createVNode(Icon, {
|
|
1144
|
+
"name": iconName.value,
|
|
1145
|
+
"size": "24px",
|
|
1146
|
+
"class": "header-alert-icon"
|
|
1147
|
+
}, null) : null, createVNode("span", null, [props.title]), createVNode(Button, {
|
|
1148
|
+
"class": "btn-close",
|
|
1149
|
+
"icon": "close",
|
|
1150
|
+
"btnStyle": "text-dark",
|
|
1151
|
+
"onClick": closeModal
|
|
1152
|
+
}, null)]), createVNode("div", {
|
|
1153
|
+
"class": "devui-modal-body"
|
|
1154
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createVNode("div", {
|
|
1155
|
+
"class": "devui-modal-footer"
|
|
1156
|
+
}, [buttonsRef.value])])];
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
class DialogService extends CommonModalService {
|
|
1162
|
+
component() {
|
|
1163
|
+
return Dialog;
|
|
1164
|
+
}
|
|
1165
|
+
open(props = {}) {
|
|
1166
|
+
const anchor = document.createElement("div");
|
|
1167
|
+
this.anchorContainer.appendChild(anchor);
|
|
1168
|
+
const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
|
|
1169
|
+
const needHideOrNot = (value) => {
|
|
1170
|
+
if (!value) {
|
|
1171
|
+
hide();
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
|
|
1175
|
+
return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
|
|
1176
|
+
modelValue: true,
|
|
1177
|
+
"onUpdate:modelValue": onUpdateModelValue
|
|
1178
|
+
}), { default: content });
|
|
1179
|
+
};
|
|
1180
|
+
const hide = () => {
|
|
1181
|
+
var _a2, _b;
|
|
1182
|
+
const vnode = renderOrigin(resProps, (value) => {
|
|
1183
|
+
if (!value) {
|
|
1184
|
+
this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
|
|
1185
|
+
this.renderNull(anchor);
|
|
1186
|
+
} else {
|
|
1187
|
+
renderOrigin(resProps);
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
(_b = (_a2 = vnode.component.exposed).closeModal) == null ? void 0 : _b.call(_a2);
|
|
1191
|
+
};
|
|
1192
|
+
const updateButtonOptions = (buttonOptions) => {
|
|
1193
|
+
const _a2 = resProps, { buttons } = _a2, innerResProps = __objRest(_a2, ["buttons"]);
|
|
1194
|
+
const newButtonOptions = buttons.map((option, index2) => __spreadValues(__spreadValues({}, option), buttonOptions[index2]));
|
|
1195
|
+
renderOrigin(__spreadProps(__spreadValues({}, innerResProps), { buttons: newButtonOptions }));
|
|
1196
|
+
};
|
|
1197
|
+
this.renderModal(anchor, { modelValue: false });
|
|
1198
|
+
renderOrigin(resProps);
|
|
1199
|
+
return { hide, updateButtonOptions };
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
__publicField(DialogService, "token", "DIALOG_SERVICE_TOKEN");
|
|
1203
|
+
Modal.install = function(app) {
|
|
1204
|
+
app.component(Modal.name, Modal);
|
|
1205
|
+
};
|
|
1206
|
+
var index = {
|
|
1207
|
+
title: "Modal \u5F39\u7A97",
|
|
1208
|
+
category: "\u53CD\u9988",
|
|
1209
|
+
status: "100%",
|
|
1210
|
+
install(app) {
|
|
1211
|
+
app.use(Modal);
|
|
1212
|
+
if (!inBrowser) {
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
let anchorsContainer = document.getElementById("d-modal-anchors-container");
|
|
1216
|
+
if (!anchorsContainer) {
|
|
1217
|
+
anchorsContainer = document.createElement("div");
|
|
1218
|
+
anchorsContainer.setAttribute("id", "d-modal-anchors-container");
|
|
1219
|
+
document.body.appendChild(anchorsContainer);
|
|
1220
|
+
}
|
|
1221
|
+
app.provide(ModalService.token, new ModalService(anchorsContainer));
|
|
1222
|
+
app.provide(DialogService.token, new DialogService(anchorsContainer));
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
export { Modal, index as default };
|