UNPKG

yanzhen-design-vue

Version:

27 lines (26 loc) 820 B
import { unref } from "vue"; import { isString } from "lodash-es"; import { Contacts } from "../constants/contacts.mjs"; import { handleDataType } from "./handleDataType.mjs"; function handleTreeNode(props, selectedIds) { let isCard = props.isCard === true; if (!isCard) isCard = handleDataType(props) === Contacts.USER; return new Proxy(props, { get(target, p, receiver) { var _a; const value = Reflect.get(target, p, receiver); if (isString(p)) { switch (true) { case p === "isCard": return isCard; case (p === "checked" && (isCard || target.isLeaf)): return (_a = unref(selectedIds)) == null ? void 0 : _a.includes(target == null ? void 0 : target.value); } } return value; } }); } export { handleTreeNode };