yanzhen-design-vue
Version:
82 lines (81 loc) • 3.14 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const context = require("./context.cjs");
const Column = require("./Column.vue.cjs");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "OptionList",
setup(__props) {
const simpleImage = antDesignVue.Empty.PRESENTED_IMAGE_SIMPLE;
const {
options,
searchValue,
searchOptions,
fieldNames,
onSelect,
values,
checkedValues,
halfCheckedValues
} = context.useInjectInnerCascader();
const checkedSet = vue.computed(() => new Set(checkedValues.value));
const halfCheckedSet = vue.computed(() => new Set(halfCheckedValues.value));
const activeValueCells = vue.ref([]);
const mergedOptions = vue.computed(() => {
if (searchValue.value) {
return searchOptions.value;
}
return options.value;
});
const optionColumns = vue.computed(() => {
const optionList = [{ options: mergedOptions.value }];
let currentList = mergedOptions.value;
for (let i = 0; i < activeValueCells.value.length; i++) {
const activeValueCell = activeValueCells.value[i];
const currentOption = currentList.find(
(option) => option[fieldNames.value.value] === activeValueCell
);
const subOptions = currentOption == null ? void 0 : currentOption[fieldNames.value.children];
if (!(subOptions == null ? void 0 : subOptions.length)) {
break;
}
currentList = subOptions;
optionList.push({ options: subOptions });
}
return optionList;
});
const onPathOpen = (fullPath) => {
activeValueCells.value = fullPath;
};
const onPathSelect = (valuePath) => {
onSelect(valuePath);
};
const onClick = (event) => {
event.preventDefault();
};
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: "inner-cascader-menus",
onClick
}, [
optionColumns.value[0].options.length ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(optionColumns.value, (column, index) => {
return vue.openBlock(), vue.createBlock(Column.default, {
key: column[vue.unref(fieldNames).value] || index,
options: column.options,
"prev-value-path": activeValueCells.value.slice(0, index),
"active-value": activeValueCells.value[index],
"checked-set": checkedSet.value,
"half-checked-set": halfCheckedSet.value,
onActive: onPathOpen,
onSelect: onPathSelect
}, null, 8, ["options", "prev-value-path", "active-value", "checked-set", "half-checked-set"]);
}), 128)) : (vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Empty), {
key: 1,
image: vue.unref(simpleImage),
style: { width: "100%" }
}, null, 8, ["image"]))
]);
};
}
});
exports.default = _sfc_main;