UNPKG

yanzhen-design-vue

Version:

25 lines (24 loc) 646 B
import { computed } from "vue"; import { convertDataToEntities } from "../utils.mjs"; function useEntities(options, fieldNames) { const entities = computed(() => { return convertDataToEntities(options.value, { fieldNames: fieldNames.value, initWrapper: (wrapper) => { return { ...wrapper, pathKeyEntities: {} }; }, processEntity: (wrapper, entity) => { const pathKey = entity.node[fieldNames.value.value]; wrapper.pathKeyEntities[pathKey] = entity; entity.key = pathKey; } }).pathKeyEntities; }); return entities; } export { useEntities };