yanzhen-design-vue
Version:
69 lines (68 loc) • 3.05 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const iconsVue = require("@ant-design/icons-vue");
const context = require("./context.cjs");
const utils = require("./utils.cjs");
const _hoisted_1 = { class: "inner-cascader-menu" };
const _hoisted_2 = ["onClick"];
const _hoisted_3 = ["title"];
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "Column",
props: {
options: {},
prevValuePath: {},
activeValue: {},
checkedSet: { default: () => /* @__PURE__ */ new Set() },
halfCheckedSet: { default: () => /* @__PURE__ */ new Set() }
},
emits: ["active", "select"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const { fieldNames } = context.useInjectInnerCascader();
const triggerOpenPath = (e, fullPath, isLeaf2) => {
e.preventDefault();
emit("active", fullPath);
if (isLeaf2) {
triggerSelect(fullPath);
}
};
const triggerSelect = (fullPath) => {
emit("select", fullPath);
};
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("ul", _hoisted_1, [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(props.options, (option, index) => {
var _a;
return vue.openBlock(), vue.createElementBlock("li", {
key: option[vue.unref(fieldNames).value] || index,
class: vue.normalizeClass(["inner-cascader-menu-item", { active: props.activeValue === option[vue.unref(fieldNames).value] }]),
onClick: (e) => triggerOpenPath(
e,
[...props.prevValuePath, option[vue.unref(fieldNames).value]],
vue.unref(utils.isLeaf)(option, vue.unref(fieldNames))
)
}, [
vue.createVNode(vue.unref(antDesignVue.Checkbox), {
class: "inner-cascader-checkbox",
checked: props.checkedSet.has(option[vue.unref(fieldNames).value]),
indeterminate: props.halfCheckedSet.has(option[vue.unref(fieldNames).value]),
onClick: vue.withModifiers(($event) => triggerSelect([...props.prevValuePath, option[vue.unref(fieldNames).value]]), ["stop"])
}, null, 8, ["checked", "indeterminate", "onClick"]),
vue.createElementVNode("div", {
class: "inner-cascader-item-content",
title: option[vue.unref(fieldNames).label]
}, vue.toDisplayString(option[vue.unref(fieldNames).label]), 9, _hoisted_3),
((_a = option[vue.unref(fieldNames).children]) == null ? void 0 : _a.length) ? (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.RightOutlined), {
key: 0,
class: "inner-cascader-item-expand-icon"
})) : vue.createCommentVNode("", true)
], 10, _hoisted_2);
}), 128))
]);
};
}
});
exports.default = _sfc_main;