1cd5d9e335999c59ab4db2c59d7318788fd01c6f8d6d81a6051e3679b1fe2310e9acf668b6f76e03f003e781b6b642280dcfe7325e6a3946c23a042fb30e36 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { defineComponent, toRef, getCurrentInstance, watch, computed, provide, reactive, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, renderSlot, createVNode, createCommentVNode, nextTick } from 'vue';
  2. import { splitterProps } from './splitter.mjs';
  3. import { splitterRootContextKey } from './type.mjs';
  4. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  5. import { useContainer } from './hooks/useContainer.mjs';
  6. import { useSize } from './hooks/useSize.mjs';
  7. import { useResize } from './hooks/useResize.mjs';
  8. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  9. import { useOrderedChildren } from '../../../hooks/use-ordered-children/index.mjs';
  10. const __default__ = defineComponent({
  11. name: "ElSplitter"
  12. });
  13. const _sfc_main = /* @__PURE__ */ defineComponent({
  14. ...__default__,
  15. props: splitterProps,
  16. emits: ["resizeStart", "resize", "resizeEnd", "collapse"],
  17. setup(__props, { emit: emits }) {
  18. const props = __props;
  19. const ns = useNamespace("splitter");
  20. const layout = toRef(props, "layout");
  21. const lazy = toRef(props, "lazy");
  22. const { containerEl, containerSize } = useContainer(layout);
  23. const {
  24. removeChild: unregisterPanel,
  25. children: panels,
  26. addChild: registerPanel,
  27. ChildrenSorter: PanelsSorter
  28. } = useOrderedChildren(getCurrentInstance(), "ElSplitterPanel");
  29. watch(panels, () => {
  30. panels.value.forEach((instance, index) => {
  31. instance.setIndex(index);
  32. });
  33. });
  34. const { percentSizes, pxSizes } = useSize(panels, containerSize);
  35. const {
  36. lazyOffset,
  37. movingIndex,
  38. onMoveStart,
  39. onMoving,
  40. onMoveEnd,
  41. onCollapse
  42. } = useResize(panels, containerSize, pxSizes, lazy);
  43. const splitterStyles = computed(() => {
  44. return {
  45. [`--${ns.b()}-bar-offset`]: lazy.value ? `${lazyOffset.value}px` : void 0
  46. };
  47. });
  48. const onResizeStart = (index) => {
  49. onMoveStart(index);
  50. emits("resizeStart", index, pxSizes.value);
  51. };
  52. const onResize = (index, offset) => {
  53. onMoving(index, offset);
  54. if (!lazy.value) {
  55. emits("resize", index, pxSizes.value);
  56. }
  57. };
  58. const onResizeEnd = async (index) => {
  59. onMoveEnd();
  60. await nextTick();
  61. emits("resizeEnd", index, pxSizes.value);
  62. };
  63. const onCollapsible = (index, type) => {
  64. onCollapse(index, type);
  65. emits("collapse", index, type, pxSizes.value);
  66. };
  67. provide(splitterRootContextKey, reactive({
  68. panels,
  69. percentSizes,
  70. pxSizes,
  71. layout,
  72. lazy,
  73. movingIndex,
  74. containerSize,
  75. onMoveStart: onResizeStart,
  76. onMoving: onResize,
  77. onMoveEnd: onResizeEnd,
  78. onCollapse: onCollapsible,
  79. registerPanel,
  80. unregisterPanel
  81. }));
  82. return (_ctx, _cache) => {
  83. return openBlock(), createElementBlock("div", {
  84. ref_key: "containerEl",
  85. ref: containerEl,
  86. class: normalizeClass([unref(ns).b(), unref(ns).e(unref(layout))]),
  87. style: normalizeStyle(unref(splitterStyles))
  88. }, [
  89. renderSlot(_ctx.$slots, "default"),
  90. createVNode(unref(PanelsSorter)),
  91. createCommentVNode(" Prevent iframe touch events from breaking "),
  92. unref(movingIndex) ? (openBlock(), createElementBlock("div", {
  93. key: 0,
  94. class: normalizeClass([unref(ns).e("mask"), unref(ns).e(`mask-${unref(layout)}`)])
  95. }, null, 2)) : createCommentVNode("v-if", true)
  96. ], 6);
  97. };
  98. }
  99. });
  100. var Splitter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "splitter.vue"]]);
  101. export { Splitter as default };
  102. //# sourceMappingURL=splitter2.mjs.map