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
@@ -1 +1,636 @@
1
- var e=Object.defineProperty,n=("undefined"!=typeof require&&require,(n,t,i)=>(((n,t,i)=>{t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i})(n,"symbol"!=typeof t?t+"":t,i),i));import{defineComponent as t,inject as i,reactive as o,ref as l,watch as s,nextTick as a,computed as r,onMounted as p,withDirectives as u,createVNode as d,provide as c,resolveComponent as v,onUpdated as m}from"vue";const g={orientation:{type:String,default:"horizontal"},splitBarSize:{type:String,default:"2px"},disabledBarSize:{type:String,default:"1px"},showCollapseButton:{type:Boolean,default:!0}};function z(e,n){const t={},i=Object.keys(n);return i.forEach((n=>{t[n]=e.style[n]})),i.forEach((t=>{e.style[t]=n[t]})),t}function h(e,n){if(e.classList)return e.classList.contains(n);return` ${e.className} `.indexOf(` ${n} `)>-1}function S(e,n){e.classList?e.classList.add(n):h(e,n)||(e.className=`${e.className} ${n}`)}function f(e,n){if(e.classList)e.classList.remove(n);else if(h(e,n)){const t=e.className;e.className=` ${t} `.replace(` ${n} `," ")}}const x={mounted(e,{value:n}){e.$value=n,n.enableResize&&function(e){P(e,"mousedown",y)}(e)},unmounted(e,{value:n}){n.enableResize&&b(e,"mousedown",y)}};function P(e,n,t){e.addEventListener&&e.addEventListener(n,t)}function b(e,n,t){e.removeEventListener&&e.removeEventListener(n,t)}function y(e){var n;const t=null==(n=null==e?void 0:e.target)?void 0:n.$value;function i(e){t.onDragEvent(B(e))}t&&(P(document,"mousemove",i),P(document,"mouseup",(function e(n){b(document,"mousemove",i),b(document,"mouseup",e),t.onReleaseEvent(B(n))})),t.onPressEvent(B(e)))}function B(e){return{pageX:e.pageX,pageY:e.pageY,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,type:e.type,originalEvent:e}}var C=t({name:"DSplitterBar",props:{index:{type:Number},orientation:{type:String,required:!0},splitBarSize:{type:String,required:!0},disabledBarSize:{type:String,default:"1px"},showCollapseButton:{type:Boolean}},setup(e){const n=i("splitterStore"),t=o({wrapperClass:`devui-splitter-bar devui-splitter-bar-${e.orientation}`}),c=l();s((()=>e.splitBarSize),(e=>{a((()=>{z(null==c?void 0:c.value,{flexBasis:e})}))}),{immediate:!0}),s((()=>n.state.panes),(()=>{n.isStaticBar(e.index)?a((()=>{z(c.value,{flexBasis:e.disabledBarSize})})):t.wrapperClass+=" resizable"}),{deep:!0});const v={pageX:0,pageY:0,originalX:0,originalY:0};let m;const g={enableResize:!0,onPressEvent:function({originalEvent:t}){t.stopPropagation(),n.isResizable(e.index)&&(m=n.dragState(e.index),v.originalX=t.pageX,v.originalY=t.pageY)},onDragEvent:function({originalEvent:t}){if(t.stopPropagation(),!n.isResizable(e.index))return;let i;v.pageX=t.pageX,v.pageY=t.pageY,i="vertical"===e.orientation?v.pageY-v.originalY:v.pageX-v.originalX,n.setSize(m,i)},onReleaseEvent:function({originalEvent:t}){if(t.stopPropagation(),!n.isResizable(e.index))return;let i;v.pageX=t.pageX,v.pageY=t.pageY,i="vertical"===e.orientation?v.pageY-v.originalY:v.pageX-v.originalX,n.setSize(m,i)}},h=(e,t)=>({pane:n.getPane(e),nearPane:n.getPane(t)}),P=(e,n,t)=>{var i,o,l,s;return{"devui-collapse":(null==(o=null==(i=null==e?void 0:e.component)?void 0:i.props)?void 0:o.collapsible)&&t,collapsed:null==(s=null==(l=null==e?void 0:e.component)?void 0:l.props)?void 0:s.collapsed,hidden:n.collapsed}},b=r((()=>{var n,t;const{pane:i,nearPane:o}=h(e.index,e.index+1),l="after"!==(null==(t=null==(n=null==i?void 0:i.component)?void 0:n.props)?void 0:t.collapseDirection)||0===e.index;return P(i,o,l)})),y=r((()=>{var t,i;const{pane:o,nearPane:l}=h(e.index+1,e.index),s="before"!==(null==(i=null==(t=null==o?void 0:o.component)?void 0:t.props)?void 0:i.collapseDirection)||e.index+1===n.state.paneCount-1;return P(o,l,s)})),B=()=>{var n,t,i,o;const{pane:l,nearPane:s}=h(e.index,e.index+1);(null==(t=null==(n=null==l?void 0:l.component)?void 0:n.props)?void 0:t.collapsed)||(null==(o=null==(i=null==s?void 0:s.component)?void 0:i.props)?void 0:o.collapsed)?S(c.value,"none-resizable"):f(c.value,"none-resizable")},C=t=>{n.tooglePane(e.index,e.index+1,t),B()},w=t=>{n.tooglePane(e.index+1,e.index,t),B()};return p((()=>{C(!0),w(!0)})),()=>u(d("div",{class:t.wrapperClass,ref:c},[e.showCollapseButton?d("div",{class:["prev",b.value],onClick:()=>{C()}},null):null,d("div",{class:"devui-resize-handle"},null),e.showCollapseButton?d("div",{class:["next",y.value],onClick:()=>w()},null):null]),[[x,g]])}});class w{constructor(){n(this,"state"),this.state=o({panes:[],splitterContainerSize:0,paneCount:0})}setPanes({panes:e}){this.state.panes=e.map(((e,n)=>{var t;return e.component&&(e.component.exposed.order.value=2*n),e.getPaneSize=null==(t=null==e?void 0:e.component)?void 0:t.exposed.getPaneSize,e})),this.state.paneCount=e.length}setSplitter({containerSize:e}){this.state.splitterContainerSize=e}getPane(e){if(!this.state.panes||e<0||e>=this.state.panes.length)throw new Error("no pane can return.");return this.state.panes[e]}dragState(e){const n=this.getPane(e),t=this.getPane(e+1),i=n.getPaneSize()+t.getPaneSize();return{prev:{index:e,initialSize:n.getPaneSize(),minSize:this.toPixels(n.component.props.minSize)||i-this.toPixels(t.component.props.maxSize)||0,maxSize:this.toPixels(n.component.props.maxSize)||i-this.toPixels(t.component.props.minSize)||i},next:{index:e+1,initialSize:t.getPaneSize(),minSize:this.toPixels(t.component.props.minSize)||i-this.toPixels(n.component.props.maxSize)||0,maxSize:this.toPixels(t.component.props.maxSize)||i-this.toPixels(n.component.props.minSize)||i}}}clamp(e,n,t){return Math.min(n,Math.max(e,t))}resize(e,n){const t=this.getPane(e.index),i=this.state.splitterContainerSize,o=this.clamp(e.minSize,e.maxSize,e.initialSize+n);let l="";l=this.isPercent(t.component.props.size)?o/i*100+"%":o+"px",t.component.props.size=l,t.component.emit("sizeChange",l)}isResizable(e){var n,t,i,o,l,s,a,r;const p=this.getPane(e),u=this.getPane(e+1),d=(null==(t=null==(n=null==p?void 0:p.component)?void 0:n.props)?void 0:t.collapsed)||(null==(o=null==(i=null==u?void 0:u.component)?void 0:i.props)?void 0:o.collapsed);return(null==(s=null==(l=null==p?void 0:p.component)?void 0:l.props)?void 0:s.resizable)&&(null==(r=null==(a=null==u?void 0:u.component)?void 0:a.props)?void 0:r.resizable)&&!d}isStaticBar(e){var n,t,i,o;const l=this.getPane(e),s=this.getPane(e+1);return!((null==(t=null==(n=null==l?void 0:l.component)?void 0:n.props)?void 0:t.resizable)&&(null==(o=null==(i=null==s?void 0:s.component)?void 0:i.props)?void 0:o.resizable))}isPercent(e){return/%$/.test(e)}toPixels(e){let n=parseFloat(e);return this.isPercent(e)&&(n=this.state.splitterContainerSize*n/100),n}tooglePane(e,n,t){var i,o,l,s,a,r,p,u,d,c,v,m,g;const z=this.getPane(e),h=this.getPane(n);(null==(o=null==(i=null==z?void 0:z.component)?void 0:i.props)?void 0:o.collapsible)&&(z.component.props.collapsed=t?null==(s=null==(l=null==z?void 0:z.component)?void 0:l.props)?void 0:s.collapsed:!(null==(r=null==(a=null==z?void 0:z.component)?void 0:a.props)?void 0:r.collapsed),null==(c=null==(p=null==h?void 0:h.component)?void 0:p.exposed)||c.toggleNearPaneFlexGrow(null==(d=null==(u=null==z?void 0:z.component)?void 0:u.props)?void 0:d.collapsed),null==(g=null==z?void 0:z.component)||g.emit("collapsedChange",null==(m=null==(v=null==z?void 0:z.component)?void 0:v.props)?void 0:m.collapsed))}setSize(e,n){const t=this.getPane(e.prev.index),i=this.getPane(e.next.index);t.component.props.size&&i.component.props.size?(this.resize(e.prev,n),this.resize(e.next,-n)):i.component.props.size?this.resize(e.next,-n):this.resize(e.prev,n)}}var X=t({name:"DSplitter",components:{DSplitterBar:C},props:g,emits:[],setup(e,n){var t,i;const s=new w,r=o({panes:[]});r.panes=(null==(i=(t=n.slots).DSplitterPane)?void 0:i.call(t))||[],s.setPanes({panes:r.panes});const p=l();return c("orientation",e.orientation),c("splitterStore",s),a((()=>{let n=0;n="vertical"===e.orientation?p.value.clientHeight:p.value.clientWidth,s.setSplitter({containerSize:n})})),()=>{const{splitBarSize:n,orientation:t,showCollapseButton:i}=e;return d("div",{class:["devui-splitter",`devui-splitter-${t}`],ref:p},[r.panes,r.panes.filter(((e,n,t)=>n!==t.length-1)).map(((e,o)=>d(v("d-splitter-bar"),{key:o,style:"order: "+(2*o+1),splitBarSize:n,orientation:t,index:o,showCollapseButton:i},null)))])}}});var Y=t({name:"DSplitterPane",props:{size:{type:String},minSize:{type:String},maxSize:{type:String},resizable:{type:Boolean,default:!0},collapsible:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!1},collapseDirection:{type:String,default:"both"},shrink:{type:Boolean,default:!1},shrinkWidth:{type:Number,default:36}},emits:["sizeChange","collapsedChange"],setup(e,{slots:n,expose:t}){const o=i("splitterStore"),r=l(),u=l();s((()=>u.value),(e=>{a((()=>{z(r.value,{order:e})}))}));s((()=>e.size),(e=>{a((()=>{(e=>{const n=r.value;n.style.flexBasis=e;const t="devui-splitter-pane-fixed";e?S(n,t):f(n,t)})(e)}))}),{immediate:!0});const c=i("orientation");let v="";p((()=>{v=e.size,o.setPanes({panes:o.state.panes})})),m((()=>{o.setPanes({panes:o.state.panes})}));s((()=>e.collapsed),(()=>{a((()=>{(()=>{const n="devui-splitter-pane-hidden";a((()=>{const t=r.value;e.collapsed?S(t,n):f(t,n),e.collapsed&&e.shrink?(f(t,n),z(t,{flexBasis:`${e.shrinkWidth}px`})):z(t,{flexBasis:v})}))})()}))}),{immediate:!0});return t({order:u,getPaneSize:()=>{const e=null==r?void 0:r.value;return"vertical"===c?e.offsetHeight:e.offsetWidth},toggleNearPaneFlexGrow:e=>{a((()=>{const n="devui-splitter-pane-grow";h(r.value,n)?f(r.value,n):e&&S(r.value,n)}))}}),()=>{var e;return d("div",{class:"devui-splitter-pane",ref:r},[null==(e=n.default)?void 0:e.call(n)])}}});X.install=function(e){e.component(X.name,X),e.component(Y.name,Y)};var E={title:"Splitter 分割器",category:"布局",install(e){e.use(X)}};export{X as Splitter,E as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { defineComponent, inject, reactive, ref, watch, computed, onMounted, withDirectives, createVNode, provide, onUnmounted, resolveComponent, onUpdated } from "vue";
8
+ const splitterProps = {
9
+ orientation: {
10
+ type: String,
11
+ default: "horizontal"
12
+ },
13
+ splitBarSize: {
14
+ type: String,
15
+ default: "2px"
16
+ },
17
+ disabledBarSize: {
18
+ type: String,
19
+ default: "1px"
20
+ },
21
+ showCollapseButton: {
22
+ type: Boolean,
23
+ default: true
24
+ }
25
+ };
26
+ function setStyle(element, style) {
27
+ const oldStyle = {};
28
+ const styleKeys = Object.keys(style);
29
+ styleKeys.forEach((key) => {
30
+ oldStyle[key] = element.style[key];
31
+ });
32
+ styleKeys.forEach((key) => {
33
+ element.style[key] = style[key];
34
+ });
35
+ return oldStyle;
36
+ }
37
+ function hasClass(el, className) {
38
+ if (el.classList) {
39
+ return el.classList.contains(className);
40
+ }
41
+ const originClass = el.className;
42
+ return ` ${originClass} `.indexOf(` ${className} `) > -1;
43
+ }
44
+ function addClass(el, className) {
45
+ if (el.classList) {
46
+ el.classList.add(className);
47
+ } else {
48
+ if (!hasClass(el, className)) {
49
+ el.className = `${el.className} ${className}`;
50
+ }
51
+ }
52
+ }
53
+ function removeClass(el, className) {
54
+ if (el.classList) {
55
+ el.classList.remove(className);
56
+ } else {
57
+ if (hasClass(el, className)) {
58
+ const originClass = el.className;
59
+ el.className = ` ${originClass} `.replace(` ${className} `, " ");
60
+ }
61
+ }
62
+ }
63
+ const resize = {
64
+ mounted(el, { value }) {
65
+ el.$value = value;
66
+ if (value.enableResize) {
67
+ bindEvent(el);
68
+ }
69
+ },
70
+ unmounted(el, { value }) {
71
+ if (value.enableResize) {
72
+ unbind(el, "mousedown", onMousedown);
73
+ }
74
+ }
75
+ };
76
+ function bindEvent(el) {
77
+ bind(el, "mousedown", onMousedown);
78
+ }
79
+ function bind(el, event, callback) {
80
+ el.addEventListener && el.addEventListener(event, callback);
81
+ }
82
+ function unbind(el, event, callback) {
83
+ el.removeEventListener && el.removeEventListener(event, callback);
84
+ }
85
+ function onMousedown(e) {
86
+ var _a;
87
+ const $value = (_a = e == null ? void 0 : e.target) == null ? void 0 : _a.$value;
88
+ if (!$value)
89
+ return;
90
+ bind(document, "mousemove", onMousemove);
91
+ bind(document, "mouseup", onMouseup);
92
+ $value.onPressEvent(normalizeEvent(e));
93
+ function onMousemove(e2) {
94
+ $value.onDragEvent(normalizeEvent(e2));
95
+ }
96
+ function onMouseup(e2) {
97
+ unbind(document, "mousemove", onMousemove);
98
+ unbind(document, "mouseup", onMouseup);
99
+ $value.onReleaseEvent(normalizeEvent(e2));
100
+ }
101
+ }
102
+ function normalizeEvent(e) {
103
+ return {
104
+ pageX: e.pageX,
105
+ pageY: e.pageY,
106
+ clientX: e.clientX,
107
+ clientY: e.clientY,
108
+ offsetX: e.offsetX,
109
+ offsetY: e.offsetY,
110
+ type: e.type,
111
+ originalEvent: e
112
+ };
113
+ }
114
+ var splitterBar = "";
115
+ const splitterBarProps = {
116
+ index: {
117
+ type: Number
118
+ },
119
+ orientation: {
120
+ type: String,
121
+ required: true
122
+ },
123
+ splitBarSize: {
124
+ type: String,
125
+ required: true
126
+ },
127
+ disabledBarSize: {
128
+ type: String,
129
+ default: "1px"
130
+ },
131
+ showCollapseButton: {
132
+ type: Boolean
133
+ }
134
+ };
135
+ var DSplitterBar = defineComponent({
136
+ name: "DSplitterBar",
137
+ props: splitterBarProps,
138
+ setup(props) {
139
+ const store = inject("splitterStore");
140
+ const state = reactive({
141
+ wrapperClass: `devui-splitter-bar devui-splitter-bar-${props.orientation}`
142
+ });
143
+ const domRef = ref();
144
+ watch([() => props.splitBarSize, domRef], ([curSplitBarSize, ele]) => {
145
+ if (!(ele instanceof HTMLElement)) {
146
+ return;
147
+ }
148
+ setStyle(ele, {
149
+ flexBasis: curSplitBarSize
150
+ });
151
+ }, {
152
+ immediate: true
153
+ });
154
+ watch([() => store.state.panes, domRef], ([panes, ele]) => {
155
+ if (!store.isStaticBar(props.index)) {
156
+ state.wrapperClass += " resizable";
157
+ } else {
158
+ setStyle(ele, {
159
+ flexBasis: props.disabledBarSize
160
+ });
161
+ }
162
+ }, {
163
+ deep: true
164
+ });
165
+ const coordinate = {
166
+ pageX: 0,
167
+ pageY: 0,
168
+ originalX: 0,
169
+ originalY: 0
170
+ };
171
+ let initState;
172
+ const resizeProp = {
173
+ enableResize: true,
174
+ onPressEvent: function({
175
+ originalEvent
176
+ }) {
177
+ originalEvent.stopPropagation();
178
+ if (!store.isResizable(props.index))
179
+ return;
180
+ initState = store.dragState(props.index);
181
+ coordinate.originalX = originalEvent.pageX;
182
+ coordinate.originalY = originalEvent.pageY;
183
+ },
184
+ onDragEvent: function({
185
+ originalEvent
186
+ }) {
187
+ originalEvent.stopPropagation();
188
+ if (!store.isResizable(props.index))
189
+ return;
190
+ coordinate.pageX = originalEvent.pageX;
191
+ coordinate.pageY = originalEvent.pageY;
192
+ let distance;
193
+ if (props.orientation === "vertical") {
194
+ distance = coordinate.pageY - coordinate.originalY;
195
+ } else {
196
+ distance = coordinate.pageX - coordinate.originalX;
197
+ }
198
+ store.setSize(initState, distance);
199
+ },
200
+ onReleaseEvent: function({
201
+ originalEvent
202
+ }) {
203
+ originalEvent.stopPropagation();
204
+ if (!store.isResizable(props.index))
205
+ return;
206
+ coordinate.pageX = originalEvent.pageX;
207
+ coordinate.pageY = originalEvent.pageY;
208
+ let distance;
209
+ if (props.orientation === "vertical") {
210
+ distance = coordinate.pageY - coordinate.originalY;
211
+ } else {
212
+ distance = coordinate.pageX - coordinate.originalX;
213
+ }
214
+ store.setSize(initState, distance);
215
+ }
216
+ };
217
+ const queryPanes = (index2, nearIndex) => {
218
+ const pane = store.getPane(index2);
219
+ const nearPane = store.getPane(nearIndex);
220
+ return {
221
+ pane,
222
+ nearPane
223
+ };
224
+ };
225
+ const generateCollapseClass = (pane, nearPane, showIcon) => {
226
+ var _a, _b, _c, _d;
227
+ const isCollapsible = ((_b = (_a = pane == null ? void 0 : pane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.collapsible) && showIcon;
228
+ const isCollapsed = (_d = (_c = pane == null ? void 0 : pane.component) == null ? void 0 : _c.props) == null ? void 0 : _d.collapsed;
229
+ const isNearPaneCollapsed = nearPane.collapsed;
230
+ return {
231
+ "devui-collapse": isCollapsible,
232
+ collapsed: isCollapsed,
233
+ hidden: isNearPaneCollapsed
234
+ };
235
+ };
236
+ const prevClass = computed(() => {
237
+ var _a, _b;
238
+ const {
239
+ pane,
240
+ nearPane
241
+ } = queryPanes(props.index, props.index + 1);
242
+ const showIcon = ((_b = (_a = pane == null ? void 0 : pane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.collapseDirection) !== "after" || props.index === 0;
243
+ return generateCollapseClass(pane, nearPane, showIcon);
244
+ });
245
+ const nextClass = computed(() => {
246
+ var _a, _b;
247
+ const {
248
+ pane,
249
+ nearPane
250
+ } = queryPanes(props.index + 1, props.index);
251
+ const showIcon = ((_b = (_a = pane == null ? void 0 : pane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.collapseDirection) !== "before" || props.index + 1 === store.state.paneCount - 1;
252
+ return generateCollapseClass(pane, nearPane, showIcon);
253
+ });
254
+ const toggleResize = () => {
255
+ var _a, _b, _c, _d;
256
+ const {
257
+ pane,
258
+ nearPane
259
+ } = queryPanes(props.index, props.index + 1);
260
+ const isCollapsed = ((_b = (_a = pane == null ? void 0 : pane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.collapsed) || ((_d = (_c = nearPane == null ? void 0 : nearPane.component) == null ? void 0 : _c.props) == null ? void 0 : _d.collapsed);
261
+ if (isCollapsed) {
262
+ addClass(domRef.value, "none-resizable");
263
+ } else {
264
+ removeClass(domRef.value, "none-resizable");
265
+ }
266
+ };
267
+ const handleCollapsePrePane = (lockStatus) => {
268
+ store.tooglePane(props.index, props.index + 1, lockStatus);
269
+ toggleResize();
270
+ };
271
+ const handleCollapseNextPane = (lockStatus) => {
272
+ store.tooglePane(props.index + 1, props.index, lockStatus);
273
+ toggleResize();
274
+ };
275
+ const initialCollapseStatus = () => {
276
+ handleCollapsePrePane(true);
277
+ handleCollapseNextPane(true);
278
+ };
279
+ onMounted(() => {
280
+ initialCollapseStatus();
281
+ });
282
+ return () => {
283
+ return withDirectives(createVNode("div", {
284
+ "class": state.wrapperClass,
285
+ "ref": domRef
286
+ }, [props.showCollapseButton ? createVNode("div", {
287
+ "class": ["prev", prevClass.value],
288
+ "onClick": () => {
289
+ handleCollapsePrePane();
290
+ }
291
+ }, null) : null, createVNode("div", {
292
+ "class": "devui-resize-handle"
293
+ }, null), props.showCollapseButton ? createVNode("div", {
294
+ "class": ["next", nextClass.value],
295
+ "onClick": () => handleCollapseNextPane()
296
+ }, null) : null]), [[resize, resizeProp]]);
297
+ };
298
+ }
299
+ });
300
+ class SplitterStore {
301
+ constructor() {
302
+ __publicField(this, "state");
303
+ this.state = reactive({
304
+ panes: [],
305
+ splitterContainerSize: 0,
306
+ paneCount: 0
307
+ });
308
+ }
309
+ setPanes({ panes }) {
310
+ this.state.panes = panes.map((pane, index2) => {
311
+ var _a;
312
+ if (pane.component) {
313
+ pane.component.exposed.order.value = index2 * 2;
314
+ }
315
+ pane.getPaneSize = (_a = pane == null ? void 0 : pane.component) == null ? void 0 : _a.exposed.getPaneSize;
316
+ return pane;
317
+ });
318
+ this.state.paneCount = panes.length;
319
+ }
320
+ setSplitter({ containerSize }) {
321
+ this.state.splitterContainerSize = containerSize;
322
+ }
323
+ getPane(index2) {
324
+ if (!this.state.panes || index2 < 0 || index2 >= this.state.panes.length) {
325
+ throw new Error("no pane can return.");
326
+ }
327
+ return this.state.panes[index2];
328
+ }
329
+ dragState(splitbarIndex) {
330
+ const prev = this.getPane(splitbarIndex);
331
+ const next = this.getPane(splitbarIndex + 1);
332
+ const total = prev.getPaneSize() + next.getPaneSize();
333
+ return {
334
+ prev: {
335
+ index: splitbarIndex,
336
+ initialSize: prev.getPaneSize(),
337
+ minSize: this.toPixels(prev.component.props.minSize) || total - this.toPixels(next.component.props.maxSize) || 0,
338
+ maxSize: this.toPixels(prev.component.props.maxSize) || total - this.toPixels(next.component.props.minSize) || total
339
+ },
340
+ next: {
341
+ index: splitbarIndex + 1,
342
+ initialSize: next.getPaneSize(),
343
+ minSize: this.toPixels(next.component.props.minSize) || total - this.toPixels(prev.component.props.maxSize) || 0,
344
+ maxSize: this.toPixels(next.component.props.maxSize) || total - this.toPixels(prev.component.props.minSize) || total
345
+ }
346
+ };
347
+ }
348
+ clamp(minSize, maxSize, initialSize) {
349
+ return Math.min(maxSize, Math.max(minSize, initialSize));
350
+ }
351
+ resize(paneState, moveSize) {
352
+ const pane = this.getPane(paneState.index);
353
+ const splitterSize = this.state.splitterContainerSize;
354
+ const newSize = this.clamp(paneState.minSize, paneState.maxSize, paneState.initialSize + moveSize);
355
+ let size = "";
356
+ if (this.isPercent(pane.component.props.size)) {
357
+ size = newSize / splitterSize * 100 + "%";
358
+ } else {
359
+ size = newSize + "px";
360
+ }
361
+ pane.component.props.size = size;
362
+ pane.component.emit("sizeChange", size);
363
+ }
364
+ isResizable(splitBarIndex) {
365
+ var _a, _b, _c, _d, _e, _f, _g, _h;
366
+ const prevPane = this.getPane(splitBarIndex);
367
+ const nextPane = this.getPane(splitBarIndex + 1);
368
+ const paneCollapsed = ((_b = (_a = prevPane == null ? void 0 : prevPane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.collapsed) || ((_d = (_c = nextPane == null ? void 0 : nextPane.component) == null ? void 0 : _c.props) == null ? void 0 : _d.collapsed);
369
+ return ((_f = (_e = prevPane == null ? void 0 : prevPane.component) == null ? void 0 : _e.props) == null ? void 0 : _f.resizable) && ((_h = (_g = nextPane == null ? void 0 : nextPane.component) == null ? void 0 : _g.props) == null ? void 0 : _h.resizable) && !paneCollapsed;
370
+ }
371
+ isStaticBar(splitBarIndex) {
372
+ var _a, _b, _c, _d;
373
+ const prevPane = this.getPane(splitBarIndex);
374
+ const nextPane = this.getPane(splitBarIndex + 1);
375
+ return !(((_b = (_a = prevPane == null ? void 0 : prevPane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.resizable) && ((_d = (_c = nextPane == null ? void 0 : nextPane.component) == null ? void 0 : _c.props) == null ? void 0 : _d.resizable));
376
+ }
377
+ isPercent(size) {
378
+ return /%$/.test(size);
379
+ }
380
+ toPixels(size) {
381
+ let result = parseFloat(size);
382
+ if (this.isPercent(size)) {
383
+ result = this.state.splitterContainerSize * result / 100;
384
+ }
385
+ return result;
386
+ }
387
+ tooglePane(paneIndex, nearPaneIndex, lockStatus) {
388
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
389
+ const pane = this.getPane(paneIndex);
390
+ const nearPane = this.getPane(nearPaneIndex);
391
+ if ((_b = (_a = pane == null ? void 0 : pane.component) == null ? void 0 : _a.props) == null ? void 0 : _b.collapsible) {
392
+ pane.component.props.collapsed = lockStatus ? (_d = (_c = pane == null ? void 0 : pane.component) == null ? void 0 : _c.props) == null ? void 0 : _d.collapsed : !((_f = (_e = pane == null ? void 0 : pane.component) == null ? void 0 : _e.props) == null ? void 0 : _f.collapsed);
393
+ (_j = (_g = nearPane == null ? void 0 : nearPane.component) == null ? void 0 : _g.exposed) == null ? void 0 : _j.toggleNearPaneFlexGrow((_i = (_h = pane == null ? void 0 : pane.component) == null ? void 0 : _h.props) == null ? void 0 : _i.collapsed);
394
+ (_m = pane == null ? void 0 : pane.component) == null ? void 0 : _m.emit("collapsedChange", (_l = (_k = pane == null ? void 0 : pane.component) == null ? void 0 : _k.props) == null ? void 0 : _l.collapsed);
395
+ }
396
+ }
397
+ setSize(state, distance) {
398
+ const prev = this.getPane(state.prev.index);
399
+ const next = this.getPane(state.next.index);
400
+ if (prev.component.props.size && next.component.props.size) {
401
+ this.resize(state.prev, distance);
402
+ this.resize(state.next, -distance);
403
+ } else if (next.component.props.size) {
404
+ this.resize(state.next, -distance);
405
+ } else {
406
+ this.resize(state.prev, distance);
407
+ }
408
+ }
409
+ }
410
+ var splitter = "";
411
+ var Splitter = defineComponent({
412
+ name: "DSplitter",
413
+ components: {
414
+ DSplitterBar
415
+ },
416
+ props: splitterProps,
417
+ emits: [],
418
+ setup(props, ctx) {
419
+ var _a, _b;
420
+ const store = new SplitterStore();
421
+ const state = reactive({
422
+ panes: []
423
+ });
424
+ state.panes = ((_b = (_a = ctx.slots).DSplitterPane) == null ? void 0 : _b.call(_a)) || [];
425
+ store.setPanes({
426
+ panes: state.panes
427
+ });
428
+ provide("orientation", props.orientation);
429
+ provide("splitterStore", store);
430
+ const domRef = ref();
431
+ const refreshSplitterContainerSize = () => {
432
+ if (!domRef)
433
+ return;
434
+ let containerSize = 0;
435
+ if (props.orientation === "vertical") {
436
+ containerSize = domRef.value.clientHeight;
437
+ } else {
438
+ containerSize = domRef.value.clientWidth;
439
+ }
440
+ store.setSplitter({
441
+ containerSize
442
+ });
443
+ };
444
+ const observer = new ResizeObserver(refreshSplitterContainerSize);
445
+ watch(domRef, (ele) => {
446
+ if (!ele) {
447
+ return;
448
+ }
449
+ refreshSplitterContainerSize();
450
+ observer.observe(domRef.value);
451
+ });
452
+ onUnmounted(() => {
453
+ observer.disconnect();
454
+ });
455
+ return () => {
456
+ const {
457
+ splitBarSize,
458
+ orientation,
459
+ showCollapseButton
460
+ } = props;
461
+ const wrapperClass = ["devui-splitter", `devui-splitter-${orientation}`];
462
+ return createVNode("div", {
463
+ "class": wrapperClass,
464
+ "ref": domRef
465
+ }, [state.panes, state.panes.filter((pane, index2, arr) => index2 !== arr.length - 1).map((pane, index2) => {
466
+ return createVNode(resolveComponent("d-splitter-bar"), {
467
+ "key": index2,
468
+ "style": `order: ${index2 * 2 + 1}`,
469
+ "splitBarSize": splitBarSize,
470
+ "orientation": orientation,
471
+ "index": index2,
472
+ "showCollapseButton": showCollapseButton
473
+ }, null);
474
+ })]);
475
+ };
476
+ }
477
+ });
478
+ const splitterPaneProps = {
479
+ size: {
480
+ type: String
481
+ },
482
+ minSize: {
483
+ type: String
484
+ },
485
+ maxSize: {
486
+ type: String
487
+ },
488
+ resizable: {
489
+ type: Boolean,
490
+ default: true
491
+ },
492
+ collapsible: {
493
+ type: Boolean,
494
+ default: false
495
+ },
496
+ collapsed: {
497
+ type: Boolean,
498
+ default: false
499
+ },
500
+ collapseDirection: {
501
+ type: String,
502
+ default: "both"
503
+ },
504
+ shrink: {
505
+ type: Boolean,
506
+ default: false
507
+ },
508
+ shrinkWidth: {
509
+ type: Number,
510
+ default: 36
511
+ }
512
+ };
513
+ var splitterPane = "";
514
+ var SplitterPane = defineComponent({
515
+ name: "DSplitterPane",
516
+ props: splitterPaneProps,
517
+ emits: ["sizeChange", "collapsedChange"],
518
+ setup(props, {
519
+ slots,
520
+ expose
521
+ }) {
522
+ const store = inject("splitterStore");
523
+ const domRef = ref();
524
+ const orderRef = ref();
525
+ watch([orderRef, domRef], ([order, ele]) => {
526
+ if (!ele) {
527
+ return;
528
+ }
529
+ setStyle(ele, {
530
+ order
531
+ });
532
+ });
533
+ const setSizeStyle = (curSize, ele) => {
534
+ if (!ele) {
535
+ return;
536
+ }
537
+ ele.style.flexBasis = curSize;
538
+ const paneFixedClass = "devui-splitter-pane-fixed";
539
+ if (curSize) {
540
+ addClass(ele, paneFixedClass);
541
+ } else {
542
+ removeClass(ele, paneFixedClass);
543
+ }
544
+ };
545
+ watch([() => props.size, domRef], ([size, ele]) => {
546
+ setSizeStyle(size, ele);
547
+ }, {
548
+ immediate: true
549
+ });
550
+ const orientation = inject("orientation");
551
+ let initialSize = "";
552
+ onMounted(() => {
553
+ initialSize = props.size;
554
+ store.setPanes({
555
+ panes: store.state.panes
556
+ });
557
+ });
558
+ onUpdated(() => {
559
+ store.setPanes({
560
+ panes: store.state.panes
561
+ });
562
+ });
563
+ const getPaneSize = () => {
564
+ const ele = domRef.value;
565
+ if (!ele) {
566
+ return;
567
+ }
568
+ if (orientation === "vertical") {
569
+ return ele.offsetHeight;
570
+ } else {
571
+ return ele.offsetWidth;
572
+ }
573
+ };
574
+ watch(() => props.collapsed, (collapsed) => {
575
+ const ele = domRef.value;
576
+ if (!ele) {
577
+ return;
578
+ }
579
+ const paneHiddenClass = "devui-splitter-pane-hidden";
580
+ if (!collapsed) {
581
+ removeClass(ele, paneHiddenClass);
582
+ } else {
583
+ addClass(ele, paneHiddenClass);
584
+ }
585
+ if (collapsed && props.shrink) {
586
+ removeClass(ele, paneHiddenClass);
587
+ setStyle(ele, {
588
+ flexBasis: `${props.shrinkWidth}px`
589
+ });
590
+ } else {
591
+ setStyle(ele, {
592
+ flexBasis: initialSize
593
+ });
594
+ }
595
+ }, {
596
+ immediate: true
597
+ });
598
+ const toggleNearPaneFlexGrow = (collapsed) => {
599
+ const ele = domRef.value;
600
+ if (!(ele instanceof HTMLElement)) {
601
+ return;
602
+ }
603
+ const flexGrowClass = "devui-splitter-pane-grow";
604
+ if (hasClass(ele, flexGrowClass)) {
605
+ removeClass(ele, flexGrowClass);
606
+ } else if (collapsed) {
607
+ addClass(ele, flexGrowClass);
608
+ }
609
+ };
610
+ expose({
611
+ order: orderRef,
612
+ getPaneSize,
613
+ toggleNearPaneFlexGrow
614
+ });
615
+ return () => {
616
+ var _a;
617
+ return createVNode("div", {
618
+ "class": "devui-splitter-pane",
619
+ "ref": domRef
620
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
621
+ };
622
+ }
623
+ });
624
+ Splitter.install = function(app) {
625
+ app.component(Splitter.name, Splitter);
626
+ app.component(SplitterPane.name, SplitterPane);
627
+ };
628
+ var index = {
629
+ title: "Splitter \u5206\u5272\u5668",
630
+ category: "\u5E03\u5C40",
631
+ status: "100%",
632
+ install(app) {
633
+ app.use(Splitter);
634
+ }
635
+ };
636
+ export { Splitter, index as default };