UNPKG

winbox-ui-next

Version:

We Design Vue 2.0: A Vue.js 3 UI Library

98 lines (97 loc) 3.04 kB
"use strict"; var vue = require("vue"); var globalConfig = require("../../_utils/global-config.js"); var index = require("../../empty/index.js"); var index$1 = require("../../spin/index.js"); var pluginVue_exportHelper = require("../../_virtual/plugin-vue_export-helper"); const _sfc_main = vue.defineComponent({ name: "DropdownPanel", components: { Empty: index, Spin: index$1 }, props: { loading: { type: Boolean, default: false }, isEmpty: { type: Boolean, default: false }, bottomOffset: { type: Number, default: 0 }, onScroll: { type: [Function, Array] }, onReachBottom: { type: [Function, Array] } }, emits: ["scroll", "reachBottom"], setup(props, { emit, slots }) { const prefixCls = globalConfig.getPrefixCls("dropdown"); const wrapperRef = vue.ref(); const handleScroll = (e) => { const { scrollTop, scrollHeight, offsetHeight } = e.target; const bottom = scrollHeight - (scrollTop + offsetHeight); if (bottom <= props.bottomOffset) { emit("reachBottom", e); } emit("scroll", e); }; const cls = vue.computed(() => [ prefixCls, { [`${prefixCls}-has-footer`]: Boolean(slots.footer) } ]); return { prefixCls, cls, wrapperRef, handleScroll }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_spin = vue.resolveComponent("spin"); const _component_empty = vue.resolveComponent("empty"); return vue.openBlock(), vue.createElementBlock("div", { class: vue.normalizeClass(_ctx.cls) }, [ _ctx.loading ? (vue.openBlock(), vue.createBlock(_component_spin, { key: 0, class: vue.normalizeClass(`${_ctx.prefixCls}-loading`) }, null, 8, ["class"])) : _ctx.isEmpty ? (vue.openBlock(), vue.createElementBlock("div", { key: 1, class: vue.normalizeClass(`${_ctx.prefixCls}-empty`) }, [ vue.renderSlot(_ctx.$slots, "empty", {}, () => [ vue.createVNode(_component_empty) ]) ], 2)) : vue.renderSlot(_ctx.$slots, "virtual-list", { key: 2 }, () => [ vue.createElementVNode("div", { ref: "wrapperRef", class: vue.normalizeClass(`${_ctx.prefixCls}-list-wrapper`), onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.handleScroll && _ctx.handleScroll(...args)) }, [ vue.createElementVNode("ul", { class: vue.normalizeClass(`${_ctx.prefixCls}-list`) }, [ vue.renderSlot(_ctx.$slots, "default") ], 2) ], 34) ]), _ctx.$slots.footer && !_ctx.isEmpty ? (vue.openBlock(), vue.createElementBlock("div", { key: 3, class: vue.normalizeClass(`${_ctx.prefixCls}-footer`) }, [ vue.renderSlot(_ctx.$slots, "footer") ], 2)) : vue.createCommentVNode("v-if", true) ], 2); } var DropdownPanel = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]); module.exports = DropdownPanel;