UNPKG

vxe-pc-ui

Version:
121 lines (120 loc) 3.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _vue = require("vue"); var _ui = require("../../ui"); var _util = require("./util"); var _xeUtils = _interopRequireDefault(require("xe-utils")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _default = exports.default = (0, _vue.defineComponent)({ name: 'VxeSplitPane', props: { name: [Number, String], width: [Number, String], height: [Number, String], showAction: Boolean, minWidth: { type: [Number, String], default: () => null }, minHeight: { type: [Number, String], default: () => null } }, emits: [], setup(props, context) { const { emit, slots } = context; const xID = _xeUtils.default.uniqueId(); const $xeSplit = (0, _vue.inject)('$xeSplit', null); const refElem = (0, _vue.ref)(); const paneConfig = (0, _vue.reactive)({ id: xID, name: props.name, width: props.width, height: props.height, minWidth: props.minWidth, minHeight: props.minHeight, showAction: props.showAction, isVisible: true, isExpand: true, renderWidth: 0, resizeWidth: 0, foldWidth: 0, renderHeight: 0, resizeHeight: 0, foldHeight: 0, slots: slots }); const reactData = (0, _vue.reactive)({}); const internalData = {}; const computeMaps = {}; const refMaps = { refElem }; const $xeSplitItem = { xID, props, context, reactData, internalData, getRefMaps: () => refMaps, getComputeMaps: () => computeMaps }; const dispatchEvent = (type, params, evnt) => { emit(type, (0, _ui.createEvent)(evnt, { $splitPane: $xeSplitItem }, params)); }; const splitPaneMethods = { dispatchEvent }; const splitPanePrivateMethods = {}; Object.assign($xeSplitItem, splitPaneMethods, splitPanePrivateMethods); const renderVN = () => { return (0, _vue.h)('div', { ref: refElem }); }; (0, _vue.watch)(() => props.name, val => { paneConfig.name = val; }); (0, _vue.watch)(() => props.width, val => { paneConfig.width = val; }); (0, _vue.watch)(() => props.height, val => { paneConfig.height = val; }); (0, _vue.watch)(() => props.minWidth, val => { paneConfig.minWidth = val; }); (0, _vue.watch)(() => props.minHeight, val => { paneConfig.minHeight = val; }); (0, _vue.watch)(() => props.showAction, val => { paneConfig.showAction = val; }); (0, _vue.onMounted)(() => { const elem = refElem.value; if ($xeSplit && elem) { (0, _util.assembleSplitItem)($xeSplit, elem, paneConfig); } }); (0, _vue.onUnmounted)(() => { if ($xeSplit) { (0, _util.destroySplitItem)($xeSplit, paneConfig); } }); (0, _vue.provide)('$xeSplitItem', $xeSplitItem); $xeSplitItem.renderVN = renderVN; return $xeSplitItem; }, render() { return this.renderVN(); } });