UNPKG

winbox-ui-next

Version:

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

97 lines (96 loc) 3.03 kB
import { defineComponent, ref, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, renderSlot, createVNode, createElementVNode, createCommentVNode } from "vue"; import { getPrefixCls } from "../../_utils/global-config.js"; import Empty from "../../empty/index.js"; import Spin from "../../spin/index.js"; import _export_sfc from "../../_virtual/plugin-vue_export-helper"; const _sfc_main = defineComponent({ name: "DropdownPanel", components: { Empty, Spin }, 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 = getPrefixCls("dropdown"); const wrapperRef = 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 = 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 = resolveComponent("spin"); const _component_empty = resolveComponent("empty"); return openBlock(), createElementBlock("div", { class: normalizeClass(_ctx.cls) }, [ _ctx.loading ? (openBlock(), createBlock(_component_spin, { key: 0, class: normalizeClass(`${_ctx.prefixCls}-loading`) }, null, 8, ["class"])) : _ctx.isEmpty ? (openBlock(), createElementBlock("div", { key: 1, class: normalizeClass(`${_ctx.prefixCls}-empty`) }, [ renderSlot(_ctx.$slots, "empty", {}, () => [ createVNode(_component_empty) ]) ], 2)) : renderSlot(_ctx.$slots, "virtual-list", { key: 2 }, () => [ createElementVNode("div", { ref: "wrapperRef", class: normalizeClass(`${_ctx.prefixCls}-list-wrapper`), onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.handleScroll && _ctx.handleScroll(...args)) }, [ createElementVNode("ul", { class: normalizeClass(`${_ctx.prefixCls}-list`) }, [ renderSlot(_ctx.$slots, "default") ], 2) ], 34) ]), _ctx.$slots.footer && !_ctx.isEmpty ? (openBlock(), createElementBlock("div", { key: 3, class: normalizeClass(`${_ctx.prefixCls}-footer`) }, [ renderSlot(_ctx.$slots, "footer") ], 2)) : createCommentVNode("v-if", true) ], 2); } var DropdownPanel = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { DropdownPanel as default };