UNPKG

vxe-table-demonic

Version:

一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...

1 lines 5.02 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _vue=require("vue"),_xeUtils=_interopRequireDefault(require("xe-utils")),_conf=_interopRequireDefault(require("../../v-x-e-table/src/conf")),_size=require("../../hooks/size"),_dom=require("../../tools/dom"),_utils=require("../../tools/utils"),_event=require("../../tools/event");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default=(0,_vue.defineComponent)({name:"VxePulldown",props:{modelValue:Boolean,disabled:Boolean,placement:String,size:{type:String,default:function(){return _conf.default.size}},className:[String,Function],popupClassName:[String,Function],destroyOnClose:Boolean,transfer:Boolean},emits:["update:modelValue","hide-panel"],setup:function(m,e){function t(){return h.inited||(h.inited=!0),new Promise(function(e){m.disabled?(0,_vue.nextTick)(function(){e()}):(clearTimeout(a),h.isActivated=!0,h.animatVisible=!0,setTimeout(function(){h.visiblePanel=!0,u("update:modelValue",!0),v(),setTimeout(function(){e(v())},40)},10),d())})}function o(){return h.visiblePanel=!1,(h.isActivated=!1,_dom.blurRecursive)(w.value),u("update:modelValue",!1),new Promise(function(e){h.animatVisible?a=window.setTimeout(function(){(h.animatVisible=!1,_vue.nextTick)(function(){e()})},350):(0,_vue.nextTick)(function(){e()})})}function n(e){var t=m.disabled,n=h.visiblePanel,i=P.value;t||n&&((0,_dom.getEventTargetNode)(e,i).flag?v():!(0,_dom.isInside)(e.target,P.value)&&Array.from(e.target.classList).every(function(t){return _dom.ignoreWheelList.every(function(e){return!t.startsWith(e)})})&&(o(),c.dispatchEvent("hide-panel",{},e)))}function i(e){var t=m.disabled,n=h.visiblePanel,i=g.value,l=P.value;t||(h.isActivated=(0,_dom.getEventTargetNode)(e,i).flag||(0,_dom.getEventTargetNode)(e,l).flag,n&&!h.isActivated&&(o(),c.dispatchEvent("hide-panel",{},e)))}function l(e){h.visiblePanel&&(h.isActivated=!1,o(),c.dispatchEvent("hide-panel",{},e))}var a,b=e.slots,u=e.emit,s=_xeUtils.default.uniqueId(),x=(0,_size.useSize)(m),h=(0,_vue.reactive)({inited:!1,panelIndex:0,panelStyle:null,panelPlacement:null,visiblePanel:!1,animatVisible:!1,isActivated:!1}),g=(0,_vue.ref)(),w=(0,_vue.ref)(),P=(0,_vue.ref)(),r={refElem:g},V={xID:s,props:m,context:e,reactData:h,getRefMaps:function(){return r}},d=function(){h.panelIndex<(0,_utils.getLastZIndex)()&&(h.panelIndex=(0,_utils.nextZIndex)())},v=function(){return(0,_vue.nextTick)().then(function(){var e,t,n,i,l,o,a,u,s,r=m.transfer,d=m.placement,v=h.panelIndex;return h.visiblePanel&&(a=w.value,i=P.value)&&a&&(e=a.offsetHeight,t=a.offsetWidth,n=i.offsetHeight,i=i.offsetWidth,v={zIndex:v},l=(a=(0,_dom.getAbsolutePos)(a)).boundingTop,s=a.boundingLeft,o=a.visibleHeight,a=a.visibleWidth,u="bottom",r?(r=l+e,"top"===d?(u="top",r=l-n):d||(o<r+n+5&&(u="top",r=l-n),r<5&&(u="bottom",r=l+e)),a<(s=s)+i+5&&(s-=s+i+5-a),s<5&&(s=5),Object.assign(v,{left:"".concat(s,"px"),top:"".concat(r,"px"),minWidth:"".concat(t,"px")})):"top"===d?(u="top",v.bottom="".concat(e,"px")):d||o<l+e+n&&5<l-e-n&&(u="top",v.bottom="".concat(e,"px")),h.panelStyle=v,h.panelPlacement=u),(0,_vue.nextTick)()})},c={dispatchEvent:function(e,t,n){u(e,Object.assign({$pulldown:V,$event:n},t))},isPanelVisible:function(){return h.visiblePanel},togglePanel:function(){return(h.visiblePanel?o:t)()},showPanel:t,hidePanel:o};Object.assign(V,c),(0,_vue.watch)(function(){return m.modelValue},function(e){(e?t:o)()}),(0,_vue.nextTick)(function(){_event.GlobalEvent.on(V,"mousewheel",n),_event.GlobalEvent.on(V,"mousedown",i),_event.GlobalEvent.on(V,"blur",l)}),(0,_vue.onUnmounted)(function(){_event.GlobalEvent.off(V,"mousewheel"),_event.GlobalEvent.off(V,"mousedown"),_event.GlobalEvent.off(V,"blur")});return V.renderVN=function(){var e=m.className,t=m.popupClassName,n=m.destroyOnClose,i=m.transfer,l=m.disabled,o=h.inited,a=h.isActivated,u=h.animatVisible,s=h.visiblePanel,r=h.panelStyle,d=h.panelPlacement,v=x.value,c=b.default,f=b.header,p=b.footer,_=b.dropdown;return(0,_vue.h)("div",{ref:g,class:["vxe-pulldown",e?_xeUtils.default.isFunction(e)?e({$pulldown:V}):e:"",((e={})["size--".concat(v)]=v,e["is--visible"]=s,e["is--disabled"]=l,e["is--active"]=a,e)]},[(0,_vue.h)("div",{ref:w,class:"vxe-pulldown--content"},c?c({$pulldown:V}):[]),(0,_vue.h)(_vue.Teleport,{to:"body",disabled:!i||!o},[(0,_vue.h)("div",{ref:P,class:["vxe-table--ignore-clear vxe-pulldown--panel",t?_xeUtils.default.isFunction(t)?t({$pulldown:V}):t:"",((l={})["size--".concat(v)]=v,l["is--transfer"]=i,l["animat--leave"]=u,l["animat--enter"]=s,l)],placement:d,style:r},_?[(0,_vue.h)("div",{class:"vxe-pulldown--panel-wrapper"},!o||n&&!s&&!u?[]:[f?(0,_vue.h)("div",{class:"vxe-pulldown--panel-header"},f({$pulldown:V})):(0,_vue.createCommentVNode)(),(0,_vue.h)("div",{class:"vxe-pulldown--panel-body"},_({$pulldown:V})),p?(0,_vue.h)("div",{class:"vxe-pulldown--panel-footer"},p({$pulldown:V})):(0,_vue.createCommentVNode)()])]:[])])])},V},render:function(){return this.renderVN()}});exports.default=_default;