yanzhen-design-vue
Version:
252 lines (251 loc) • 10.9 kB
JavaScript
import { defineComponent, openBlock, createElementBlock, Fragment, createVNode, unref, withCtx, createBlock, mergeProps, createSlots, resolveDynamicComponent, createCommentVNode, normalizeClass, normalizeStyle, withModifiers, createElementVNode, toDisplayString, isRef, renderList, createTextVNode, renderSlot, normalizeProps, guardReactiveProps } from "vue";
import { Tree, Radio } from "ant-design-vue";
import { LoadingOutlined, CaretDownOutlined } from "@ant-design/icons-vue";
import { YzList } from "../../../list/index.mjs";
import { Contacts } from "../constants/contacts.mjs";
import "../item/contacts-item.vue.mjs";
import "../item/contacts-selected-icon.vue.mjs";
import { useContactsList } from "./use-contacts-list.mjs";
import { contactsListName, contactsListProps, contactsListEmits, contactsListOptions } from "./contacts-list.mjs";
import _sfc_main$1 from "../item/contacts-item.vue2.mjs";
import _sfc_main$2 from "../item/contacts-selected-icon.vue2.mjs";
const _hoisted_1 = ["onClick"];
const _sfc_main = /* @__PURE__ */ defineComponent({
...{ name: contactsListName },
__name: "contacts-list",
props: contactsListProps,
emits: contactsListEmits,
setup(__props, { emit: __emit }) {
const { ns } = contactsListOptions;
const props = __props;
const emit = __emit;
const {
ctx: {
dataSource,
isTreeMode,
headerClass,
activeTab,
childTabs,
itemClass,
treeClass,
_childActiveTab,
_disabledIds,
_selectedIds,
selectedIconClass,
multiple,
optionKey,
listConfig
},
templates: {
DefineHeaderTemplate,
ReusableHeaderTemplate,
DefineContactsItemTemplate,
ReusableContactsItemTemplate,
DefineContactsCardItemTemplate,
ReusableContactsCardItemTemplate,
DefineTreeTemplate,
ReusableTreeTemplate,
DefineTreeItemTemplate,
ReusableTreeItemTemplate
},
handleTreeNode,
handleItemClick,
handleTreeSelect,
handleTreeExpand,
handleLoadMore
// handleUpdateChildActiveTab,
} = useContactsList(props, emit);
return (_ctx, _cache) => {
return openBlock(), createElementBlock(Fragment, null, [
createVNode(unref(DefineContactsItemTemplate), null, {
default: withCtx(({ item, onItemClick, onSuffixClick, $slots, ...itemProps }) => [
item ? (openBlock(), createBlock(_sfc_main$1, mergeProps({
key: item.value
}, item, {
style: itemProps.style,
class: [
itemProps.class,
{
[unref(ns).is("item-hover")]: true,
[unref(ns).is("disabled")]: unref(_disabledIds).includes(item.value)
}
],
type: unref(activeTab),
onItemClick,
onSuffixClick
}), createSlots({ _: 2 }, [
($slots == null ? void 0 : $slots.default) ? {
name: "default",
fn: withCtx(() => [
(openBlock(), createBlock(resolveDynamicComponent($slots.default)))
]),
key: "0"
} : void 0,
($slots == null ? void 0 : $slots.suffix) ? {
name: "suffix",
fn: withCtx(() => [
(openBlock(), createBlock(resolveDynamicComponent($slots.suffix)))
]),
key: "1"
} : void 0
]), 1040, ["style", "class", "type", "onItemClick", "onSuffixClick"])) : createCommentVNode("", true)
]),
_: 1
}),
createVNode(unref(DefineContactsCardItemTemplate), null, {
default: withCtx(({ treeNode: item, ...listItemProps }) => [
(openBlock(), createBlock(unref(ReusableContactsItemTemplate), {
key: item == null ? void 0 : item.value,
item,
checked: item.checked,
class: normalizeClass([unref(itemClass), unref(ns).is("list-item")]),
style: normalizeStyle(listItemProps.style),
onItemClick: ($event) => unref(handleItemClick)(item),
onSuffixClick: ($event) => unref(handleItemClick)(item)
}, {
suffix: withCtx(() => {
var _a, _b;
return [
createVNode(_sfc_main$2, {
class: normalizeClass([unref(selectedIconClass)]),
multiple: unref(multiple),
disabled: (_a = unref(_disabledIds)) == null ? void 0 : _a.includes(item.value),
checked: (_b = unref(_selectedIds)) == null ? void 0 : _b.includes(item == null ? void 0 : item.value)
}, null, 8, ["class", "multiple", "disabled", "checked"])
];
}),
_: 2
}, 1032, ["item", "checked", "class", "style", "onItemClick", "onSuffixClick"]))
]),
_: 1
}),
createVNode(unref(DefineTreeItemTemplate), null, {
default: withCtx(({ treeNode: item }) => [
item.isCard ? (openBlock(), createBlock(unref(ReusableContactsCardItemTemplate), {
key: 0,
"tree-node": item,
style: { "padding-left": "0", "padding-right": "0" }
}, null, 8, ["tree-node"])) : (item == null ? void 0 : item.label) ? (openBlock(), createElementBlock("div", {
key: 1,
onClick: withModifiers(($event) => unref(handleItemClick)(item), ["stop"])
}, [
createElementVNode("span", null, toDisplayString(item == null ? void 0 : item.label), 1),
createVNode(_sfc_main$2, {
class: normalizeClass([unref(selectedIconClass)].concat([unref(ns).is("tree-selected-icon")])),
multiple: unref(multiple),
checked: item.checked,
disabled: item.disabled,
indeterminate: item.halfChecked
}, null, 8, ["class", "multiple", "checked", "disabled", "indeterminate"])
], 8, _hoisted_1)) : createCommentVNode("", true)
]),
_: 1
}),
createVNode(unref(DefineTreeTemplate), null, {
default: withCtx(({ height }) => [
unref(dataSource) ? (openBlock(), createBlock(unref(Tree), {
key: 0,
class: normalizeClass([unref(treeClass), unref(ns).is("tree-list")]),
style: {
height: "100%"
},
"block-node": true,
"show-icon": true,
virtual: true,
selectable: false,
multiple: unref(multiple),
height,
"selected-keys": unref(_selectedIds),
"checked-keys": unref(_selectedIds),
checkable: true,
"tree-data": unref(dataSource),
"field-names": {
children: unref(optionKey).children,
title: unref(optionKey).label,
key: unref(optionKey).value
},
onExpand: unref(handleTreeExpand),
onSelect: unref(handleTreeSelect)
}, {
switcherIcon: withCtx(({ switcherCls, dataRef }) => [
(dataRef == null ? void 0 : dataRef.loading) ? (openBlock(), createBlock(unref(LoadingOutlined), { key: 0 })) : (openBlock(), createBlock(unref(CaretDownOutlined), {
key: 1,
class: normalizeClass(switcherCls)
}, null, 8, ["class"]))
]),
title: withCtx((treeNode) => [
createVNode(unref(ReusableTreeItemTemplate), {
"tree-node": unref(handleTreeNode)(treeNode, unref(_selectedIds))
}, null, 8, ["tree-node"])
]),
_: 2
}, 1032, ["class", "multiple", "height", "selected-keys", "checked-keys", "tree-data", "field-names", "onExpand", "onSelect"])) : createCommentVNode("", true)
]),
_: 1
}),
createVNode(unref(DefineHeaderTemplate), null, {
default: withCtx(() => [
createElementVNode("div", {
class: normalizeClass([unref(headerClass), unref(ns).is("list-header")])
}, [
createVNode(unref(Radio).Group, {
value: unref(_childActiveTab),
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => isRef(_childActiveTab) ? _childActiveTab.value = $event : null),
"button-style": "solid",
size: "small",
onChange: unref(handleLoadMore)
}, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(childTabs), (item) => {
return openBlock(), createBlock(unref(Radio).Button, {
key: item.value,
value: item.value
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(item.label), 1)
]),
_: 2
}, 1032, ["value"]);
}), 128))
]),
_: 1
}, 8, ["value", "onChange"])
], 2)
]),
_: 1
}),
createVNode(unref(YzList), mergeProps({
class: [unref(ns).b()],
"data-source": unref(dataSource)
}, unref(listConfig)), createSlots({ _: 2 }, [
_ctx.$slots.header || unref(activeTab) === unref(Contacts).USER ? {
name: "header",
fn: withCtx((headerProps) => [
_ctx.$slots.header ? renderSlot(_ctx.$slots, "header", normalizeProps(mergeProps({ key: 0 }, headerProps))) : unref(activeTab) === unref(Contacts).USER ? (openBlock(), createBlock(unref(ReusableHeaderTemplate), { key: 1 })) : createCommentVNode("", true)
]),
key: "0"
} : void 0,
unref(isTreeMode) ? {
name: "tree",
fn: withCtx(({ height, props: treeProps }) => [
createVNode(unref(ReusableTreeTemplate), normalizeProps(guardReactiveProps({ height, props: treeProps })), null, 16)
]),
key: "1"
} : {
name: "default",
fn: withCtx(({ item }) => [
item ? (openBlock(), createBlock(unref(ReusableContactsCardItemTemplate), {
key: 0,
"tree-node": unref(handleTreeNode)(item, unref(_selectedIds))
}, null, 8, ["tree-node"])) : createCommentVNode("", true)
]),
key: "2"
}
]), 1040, ["class", "data-source"])
], 64);
};
}
});
export {
_sfc_main as default
};