winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
104 lines (103 loc) • 3.58 kB
JavaScript
"use strict";
var vue = require("vue");
var globalConfig = require("../_utils/global-config.js");
var index$1 = require("../empty/index.js");
var index$2 = require("../spin/index.js");
var index = require("../scrollbar/index.js");
var useComponentRef = require("../_hooks/use-component-ref.js");
var pluginVue_exportHelper = require("../_virtual/plugin-vue_export-helper");
const _sfc_main = vue.defineComponent({
name: "SelectDropdown",
components: {
Scrollbar: index,
Empty: index$1,
Spin: index$2
},
props: {
loading: Boolean,
empty: Boolean,
virtualList: Boolean,
bottomOffset: {
type: Number,
default: 0
},
onScroll: {
type: [Function, Array]
},
onReachBottom: {
type: [Function, Array]
}
},
emits: ["scroll", "reachBottom"],
setup(props, { emit, slots }) {
const prefixCls = globalConfig.getPrefixCls("select-dropdown");
const { componentRef: wrapperComRef, elementRef: wrapperRef } = useComponentRef.useComponentRef("containerRef");
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,
wrapperComRef,
handleScroll
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_spin = vue.resolveComponent("spin");
const _component_empty = vue.resolveComponent("empty");
const _component_Scrollbar = vue.resolveComponent("Scrollbar");
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.empty ? (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: vue.normalizeClass(`${_ctx.prefixCls}-empty`)
}, [
vue.renderSlot(_ctx.$slots, "empty", {}, () => [
vue.createVNode(_component_empty)
])
], 2)) : vue.createCommentVNode("v-if", true),
_ctx.virtualList && !_ctx.loading && !_ctx.empty ? vue.renderSlot(_ctx.$slots, "virtual-list", { key: 2 }) : vue.createCommentVNode("v-if", true),
!_ctx.virtualList ? vue.withDirectives((vue.openBlock(), vue.createBlock(_component_Scrollbar, {
key: 3,
ref: "wrapperComRef",
class: vue.normalizeClass(`${_ctx.prefixCls}-list-wrapper`),
onScroll: _ctx.handleScroll
}, {
default: vue.withCtx(() => [
vue.createElementVNode("ul", {
class: vue.normalizeClass(`${_ctx.prefixCls}-list`)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2)
]),
_: 3
}, 8, ["class", "onScroll"])), [
[vue.vShow, !_ctx.loading && !_ctx.empty]
]) : vue.createCommentVNode("v-if", true),
_ctx.$slots.footer && !_ctx.empty ? (vue.openBlock(), vue.createElementBlock("div", {
key: 4,
class: vue.normalizeClass(`${_ctx.prefixCls}-footer`)
}, [
vue.renderSlot(_ctx.$slots, "footer")
], 2)) : vue.createCommentVNode("v-if", true)
], 2);
}
var SelectDropdown = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]);
module.exports = SelectDropdown;