vue-devui 1.0.0-alpha.4 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/accordion/index.d.ts +7 -0
  2. package/accordion/index.es.js +237 -1
  3. package/accordion/index.umd.js +1 -1
  4. package/accordion/style.css +1 -1
  5. package/alert/index.d.ts +7 -0
  6. package/alert/index.es.js +175 -1
  7. package/alert/index.umd.js +1 -1
  8. package/alert/style.css +1 -1
  9. package/anchor/index.d.ts +7 -0
  10. package/anchor/index.es.js +263 -1
  11. package/anchor/index.umd.js +1 -1
  12. package/avatar/index.d.ts +7 -0
  13. package/avatar/index.es.js +301 -1
  14. package/avatar/index.umd.js +1 -1
  15. package/back-top/index.d.ts +7 -0
  16. package/back-top/index.es.js +128 -0
  17. package/back-top/index.umd.js +1 -0
  18. package/back-top/package.json +7 -0
  19. package/back-top/style.css +1 -0
  20. package/badge/index.d.ts +7 -0
  21. package/badge/index.es.js +95 -1
  22. package/badge/index.umd.js +1 -1
  23. package/breadcrumb/index.d.ts +7 -0
  24. package/breadcrumb/index.es.js +127 -1
  25. package/breadcrumb/index.umd.js +1 -1
  26. package/breadcrumb/style.css +1 -1
  27. package/button/index.d.ts +7 -0
  28. package/button/index.es.js +190 -1
  29. package/button/index.umd.js +1 -1
  30. package/card/index.d.ts +7 -0
  31. package/card/index.es.js +61 -1
  32. package/card/index.umd.js +1 -1
  33. package/carousel/index.d.ts +7 -0
  34. package/carousel/index.es.js +329 -1
  35. package/carousel/index.umd.js +1 -1
  36. package/cascader/index.d.ts +7 -0
  37. package/cascader/index.es.js +1343 -1
  38. package/cascader/index.umd.js +1 -1
  39. package/cascader/style.css +1 -1
  40. package/checkbox/index.d.ts +7 -0
  41. package/checkbox/index.es.js +377 -1
  42. package/checkbox/index.umd.js +1 -1
  43. package/comment/index.d.ts +7 -0
  44. package/comment/index.es.js +85 -0
  45. package/comment/index.umd.js +1 -0
  46. package/comment/package.json +7 -0
  47. package/comment/style.css +1 -0
  48. package/countdown/index.d.ts +7 -0
  49. package/countdown/index.es.js +176 -0
  50. package/countdown/index.umd.js +1 -0
  51. package/countdown/package.json +7 -0
  52. package/countdown/style.css +1 -0
  53. package/date-picker/index.d.ts +7 -0
  54. package/date-picker/index.es.js +1172 -1
  55. package/date-picker/index.umd.js +1 -1
  56. package/date-picker/style.css +1 -1
  57. package/dragdrop/index.d.ts +7 -0
  58. package/dragdrop/index.es.js +32 -0
  59. package/dragdrop/index.umd.js +1 -0
  60. package/dragdrop/package.json +7 -0
  61. package/drawer/index.d.ts +7 -0
  62. package/drawer/index.es.js +288 -0
  63. package/drawer/index.umd.js +1 -0
  64. package/drawer/package.json +7 -0
  65. package/drawer/style.css +1 -0
  66. package/dropdown/index.d.ts +7 -0
  67. package/dropdown/index.es.js +527 -0
  68. package/dropdown/index.umd.js +1 -0
  69. package/dropdown/package.json +7 -0
  70. package/dropdown/style.css +1 -0
  71. package/editable-select/index.d.ts +7 -0
  72. package/editable-select/index.es.js +5793 -1
  73. package/editable-select/index.umd.js +27 -1
  74. package/editable-select/style.css +1 -1
  75. package/form/index.d.ts +7 -0
  76. package/form/index.es.js +2244 -0
  77. package/form/index.umd.js +1 -0
  78. package/form/package.json +7 -0
  79. package/form/style.css +1 -0
  80. package/fullscreen/index.d.ts +7 -0
  81. package/fullscreen/index.es.js +163 -1
  82. package/fullscreen/index.umd.js +1 -1
  83. package/gantt/index.d.ts +7 -0
  84. package/gantt/index.es.js +535 -0
  85. package/gantt/index.umd.js +1 -0
  86. package/gantt/package.json +7 -0
  87. package/gantt/style.css +1 -0
  88. package/grid/index.d.ts +7 -0
  89. package/grid/index.es.js +269 -0
  90. package/grid/index.umd.js +1 -0
  91. package/grid/package.json +7 -0
  92. package/grid/style.css +1 -0
  93. package/icon/index.d.ts +7 -0
  94. package/icon/index.es.js +75 -1
  95. package/icon/index.umd.js +1 -1
  96. package/image-preview/index.d.ts +7 -0
  97. package/image-preview/index.es.js +480 -1
  98. package/image-preview/index.umd.js +1 -1
  99. package/image-preview/style.css +1 -1
  100. package/index.d.ts +7 -0
  101. package/input/index.d.ts +7 -0
  102. package/input/index.es.js +190 -1
  103. package/input/index.umd.js +1 -1
  104. package/input-icon/index.d.ts +7 -0
  105. package/input-icon/index.es.js +332 -0
  106. package/input-icon/index.umd.js +1 -0
  107. package/input-icon/package.json +7 -0
  108. package/input-icon/style.css +1 -0
  109. package/input-number/index.d.ts +7 -0
  110. package/input-number/index.es.js +240 -1
  111. package/input-number/index.umd.js +1 -1
  112. package/input-number/style.css +1 -1
  113. package/layout/index.d.ts +7 -0
  114. package/layout/index.es.js +100 -0
  115. package/layout/index.umd.js +1 -0
  116. package/layout/package.json +7 -0
  117. package/layout/style.css +1 -0
  118. package/loading/index.d.ts +7 -0
  119. package/loading/index.es.js +256 -1
  120. package/loading/index.umd.js +1 -1
  121. package/modal/index.d.ts +7 -0
  122. package/modal/index.es.js +1027 -1
  123. package/modal/index.umd.js +1 -1
  124. package/modal/style.css +1 -1
  125. package/nav-sprite/index.d.ts +7 -0
  126. package/nav-sprite/index.es.js +742 -0
  127. package/nav-sprite/index.umd.js +1 -0
  128. package/nav-sprite/package.json +7 -0
  129. package/nuxt/components/Accordion.js +3 -0
  130. package/nuxt/components/Alert.js +3 -0
  131. package/nuxt/components/Anchor.js +3 -0
  132. package/nuxt/components/Aside.js +3 -0
  133. package/nuxt/components/Avatar.js +3 -0
  134. package/nuxt/components/BackTop.js +3 -0
  135. package/nuxt/components/Badge.js +3 -0
  136. package/nuxt/components/Breadcrumb.js +3 -0
  137. package/nuxt/components/Button.js +3 -0
  138. package/nuxt/components/Card.js +3 -0
  139. package/nuxt/components/Carousel.js +3 -0
  140. package/nuxt/components/Cascader.js +3 -0
  141. package/nuxt/components/Checkbox.js +3 -0
  142. package/nuxt/components/Col.js +3 -0
  143. package/nuxt/components/Column.js +3 -0
  144. package/nuxt/components/Comment.js +3 -0
  145. package/nuxt/components/Content.js +3 -0
  146. package/nuxt/components/Countdown.js +3 -0
  147. package/nuxt/components/DatePicker.js +3 -0
  148. package/nuxt/components/Drawer.js +3 -0
  149. package/nuxt/components/Dropdown.js +3 -0
  150. package/nuxt/components/EditableSelect.js +3 -0
  151. package/nuxt/components/FixedOverlay.js +3 -0
  152. package/nuxt/components/FlexibleOverlay.js +3 -0
  153. package/nuxt/components/Footer.js +3 -0
  154. package/nuxt/components/Form.js +3 -0
  155. package/nuxt/components/FormControl.js +3 -0
  156. package/nuxt/components/FormItem.js +3 -0
  157. package/nuxt/components/FormLabel.js +3 -0
  158. package/nuxt/components/FormOperation.js +3 -0
  159. package/nuxt/components/Fullscreen.js +3 -0
  160. package/nuxt/components/Gantt.js +3 -0
  161. package/nuxt/components/Header.js +3 -0
  162. package/nuxt/components/Icon.js +2 -0
  163. package/nuxt/components/ImagePreviewService.js +3 -0
  164. package/nuxt/components/Input.js +3 -0
  165. package/nuxt/components/InputIcon.js +3 -0
  166. package/nuxt/components/InputNumber.js +3 -0
  167. package/nuxt/components/Layout.js +3 -0
  168. package/nuxt/components/Loading.js +3 -0
  169. package/nuxt/components/LoadingService.js +3 -0
  170. package/nuxt/components/Modal.js +3 -0
  171. package/nuxt/components/MultiUpload.js +3 -0
  172. package/nuxt/components/NavSprite.js +2 -0
  173. package/nuxt/components/Pagination.js +3 -0
  174. package/nuxt/components/Panel.js +3 -0
  175. package/nuxt/components/Popover.js +3 -0
  176. package/nuxt/components/Progress.js +3 -0
  177. package/nuxt/components/QuadrantDiagram.js +3 -0
  178. package/nuxt/components/Radio.js +3 -0
  179. package/nuxt/components/RadioGroup.js +3 -0
  180. package/nuxt/components/Rate.js +3 -0
  181. package/nuxt/components/ReadTip.js +3 -0
  182. package/nuxt/components/Result.js +3 -0
  183. package/nuxt/components/Row.js +3 -0
  184. package/nuxt/components/Search.js +3 -0
  185. package/nuxt/components/Select.js +3 -0
  186. package/nuxt/components/Skeleton.js +3 -0
  187. package/nuxt/components/SkeletonItem.js +3 -0
  188. package/nuxt/components/Slider.js +3 -0
  189. package/nuxt/components/Splitter.js +3 -0
  190. package/nuxt/components/Statistic.js +3 -0
  191. package/nuxt/components/Status.js +3 -0
  192. package/nuxt/components/StepsGuide.js +3 -0
  193. package/nuxt/components/StickSlider.js +3 -0
  194. package/nuxt/components/Sticky.js +2 -0
  195. package/nuxt/components/Switch.js +3 -0
  196. package/nuxt/components/Table.js +3 -0
  197. package/nuxt/components/Tabs.js +3 -0
  198. package/nuxt/components/Tag.js +3 -0
  199. package/nuxt/components/TagInput.js +3 -0
  200. package/nuxt/components/Textarea.js +3 -0
  201. package/nuxt/components/TimeAxis.js +3 -0
  202. package/nuxt/components/TimeAxisItem.js +3 -0
  203. package/nuxt/components/TimePicker.js +3 -0
  204. package/nuxt/components/Toast.js +3 -0
  205. package/nuxt/components/ToastService.js +3 -0
  206. package/nuxt/components/Tooltip.js +3 -0
  207. package/nuxt/components/Transfer.js +3 -0
  208. package/nuxt/components/Tree.js +3 -0
  209. package/nuxt/components/TreeSelect.js +3 -0
  210. package/nuxt/components/Upload.js +3 -0
  211. package/nuxt/components/buttonProps.js +3 -0
  212. package/nuxt/index.js +13 -0
  213. package/overlay/index.d.ts +7 -0
  214. package/overlay/index.es.js +368 -1
  215. package/overlay/index.umd.js +1 -1
  216. package/overlay/style.css +1 -1
  217. package/package.json +8 -33
  218. package/pagination/index.d.ts +7 -0
  219. package/pagination/index.es.js +642 -1
  220. package/pagination/index.umd.js +1 -1
  221. package/panel/index.d.ts +7 -0
  222. package/panel/index.es.js +205 -1
  223. package/panel/index.umd.js +1 -1
  224. package/panel/style.css +1 -1
  225. package/popover/index.d.ts +7 -0
  226. package/popover/index.es.js +236 -1
  227. package/popover/index.umd.js +1 -1
  228. package/popover/style.css +1 -1
  229. package/progress/index.d.ts +7 -0
  230. package/progress/index.es.js +153 -1
  231. package/progress/index.umd.js +3 -1
  232. package/quadrant-diagram/index.d.ts +7 -0
  233. package/quadrant-diagram/index.es.js +489 -1
  234. package/quadrant-diagram/index.umd.js +1 -1
  235. package/radio/index.d.ts +7 -0
  236. package/radio/index.es.js +225 -1
  237. package/radio/index.umd.js +1 -1
  238. package/rate/index.d.ts +7 -0
  239. package/rate/index.es.js +220 -1
  240. package/rate/index.umd.js +1 -1
  241. package/read-tip/index.d.ts +7 -0
  242. package/read-tip/index.es.js +258 -0
  243. package/read-tip/index.umd.js +1 -0
  244. package/read-tip/package.json +7 -0
  245. package/read-tip/style.css +1 -0
  246. package/result/index.d.ts +7 -0
  247. package/result/index.es.js +119 -0
  248. package/result/index.umd.js +1 -0
  249. package/result/package.json +7 -0
  250. package/result/style.css +1 -0
  251. package/ripple/index.d.ts +7 -0
  252. package/ripple/index.es.js +181 -1
  253. package/ripple/index.umd.js +1 -1
  254. package/search/index.d.ts +7 -0
  255. package/search/index.es.js +543 -1
  256. package/search/index.umd.js +1 -1
  257. package/select/index.d.ts +7 -0
  258. package/select/index.es.js +706 -1
  259. package/select/index.umd.js +1 -1
  260. package/skeleton/index.d.ts +7 -0
  261. package/skeleton/index.es.js +297 -1
  262. package/skeleton/index.umd.js +1 -1
  263. package/skeleton/style.css +1 -1
  264. package/slider/index.d.ts +7 -0
  265. package/slider/index.es.js +199 -1
  266. package/slider/index.umd.js +1 -1
  267. package/slider/style.css +1 -1
  268. package/splitter/index.d.ts +7 -0
  269. package/splitter/index.es.js +636 -1
  270. package/splitter/index.umd.js +1 -1
  271. package/statistic/index.d.ts +7 -0
  272. package/statistic/index.es.js +280 -0
  273. package/statistic/index.umd.js +1 -0
  274. package/statistic/package.json +7 -0
  275. package/statistic/style.css +1 -0
  276. package/status/index.d.ts +7 -0
  277. package/status/index.es.js +42 -1
  278. package/status/index.umd.js +1 -1
  279. package/steps-guide/index.d.ts +7 -0
  280. package/steps-guide/index.es.js +239 -1
  281. package/steps-guide/index.umd.js +1 -1
  282. package/steps-guide/style.css +1 -1
  283. package/sticky/index.d.ts +7 -0
  284. package/sticky/index.es.js +197 -1
  285. package/sticky/index.umd.js +1 -1
  286. package/style.css +1 -1
  287. package/switch/index.d.ts +7 -0
  288. package/switch/index.es.js +100 -1
  289. package/switch/index.umd.js +1 -1
  290. package/switch/style.css +1 -1
  291. package/table/index.d.ts +7 -0
  292. package/table/index.es.js +1626 -1
  293. package/table/index.umd.js +1 -1
  294. package/table/style.css +1 -1
  295. package/tabs/index.d.ts +7 -0
  296. package/tabs/index.es.js +195 -1
  297. package/tabs/index.umd.js +1 -1
  298. package/tabs/style.css +1 -1
  299. package/tag/index.d.ts +7 -0
  300. package/tag/index.es.js +131 -0
  301. package/tag/index.umd.js +1 -0
  302. package/tag/package.json +7 -0
  303. package/tag/style.css +1 -0
  304. package/tag-input/index.d.ts +7 -0
  305. package/tag-input/index.es.js +329 -1
  306. package/tag-input/index.umd.js +1 -1
  307. package/textarea/index.d.ts +7 -0
  308. package/textarea/index.es.js +132 -0
  309. package/textarea/index.umd.js +1 -0
  310. package/textarea/package.json +7 -0
  311. package/textarea/style.css +1 -0
  312. package/time-axis/index.d.ts +7 -0
  313. package/time-axis/index.es.js +299 -0
  314. package/time-axis/index.umd.js +1 -0
  315. package/time-axis/package.json +7 -0
  316. package/time-axis/style.css +1 -0
  317. package/time-picker/index.d.ts +7 -0
  318. package/time-picker/index.es.js +1053 -1
  319. package/time-picker/index.umd.js +1 -1
  320. package/time-picker/style.css +1 -1
  321. package/toast/index.d.ts +7 -0
  322. package/toast/index.es.js +2060 -1
  323. package/toast/index.umd.js +1 -1
  324. package/toast/style.css +1 -1
  325. package/tooltip/index.d.ts +7 -0
  326. package/tooltip/index.es.js +171 -1
  327. package/tooltip/index.umd.js +1 -1
  328. package/transfer/index.d.ts +7 -0
  329. package/transfer/index.es.js +1725 -1
  330. package/transfer/index.umd.js +1 -1
  331. package/transfer/style.css +1 -1
  332. package/tree/index.d.ts +7 -0
  333. package/tree/index.es.js +907 -1
  334. package/tree/index.umd.js +1 -1
  335. package/tree/style.css +1 -1
  336. package/tree-select/index.d.ts +7 -0
  337. package/tree-select/index.es.js +528 -0
  338. package/tree-select/index.umd.js +1 -0
  339. package/tree-select/package.json +7 -0
  340. package/tree-select/style.css +1 -0
  341. package/upload/index.d.ts +7 -0
  342. package/upload/index.es.js +3179 -1
  343. package/upload/index.umd.js +1 -1
  344. package/upload/style.css +1 -1
  345. package/vue-devui.es.js +27755 -1
  346. package/vue-devui.umd.js +29 -1
package/modal/index.es.js CHANGED
@@ -1 +1,1027 @@
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 v,renderSlot as y,isVNode as b,computed as m,watch as g,onUnmounted as h,withDirectives as w,vShow as C,ref as x,reactive as k,getCurrentInstance as S,onMounted 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(v,{name:"devui-overlay-fade"},(n=e=y(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")),o=document.body,l=o.style.overflow,a=o.style.position;return g([()=>e.visible,()=>e.backgroundBlock],(([e,t])=>{if(t){const t=o.getBoundingClientRect().y;e?(o.style.overflowY="scroll",o.style.position=e?"fixed":"",o.style.top=`${t}px`):(o.style.overflowY=l,o.style.position=a,o.style.top="",window.scrollTo(0,-t))}})),h((()=>{o.style.overflow=l})),{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:()=>[w(p("div",{class:n.value,style:e.backgroundStyle,onClick:l},[p("div",{class:o.value,style:e.overlayStyle,onClick:a},[y(t.slots,"default")])]),[[C,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=x(null),o=k({position:"absolute"}),l=S();B((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());g(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)}))})),g(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:()=>[w(p("div",{class:a.value,onClick:r},[p("div",{ref:n,class:i.value,style:o,onClick:d},[y(t.slots,"default")])]),[[C,e.visible]])]})}});function U(e){window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}D.install=function(e){e.component(D.name,D)},H.install=function(e){e.component(H.name,H)};var F=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(v,{name:"devui-modal-wipe"},{default:()=>{var e,o;return[n.value?null==(o=(e=t.slots).default)?void 0:o.call(e):null]}})]})}});class N{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 P extends N{component(){return F}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(P,"token","MODAL_SERVICE_TOKEN");const T={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}},A=(e,t,n)=>e<t?t:e>n?n:e;var _=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)}});_.install=function(e){e.component(_.name,_)};var q=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=x(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(_,{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)])])])}}});q.install=function(e){e.component(q.name,q)};var Z=c({name:"DModal",inheritAttrs:!1,props:T,emits:["onUpdate:modelValue"],setup(e,t){const{movingX:n,movingY:o,handleRef:l,moveElRef:a,reset:i}=((e=!0)=>{const t=x(0),n=x(0),o=x(),l=x(),a=L(e)?e:x(e);return g([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 v=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())},y=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=A(o,-a,p.width-c.width-a),n.value=A(l,-i,p.height-c.height-i)},b=e=>{e.preventDefault(),f&&(f=!1)};window.addEventListener("mousedown",v),window.addEventListener("mousemove",y),window.addEventListener("mouseup",b),i((()=>{window.removeEventListener("mousedown",v),window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",b)}))})),{movingX:M(t),movingY:M(n),handleRef:o,moveElRef:l,reset:()=>{t.value=0,n.value=0}}})();g((()=>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(q,{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=x(),f=()=>{var e,t;null==(t=null==(e=c.value)?void 0:e.onVisibleChange)||t.call(e,!1)};return t.expose({closeModal:f}),()=>p(F,{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(_,{name:s.value,size:"24px",class:"header-alert-icon"},null):null,p("span",null,[e.title]),p(q,{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 K extends N{component(){return Z}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(K,"token","DIALOG_SERVICE_TOKEN"),F.install=function(e){e.component(F.name,F)};var G={title:"Modal 弹窗",category:"反馈",status:void 0,install(e){e.use(F);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(P.token,new P(t)),e.provide(K.token,new K(t))}};export{F as Modal,G 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
+ Button.install = function(app) {
840
+ app.component(Button.name, Button);
841
+ };
842
+ function _isSlot(s) {
843
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
844
+ }
845
+ var Dialog = defineComponent({
846
+ name: "DModal",
847
+ inheritAttrs: false,
848
+ props: dialogProps,
849
+ emits: ["onUpdate:modelValue"],
850
+ setup(props, ctx) {
851
+ const {
852
+ movingX,
853
+ movingY,
854
+ handleRef,
855
+ moveElRef,
856
+ reset
857
+ } = useMoveable();
858
+ watch(() => props.modelValue, (value) => {
859
+ if (value) {
860
+ reset();
861
+ }
862
+ });
863
+ const movingStyle = computed(() => ({
864
+ position: "relative",
865
+ left: `${movingX.value}px`,
866
+ top: `${movingY.value}px`
867
+ }));
868
+ const containerStyle = computed(() => ({
869
+ width: props.width,
870
+ maxHeight: props.maxHeight,
871
+ transform: `translate(${props.offsetX}, ${props.offsetY})`,
872
+ zIndex: props.zIndex
873
+ }));
874
+ const iconName = computed(() => {
875
+ switch (props.dialogType) {
876
+ case "standard":
877
+ return "";
878
+ case "info":
879
+ return "icon-info-o";
880
+ case "success":
881
+ return "icon-right-o";
882
+ case "warning":
883
+ return "icon-warning-o";
884
+ case "failed":
885
+ return "icon-error-o";
886
+ default:
887
+ return "";
888
+ }
889
+ });
890
+ const buttonsRef = computed(() => {
891
+ return props.buttons.map((buttonProps2, index2) => {
892
+ const {
893
+ btnStyle,
894
+ disabled,
895
+ handler,
896
+ text
897
+ } = buttonProps2;
898
+ return createVNode(Button, {
899
+ "key": index2,
900
+ "style": {
901
+ display: "inline-block",
902
+ margin: "0 5px"
903
+ },
904
+ "btnStyle": btnStyle,
905
+ "disabled": disabled,
906
+ "onClick": handler
907
+ }, _isSlot(text) ? text : {
908
+ default: () => [text]
909
+ });
910
+ });
911
+ });
912
+ const modalRef = ref();
913
+ const closeModal = () => {
914
+ var _a, _b;
915
+ (_b = (_a = modalRef.value) == null ? void 0 : _a.onVisibleChange) == null ? void 0 : _b.call(_a, false);
916
+ };
917
+ ctx.expose({
918
+ closeModal
919
+ });
920
+ return () => createVNode(Modal, {
921
+ "ref": modalRef,
922
+ "width": props.width,
923
+ "maxHeight": props.maxHeight,
924
+ "offsetX": props.offsetX,
925
+ "offsetY": props.offsetY,
926
+ "zIndex": props.zIndex,
927
+ "backdropZIndex": props.backdropZIndex,
928
+ "backdropCloseable": props.backdropCloseable,
929
+ "bodyScrollable": props.bodyScrollable,
930
+ "placement": props.placement,
931
+ "onClose": props.onClose,
932
+ "beforeHidden": props.beforeHidden,
933
+ "modelValue": props.modelValue,
934
+ "onUpdate:modelValue": props["onUpdate:modelValue"]
935
+ }, {
936
+ default: () => {
937
+ var _a, _b;
938
+ return [createVNode("div", {
939
+ "class": "devui-modal-content",
940
+ "style": [containerStyle.value, movingStyle.value],
941
+ "ref": moveElRef
942
+ }, [createVNode("div", {
943
+ "class": "devui-modal-header",
944
+ "ref": handleRef
945
+ }, [!!iconName.value ? createVNode(Icon, {
946
+ "name": iconName.value,
947
+ "size": "24px",
948
+ "class": "header-alert-icon"
949
+ }, null) : null, createVNode("span", null, [props.title]), createVNode(Button, {
950
+ "class": "btn-close",
951
+ "icon": "close",
952
+ "btnStyle": "text-dark",
953
+ "onClick": closeModal
954
+ }, null)]), createVNode("div", {
955
+ "class": "devui-modal-body"
956
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createVNode("div", {
957
+ "class": "devui-modal-footer"
958
+ }, [buttonsRef.value])])];
959
+ }
960
+ });
961
+ }
962
+ });
963
+ class DialogService extends CommonModalService {
964
+ component() {
965
+ return Dialog;
966
+ }
967
+ open(props = {}) {
968
+ const anchor = document.createElement("div");
969
+ this.anchorContainer.appendChild(anchor);
970
+ const _a = props, { content } = _a, resProps = __objRest(_a, ["content"]);
971
+ const needHideOrNot = (value) => {
972
+ if (!value) {
973
+ hide();
974
+ }
975
+ };
976
+ const renderOrigin = (props2, onUpdateModelValue = needHideOrNot) => {
977
+ return this.renderModal(anchor, __spreadProps(__spreadValues({}, props2), {
978
+ modelValue: true,
979
+ "onUpdate:modelValue": onUpdateModelValue
980
+ }), { default: content });
981
+ };
982
+ const hide = () => {
983
+ var _a2, _b;
984
+ const vnode = renderOrigin(resProps, (value) => {
985
+ if (!value) {
986
+ this.renderModal(anchor, __spreadProps(__spreadValues({}, resProps), { modelValue: false }));
987
+ this.renderNull(anchor);
988
+ } else {
989
+ renderOrigin(resProps);
990
+ }
991
+ });
992
+ (_b = (_a2 = vnode.component.exposed).closeModal) == null ? void 0 : _b.call(_a2);
993
+ };
994
+ const updateButtonOptions = (buttonOptions) => {
995
+ const _a2 = resProps, { buttons } = _a2, innerResProps = __objRest(_a2, ["buttons"]);
996
+ const newButtonOptions = buttons.map((option, index2) => __spreadValues(__spreadValues({}, option), buttonOptions[index2]));
997
+ renderOrigin(__spreadProps(__spreadValues({}, innerResProps), { buttons: newButtonOptions }));
998
+ };
999
+ this.renderModal(anchor, { modelValue: false });
1000
+ renderOrigin(resProps);
1001
+ return { hide, updateButtonOptions };
1002
+ }
1003
+ }
1004
+ __publicField(DialogService, "token", "DIALOG_SERVICE_TOKEN");
1005
+ Modal.install = function(app) {
1006
+ app.component(Modal.name, Modal);
1007
+ };
1008
+ var index = {
1009
+ title: "Modal \u5F39\u7A97",
1010
+ category: "\u53CD\u9988",
1011
+ status: "100%",
1012
+ install(app) {
1013
+ app.use(Modal);
1014
+ if (!inBrowser) {
1015
+ return;
1016
+ }
1017
+ let anchorsContainer = document.getElementById("d-modal-anchors-container");
1018
+ if (!anchorsContainer) {
1019
+ anchorsContainer = document.createElement("div");
1020
+ anchorsContainer.setAttribute("id", "d-modal-anchors-container");
1021
+ document.body.appendChild(anchorsContainer);
1022
+ }
1023
+ app.provide(ModalService.token, new ModalService(anchorsContainer));
1024
+ app.provide(DialogService.token, new DialogService(anchorsContainer));
1025
+ }
1026
+ };
1027
+ export { Modal, index as default };