UNPKG

yanzhen-design-vue

Version:

167 lines (166 loc) 6.32 kB
import { defineComponent, openBlock, createElementBlock, Fragment, createVNode, unref, withCtx, createBlock, normalizeClass, createCommentVNode, renderSlot, createElementVNode, normalizeStyle, renderList } from "vue"; import { Spin, Empty } from "ant-design-vue"; import { UseVirtualList } from "@vueuse/components"; import { listName, listProps, listEmits, listOptions } from "./list.mjs"; import { useList } from "./use-list.mjs"; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: listName }, __name: "list", props: listProps, emits: listEmits, setup(__props, { emit: __emit }) { const { ns } = listOptions; const props = __props; const emit = __emit; const { ctx: { mode, _ref, _itemRef, _boxRef, _headerRef, _mainRef, _footerRef, wrapClass, wrapStyle, styles, $slots, _dataSource, _loading, mainHeight, virtualOptions }, templates: { DefineEmptyTemplate, ReusableEmptyTemplate, DefineItemTemplate, ReusableItemTemplate } } = useList(props, emit); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ createVNode(unref(DefineEmptyTemplate), null, { default: withCtx(({ loading, empty }) => [ loading ? (openBlock(), createBlock(unref(Spin), { key: 0, class: normalizeClass([unref(ns).e("loading")]), indicator: "" }, null, 8, ["class"])) : empty ? (openBlock(), createBlock(unref(Empty), { key: 1, class: normalizeClass([unref(ns).e("empty")]), image: unref(Empty).PRESENTED_IMAGE_SIMPLE }, null, 8, ["class", "image"])) : createCommentVNode("", true), renderSlot(_ctx.$slots, "empty-wrapper") ]), _: 3 }), createVNode(unref(DefineItemTemplate), null, { default: withCtx(({ item, index, ...record }) => [ createElementVNode("div", { ref_key: "_itemRef", ref: _itemRef, class: normalizeClass([unref(ns).e("item"), record.class]) }, [ renderSlot(_ctx.$slots, "default", { item, index }), unref($slots).footer && index === unref(_dataSource).length - 1 ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "_footerRef", ref: _footerRef, class: normalizeClass([unref(ns).e("item"), unref(ns).e("footer")]), style: normalizeStyle(unref(styles).footer) }, [ renderSlot(_ctx.$slots, "footer") ], 6)) : createCommentVNode("", true) ], 2) ]), _: 3 }), createElementVNode("div", { ref_key: "_boxRef", ref: _boxRef, class: normalizeClass(unref(wrapClass)), style: normalizeStyle(unref(wrapStyle)) }, [ unref($slots).header ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "_headerRef", ref: _headerRef, class: normalizeClass([unref(ns).e("header")]), style: normalizeStyle(unref(styles).header) }, [ renderSlot(_ctx.$slots, "header", { props }) ], 6)) : createCommentVNode("", true), createElementVNode("div", { ref_key: "_mainRef", ref: _mainRef, class: normalizeClass([unref(ns).e("main")]) }, [ unref(_dataSource).length === 0 ? (openBlock(), createBlock(unref(ReusableEmptyTemplate), { key: 0, loading: unref(_loading), empty: true }, null, 8, ["loading"])) : createCommentVNode("", true), unref($slots).tree ? (openBlock(), createElementBlock("div", { key: 1, class: normalizeClass([unref(ns).e("scroll")]) }, [ renderSlot(_ctx.$slots, "tree", { dataSource: unref(_dataSource), height: unref(mainHeight), props }) ], 2)) : unref(mode) === "virtual" ? (openBlock(), createBlock(unref(UseVirtualList), { key: 2, ref_key: "_ref", ref: _ref, class: normalizeClass([unref(ns).e("scroll"), unref(ns).e("virtual")]), style: { height: "100%" }, options: unref(virtualOptions), list: unref(_dataSource) }, { default: withCtx(({ data: item, index }) => [ createVNode(unref(ReusableItemTemplate), { class: normalizeClass([unref(ns).e("virtual-item")]), item, index }, null, 8, ["class", "item", "index"]) ]), _: 1 }, 8, ["class", "options", "list"])) : (openBlock(), createElementBlock("div", { key: 3, ref_key: "_ref", ref: _ref, class: normalizeClass([unref(ns).e("scroll")]) }, [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(_dataSource), (item, index) => { return openBlock(), createBlock(unref(ReusableItemTemplate), { key: (item == null ? void 0 : item.value) ?? index, class: normalizeClass([unref(ns).e("default-item")]), item, index }, null, 8, ["class", "item", "index"]); }), 128)) ], 2)) ], 2), unref($slots).tree && unref($slots).footer ? (openBlock(), createElementBlock("div", { key: 1, ref_key: "_footerRef", ref: _footerRef, class: normalizeClass([unref(ns).e("footer")]), style: normalizeStyle(unref(styles).footer) }, [ renderSlot(_ctx.$slots, "footer", { props }) ], 6)) : createCommentVNode("", true) ], 6) ], 64); }; } }); export { _sfc_main as default };