38faf07122910353eb7a9a685e55cd7ec0d23a4088df0bcebbbb437a637f922bc885074975d344377f47c13e4c82ad3d645419aca848b904da866e8344cbc4 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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 splitpanes_vue_vue_type_style_index_0_lang = "";
  33. function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
  34. var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
  35. if (render2) {
  36. options.render = render2;
  37. options.staticRenderFns = staticRenderFns2;
  38. options._compiled = true;
  39. }
  40. if (functionalTemplate) {
  41. options.functional = true;
  42. }
  43. if (scopeId) {
  44. options._scopeId = "data-v-" + scopeId;
  45. }
  46. var hook;
  47. if (moduleIdentifier) {
  48. hook = function(context) {
  49. context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
  50. if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
  51. context = __VUE_SSR_CONTEXT__;
  52. }
  53. if (injectStyles) {
  54. injectStyles.call(this, context);
  55. }
  56. if (context && context._registeredComponents) {
  57. context._registeredComponents.add(moduleIdentifier);
  58. }
  59. };
  60. options._ssrRegister = hook;
  61. } else if (injectStyles) {
  62. hook = shadowMode ? function() {
  63. injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
  64. } : injectStyles;
  65. }
  66. if (hook) {
  67. if (options.functional) {
  68. options._injectStyles = hook;
  69. var originalRender = options.render;
  70. options.render = function renderWithStyleInjection(h, context) {
  71. hook.call(context);
  72. return originalRender(h, context);
  73. };
  74. } else {
  75. var existing = options.beforeCreate;
  76. options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
  77. }
  78. }
  79. return {
  80. exports: scriptExports,
  81. options
  82. };
  83. }
  84. const __vue2_script$1 = {
  85. name: "splitpanes",
  86. props: {
  87. horizontal: { type: Boolean },
  88. pushOtherPanes: { type: Boolean, default: true },
  89. dblClickSplitter: { type: Boolean, default: true },
  90. rtl: { type: Boolean, default: false },
  91. firstSplitter: { type: Boolean }
  92. },
  93. provide() {
  94. return {
  95. requestUpdate: this.requestUpdate,
  96. onPaneAdd: this.onPaneAdd,
  97. onPaneRemove: this.onPaneRemove,
  98. onPaneClick: this.onPaneClick
  99. };
  100. },
  101. data: () => ({
  102. container: null,
  103. ready: false,
  104. panes: [],
  105. touch: {
  106. mouseDown: false,
  107. dragging: false,
  108. activeSplitter: null
  109. },
  110. splitterTaps: {
  111. splitter: null,
  112. timeoutId: null
  113. }
  114. }),
  115. computed: {
  116. panesCount() {
  117. return this.panes.length;
  118. },
  119. indexedPanes() {
  120. return this.panes.reduce((obj, pane2) => (obj[pane2.id] = pane2) && obj, {});
  121. }
  122. },
  123. methods: {
  124. updatePaneComponents() {
  125. this.panes.forEach((pane2) => {
  126. pane2.update && pane2.update({
  127. [this.horizontal ? "height" : "width"]: `${this.indexedPanes[pane2.id].size}%`
  128. });
  129. });
  130. },
  131. bindEvents() {
  132. document.addEventListener("mousemove", this.onMouseMove, { passive: false });
  133. document.addEventListener("mouseup", this.onMouseUp);
  134. if ("ontouchstart" in window) {
  135. document.addEventListener("touchmove", this.onMouseMove, { passive: false });
  136. document.addEventListener("touchend", this.onMouseUp);
  137. }
  138. },
  139. unbindEvents() {
  140. document.removeEventListener("mousemove", this.onMouseMove, { passive: false });
  141. document.removeEventListener("mouseup", this.onMouseUp);
  142. if ("ontouchstart" in window) {
  143. document.removeEventListener("touchmove", this.onMouseMove, { passive: false });
  144. document.removeEventListener("touchend", this.onMouseUp);
  145. }
  146. },
  147. onMouseDown(event, splitterIndex) {
  148. this.bindEvents();
  149. this.touch.mouseDown = true;
  150. this.touch.activeSplitter = splitterIndex;
  151. },
  152. onMouseMove(event) {
  153. if (this.touch.mouseDown) {
  154. event.preventDefault();
  155. this.touch.dragging = true;
  156. this.calculatePanesSize(this.getCurrentMouseDrag(event));
  157. this.$emit("resize", this.panes.map((pane2) => ({ min: pane2.min, max: pane2.max, size: pane2.size })));
  158. }
  159. },
  160. onMouseUp() {
  161. if (this.touch.dragging) {
  162. this.$emit("resized", this.panes.map((pane2) => ({ min: pane2.min, max: pane2.max, size: pane2.size })));
  163. }
  164. this.touch.mouseDown = false;
  165. setTimeout(() => {
  166. this.touch.dragging = false;
  167. this.unbindEvents();
  168. }, 100);
  169. },
  170. onSplitterClick(event, splitterIndex) {
  171. if ("ontouchstart" in window) {
  172. event.preventDefault();
  173. if (this.dblClickSplitter) {
  174. if (this.splitterTaps.splitter === splitterIndex) {
  175. clearTimeout(this.splitterTaps.timeoutId);
  176. this.splitterTaps.timeoutId = null;
  177. this.onSplitterDblClick(event, splitterIndex);
  178. this.splitterTaps.splitter = null;
  179. } else {
  180. this.splitterTaps.splitter = splitterIndex;
  181. this.splitterTaps.timeoutId = setTimeout(() => {
  182. this.splitterTaps.splitter = null;
  183. }, 500);
  184. }
  185. }
  186. }
  187. if (!this.touch.dragging)
  188. this.$emit("splitter-click", this.panes[splitterIndex]);
  189. },
  190. onSplitterDblClick(event, splitterIndex) {
  191. let totalMinSizes = 0;
  192. this.panes = this.panes.map((pane2, i) => {
  193. pane2.size = i === splitterIndex ? pane2.max : pane2.min;
  194. if (i !== splitterIndex)
  195. totalMinSizes += pane2.min;
  196. return pane2;
  197. });
  198. this.panes[splitterIndex].size -= totalMinSizes;
  199. this.$emit("pane-maximize", this.panes[splitterIndex]);
  200. },
  201. onPaneClick(event, paneId) {
  202. this.$emit("pane-click", this.indexedPanes[paneId]);
  203. },
  204. getCurrentMouseDrag(event) {
  205. const rect = this.container.getBoundingClientRect();
  206. const { clientX, clientY } = "ontouchstart" in window && event.touches ? event.touches[0] : event;
  207. return {
  208. x: clientX - rect.left,
  209. y: clientY - rect.top
  210. };
  211. },
  212. getCurrentDragPercentage(drag) {
  213. drag = drag[this.horizontal ? "y" : "x"];
  214. const containerSize = this.container[this.horizontal ? "clientHeight" : "clientWidth"];
  215. if (this.rtl && !this.horizontal)
  216. drag = containerSize - drag;
  217. return drag * 100 / containerSize;
  218. },
  219. calculatePanesSize(drag) {
  220. const splitterIndex = this.touch.activeSplitter;
  221. let sums = {
  222. prevPanesSize: this.sumPrevPanesSize(splitterIndex),
  223. nextPanesSize: this.sumNextPanesSize(splitterIndex),
  224. prevReachedMinPanes: 0,
  225. nextReachedMinPanes: 0
  226. };
  227. const minDrag = 0 + (this.pushOtherPanes ? 0 : sums.prevPanesSize);
  228. const maxDrag = 100 - (this.pushOtherPanes ? 0 : sums.nextPanesSize);
  229. const dragPercentage = Math.max(Math.min(this.getCurrentDragPercentage(drag), maxDrag), minDrag);
  230. let panesToResize = [splitterIndex, splitterIndex + 1];
  231. let paneBefore = this.panes[panesToResize[0]] || null;
  232. let paneAfter = this.panes[panesToResize[1]] || null;
  233. const paneBeforeMaxReached = paneBefore.max < 100 && dragPercentage >= paneBefore.max + sums.prevPanesSize;
  234. const paneAfterMaxReached = paneAfter.max < 100 && dragPercentage <= 100 - (paneAfter.max + this.sumNextPanesSize(splitterIndex + 1));
  235. if (paneBeforeMaxReached || paneAfterMaxReached) {
  236. if (paneBeforeMaxReached) {
  237. paneBefore.size = paneBefore.max;
  238. paneAfter.size = Math.max(100 - paneBefore.max - sums.prevPanesSize - sums.nextPanesSize, 0);
  239. } else {
  240. paneBefore.size = Math.max(100 - paneAfter.max - sums.prevPanesSize - this.sumNextPanesSize(splitterIndex + 1), 0);
  241. paneAfter.size = paneAfter.max;
  242. }
  243. return;
  244. }
  245. if (this.pushOtherPanes) {
  246. const vars = this.doPushOtherPanes(sums, dragPercentage);
  247. if (!vars)
  248. return;
  249. ({ sums, panesToResize } = vars);
  250. paneBefore = this.panes[panesToResize[0]] || null;
  251. paneAfter = this.panes[panesToResize[1]] || null;
  252. }
  253. if (paneBefore !== null) {
  254. paneBefore.size = Math.min(Math.max(dragPercentage - sums.prevPanesSize - sums.prevReachedMinPanes, paneBefore.min), paneBefore.max);
  255. }
  256. if (paneAfter !== null) {
  257. paneAfter.size = Math.min(Math.max(100 - dragPercentage - sums.nextPanesSize - sums.nextReachedMinPanes, paneAfter.min), paneAfter.max);
  258. }
  259. },
  260. doPushOtherPanes(sums, dragPercentage) {
  261. const splitterIndex = this.touch.activeSplitter;
  262. const panesToResize = [splitterIndex, splitterIndex + 1];
  263. if (dragPercentage < sums.prevPanesSize + this.panes[panesToResize[0]].min) {
  264. panesToResize[0] = this.findPrevExpandedPane(splitterIndex).index;
  265. sums.prevReachedMinPanes = 0;
  266. if (panesToResize[0] < splitterIndex) {
  267. this.panes.forEach((pane2, i) => {
  268. if (i > panesToResize[0] && i <= splitterIndex) {
  269. pane2.size = pane2.min;
  270. sums.prevReachedMinPanes += pane2.min;
  271. }
  272. });
  273. }
  274. sums.prevPanesSize = this.sumPrevPanesSize(panesToResize[0]);
  275. if (panesToResize[0] === void 0) {
  276. sums.prevReachedMinPanes = 0;
  277. this.panes[0].size = this.panes[0].min;
  278. this.panes.forEach((pane2, i) => {
  279. if (i > 0 && i <= splitterIndex) {
  280. pane2.size = pane2.min;
  281. sums.prevReachedMinPanes += pane2.min;
  282. }
  283. });
  284. this.panes[panesToResize[1]].size = 100 - sums.prevReachedMinPanes - this.panes[0].min - sums.prevPanesSize - sums.nextPanesSize;
  285. return null;
  286. }
  287. }
  288. if (dragPercentage > 100 - sums.nextPanesSize - this.panes[panesToResize[1]].min) {
  289. panesToResize[1] = this.findNextExpandedPane(splitterIndex).index;
  290. sums.nextReachedMinPanes = 0;
  291. if (panesToResize[1] > splitterIndex + 1) {
  292. this.panes.forEach((pane2, i) => {
  293. if (i > splitterIndex && i < panesToResize[1]) {
  294. pane2.size = pane2.min;
  295. sums.nextReachedMinPanes += pane2.min;
  296. }
  297. });
  298. }
  299. sums.nextPanesSize = this.sumNextPanesSize(panesToResize[1] - 1);
  300. if (panesToResize[1] === void 0) {
  301. sums.nextReachedMinPanes = 0;
  302. this.panes[this.panesCount - 1].size = this.panes[this.panesCount - 1].min;
  303. this.panes.forEach((pane2, i) => {
  304. if (i < this.panesCount - 1 && i >= splitterIndex + 1) {
  305. pane2.size = pane2.min;
  306. sums.nextReachedMinPanes += pane2.min;
  307. }
  308. });
  309. this.panes[panesToResize[0]].size = 100 - sums.prevPanesSize - sums.nextReachedMinPanes - this.panes[this.panesCount - 1].min - sums.nextPanesSize;
  310. return null;
  311. }
  312. }
  313. return { sums, panesToResize };
  314. },
  315. sumPrevPanesSize(splitterIndex) {
  316. return this.panes.reduce((total, pane2, i) => total + (i < splitterIndex ? pane2.size : 0), 0);
  317. },
  318. sumNextPanesSize(splitterIndex) {
  319. return this.panes.reduce((total, pane2, i) => total + (i > splitterIndex + 1 ? pane2.size : 0), 0);
  320. },
  321. findPrevExpandedPane(splitterIndex) {
  322. const pane2 = [...this.panes].reverse().find((p) => p.index < splitterIndex && p.size > p.min);
  323. return pane2 || {};
  324. },
  325. findNextExpandedPane(splitterIndex) {
  326. const pane2 = this.panes.find((p) => p.index > splitterIndex + 1 && p.size > p.min);
  327. return pane2 || {};
  328. },
  329. checkSplitpanesNodes() {
  330. const children = Array.from(this.container.children);
  331. children.forEach((child) => {
  332. const isPane = child.classList.contains("splitpanes__pane");
  333. const isSplitter = child.classList.contains("splitpanes__splitter");
  334. if (!isPane && !isSplitter) {
  335. child.parentNode.removeChild(child);
  336. console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed.");
  337. return;
  338. }
  339. });
  340. },
  341. addSplitter(paneIndex, nextPaneNode, isVeryFirst = false) {
  342. const splitterIndex = paneIndex - 1;
  343. const elm = document.createElement("div");
  344. elm.classList.add("splitpanes__splitter");
  345. if (!isVeryFirst) {
  346. elm.onmousedown = (event) => this.onMouseDown(event, splitterIndex);
  347. if (typeof window !== "undefined" && "ontouchstart" in window) {
  348. elm.ontouchstart = (event) => this.onMouseDown(event, splitterIndex);
  349. }
  350. elm.onclick = (event) => this.onSplitterClick(event, splitterIndex + 1);
  351. }
  352. if (this.dblClickSplitter) {
  353. elm.ondblclick = (event) => this.onSplitterDblClick(event, splitterIndex + 1);
  354. }
  355. nextPaneNode.parentNode.insertBefore(elm, nextPaneNode);
  356. },
  357. removeSplitter(node) {
  358. node.onmousedown = void 0;
  359. node.onclick = void 0;
  360. node.ondblclick = void 0;
  361. node.parentNode.removeChild(node);
  362. },
  363. redoSplitters() {
  364. const children = Array.from(this.container.children);
  365. children.forEach((el) => {
  366. if (el.className.includes("splitpanes__splitter"))
  367. this.removeSplitter(el);
  368. });
  369. let paneIndex = 0;
  370. children.forEach((el) => {
  371. if (el.className.includes("splitpanes__pane")) {
  372. if (!paneIndex && this.firstSplitter)
  373. this.addSplitter(paneIndex, el, true);
  374. else if (paneIndex)
  375. this.addSplitter(paneIndex, el);
  376. paneIndex++;
  377. }
  378. });
  379. },
  380. requestUpdate(_a) {
  381. var _b = _a, { target } = _b, args = __objRest(_b, ["target"]);
  382. const pane2 = this.indexedPanes[target._uid];
  383. Object.entries(args).forEach(([key, value]) => pane2[key] = value);
  384. },
  385. onPaneAdd(pane2) {
  386. let index = -1;
  387. Array.from(pane2.$el.parentNode.children).some((el) => {
  388. if (el.className.includes("splitpanes__pane"))
  389. index++;
  390. return el === pane2.$el;
  391. });
  392. const min = parseFloat(pane2.minSize);
  393. const max = parseFloat(pane2.maxSize);
  394. this.panes.splice(index, 0, {
  395. id: pane2._uid,
  396. index,
  397. min: isNaN(min) ? 0 : min,
  398. max: isNaN(max) ? 100 : max,
  399. size: pane2.size === null ? null : parseFloat(pane2.size),
  400. givenSize: pane2.size,
  401. update: pane2.update
  402. });
  403. this.panes.forEach((p, i) => p.index = i);
  404. if (this.ready) {
  405. this.$nextTick(() => {
  406. this.redoSplitters();
  407. this.resetPaneSizes({ addedPane: this.panes[index] });
  408. this.$emit("pane-add", { index, panes: this.panes.map((pane3) => ({ min: pane3.min, max: pane3.max, size: pane3.size })) });
  409. });
  410. }
  411. },
  412. onPaneRemove(pane2) {
  413. const index = this.panes.findIndex((p) => p.id === pane2._uid);
  414. const removed = this.panes.splice(index, 1)[0];
  415. this.panes.forEach((p, i) => p.index = i);
  416. this.$nextTick(() => {
  417. this.redoSplitters();
  418. this.resetPaneSizes({ removedPane: __spreadProps(__spreadValues({}, removed), { index }) });
  419. this.$emit("pane-remove", { removed, panes: this.panes.map((pane3) => ({ min: pane3.min, max: pane3.max, size: pane3.size })) });
  420. });
  421. },
  422. resetPaneSizes(changedPanes = {}) {
  423. if (!changedPanes.addedPane && !changedPanes.removedPane)
  424. this.initialPanesSizing();
  425. else if (this.panes.some((pane2) => pane2.givenSize !== null || pane2.min || pane2.max < 100))
  426. this.equalizeAfterAddOrRemove(changedPanes);
  427. else
  428. this.equalize();
  429. if (this.ready)
  430. this.$emit("resized", this.panes.map((pane2) => ({ min: pane2.min, max: pane2.max, size: pane2.size })));
  431. },
  432. equalize() {
  433. const equalSpace = 100 / this.panesCount;
  434. let leftToAllocate = 0;
  435. let ungrowable = [];
  436. let unshrinkable = [];
  437. this.panes.forEach((pane2) => {
  438. pane2.size = Math.max(Math.min(equalSpace, pane2.max), pane2.min);
  439. leftToAllocate -= pane2.size;
  440. if (pane2.size >= pane2.max)
  441. ungrowable.push(pane2.id);
  442. if (pane2.size <= pane2.min)
  443. unshrinkable.push(pane2.id);
  444. });
  445. if (leftToAllocate > 0.1)
  446. this.readjustSizes(leftToAllocate, ungrowable, unshrinkable);
  447. },
  448. initialPanesSizing() {
  449. 100 / this.panesCount;
  450. let leftToAllocate = 100;
  451. let ungrowable = [];
  452. let unshrinkable = [];
  453. let definedSizes = 0;
  454. this.panes.forEach((pane2) => {
  455. leftToAllocate -= pane2.size;
  456. if (pane2.size !== null)
  457. definedSizes++;
  458. if (pane2.size >= pane2.max)
  459. ungrowable.push(pane2.id);
  460. if (pane2.size <= pane2.min)
  461. unshrinkable.push(pane2.id);
  462. });
  463. let leftToAllocate2 = 100;
  464. if (leftToAllocate > 0.1) {
  465. this.panes.forEach((pane2) => {
  466. if (pane2.size === null) {
  467. pane2.size = Math.max(Math.min(leftToAllocate / (this.panesCount - definedSizes), pane2.max), pane2.min);
  468. }
  469. leftToAllocate2 -= pane2.size;
  470. });
  471. if (leftToAllocate2 > 0.1)
  472. this.readjustSizes(leftToAllocate, ungrowable, unshrinkable);
  473. }
  474. },
  475. equalizeAfterAddOrRemove({ addedPane, removedPane } = {}) {
  476. let equalSpace = 100 / this.panesCount;
  477. let leftToAllocate = 0;
  478. let ungrowable = [];
  479. let unshrinkable = [];
  480. if (addedPane && addedPane.givenSize !== null) {
  481. equalSpace = (100 - addedPane.givenSize) / (this.panesCount - 1);
  482. }
  483. this.panes.forEach((pane2) => {
  484. leftToAllocate -= pane2.size;
  485. if (pane2.size >= pane2.max)
  486. ungrowable.push(pane2.id);
  487. if (pane2.size <= pane2.min)
  488. unshrinkable.push(pane2.id);
  489. });
  490. if (Math.abs(leftToAllocate) < 0.1)
  491. return;
  492. this.panes.forEach((pane2) => {
  493. if (addedPane && addedPane.givenSize !== null && addedPane.id === pane2.id)
  494. ;
  495. else
  496. pane2.size = Math.max(Math.min(equalSpace, pane2.max), pane2.min);
  497. leftToAllocate -= pane2.size;
  498. if (pane2.size >= pane2.max)
  499. ungrowable.push(pane2.id);
  500. if (pane2.size <= pane2.min)
  501. unshrinkable.push(pane2.id);
  502. });
  503. if (leftToAllocate > 0.1)
  504. this.readjustSizes(leftToAllocate, ungrowable, unshrinkable);
  505. },
  506. readjustSizes(leftToAllocate, ungrowable, unshrinkable) {
  507. let equalSpaceToAllocate;
  508. if (leftToAllocate > 0)
  509. equalSpaceToAllocate = leftToAllocate / (this.panesCount - ungrowable.length);
  510. else
  511. equalSpaceToAllocate = leftToAllocate / (this.panesCount - unshrinkable.length);
  512. this.panes.forEach((pane2, i) => {
  513. if (leftToAllocate > 0 && !ungrowable.includes(pane2.id)) {
  514. const newPaneSize = Math.max(Math.min(pane2.size + equalSpaceToAllocate, pane2.max), pane2.min);
  515. const allocated = newPaneSize - pane2.size;
  516. leftToAllocate -= allocated;
  517. pane2.size = newPaneSize;
  518. } else if (!unshrinkable.includes(pane2.id)) {
  519. const newPaneSize = Math.max(Math.min(pane2.size + equalSpaceToAllocate, pane2.max), pane2.min);
  520. const allocated = newPaneSize - pane2.size;
  521. leftToAllocate -= allocated;
  522. pane2.size = newPaneSize;
  523. }
  524. pane2.update({
  525. [this.horizontal ? "height" : "width"]: `${this.indexedPanes[pane2.id].size}%`
  526. });
  527. });
  528. if (Math.abs(leftToAllocate) > 0.1) {
  529. this.$nextTick(() => {
  530. if (this.ready) {
  531. console.warn("Splitpanes: Could not resize panes correctly due to their constraints.");
  532. }
  533. });
  534. }
  535. }
  536. },
  537. watch: {
  538. panes: {
  539. deep: true,
  540. immediate: false,
  541. handler() {
  542. this.updatePaneComponents();
  543. }
  544. },
  545. horizontal() {
  546. this.updatePaneComponents();
  547. },
  548. firstSplitter() {
  549. this.redoSplitters();
  550. },
  551. dblClickSplitter(enable) {
  552. const splitters = [...this.container.querySelectorAll(".splitpanes__splitter")];
  553. splitters.forEach((splitter, i) => {
  554. splitter.ondblclick = enable ? (event) => this.onSplitterDblClick(event, i) : void 0;
  555. });
  556. }
  557. },
  558. beforeDestroy() {
  559. this.ready = false;
  560. },
  561. mounted() {
  562. this.container = this.$refs.container;
  563. this.checkSplitpanesNodes();
  564. this.redoSplitters();
  565. this.resetPaneSizes();
  566. this.$emit("ready");
  567. this.ready = true;
  568. },
  569. render(h) {
  570. return h("div", {
  571. ref: "container",
  572. class: [
  573. "splitpanes",
  574. `splitpanes--${this.horizontal ? "horizontal" : "vertical"}`,
  575. {
  576. "splitpanes--dragging": this.touch.dragging
  577. }
  578. ]
  579. }, this.$slots.default);
  580. }
  581. };
  582. let __vue2_render, __vue2_staticRenderFns;
  583. const __cssModules$1 = {};
  584. var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles$1, null, null, null);
  585. function __vue2_injectStyles$1(context) {
  586. for (let o in __cssModules$1) {
  587. this[o] = __cssModules$1[o];
  588. }
  589. }
  590. var splitpanes = /* @__PURE__ */ function() {
  591. return __component__$1.exports;
  592. }();
  593. var render = function() {
  594. var _vm = this;
  595. var _h = _vm.$createElement;
  596. var _c = _vm._self._c || _h;
  597. return _c("div", { staticClass: "splitpanes__pane", style: _vm.style, on: { "click": function($event) {
  598. return _vm.onPaneClick($event, _vm._uid);
  599. } } }, [_vm._t("default")], 2);
  600. };
  601. var staticRenderFns = [];
  602. const __vue2_script = {
  603. name: "pane",
  604. inject: ["requestUpdate", "onPaneAdd", "onPaneRemove", "onPaneClick"],
  605. props: {
  606. size: { type: [Number, String], default: null },
  607. minSize: { type: [Number, String], default: 0 },
  608. maxSize: { type: [Number, String], default: 100 }
  609. },
  610. data: () => ({
  611. style: {}
  612. }),
  613. mounted() {
  614. this.onPaneAdd(this);
  615. },
  616. beforeDestroy() {
  617. this.onPaneRemove(this);
  618. },
  619. methods: {
  620. update(style) {
  621. this.style = style;
  622. }
  623. },
  624. computed: {
  625. sizeNumber() {
  626. return this.size || this.size === 0 ? parseFloat(this.size) : null;
  627. },
  628. minSizeNumber() {
  629. return parseFloat(this.minSize);
  630. },
  631. maxSizeNumber() {
  632. return parseFloat(this.maxSize);
  633. }
  634. },
  635. watch: {
  636. sizeNumber(size) {
  637. this.requestUpdate({ target: this, size });
  638. },
  639. minSizeNumber(min) {
  640. this.requestUpdate({ target: this, min });
  641. },
  642. maxSizeNumber(max) {
  643. this.requestUpdate({ target: this, max });
  644. }
  645. }
  646. };
  647. const __cssModules = {};
  648. var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
  649. function __vue2_injectStyles(context) {
  650. for (let o in __cssModules) {
  651. this[o] = __cssModules[o];
  652. }
  653. }
  654. var pane = /* @__PURE__ */ function() {
  655. return __component__.exports;
  656. }();
  657. export { pane as Pane, splitpanes as Splitpanes };