mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-30 19:18:07 +08:00
f0385d7c24
* feat: tree * refactor: select * refactor: select * refactor: select * refactor: vc-tree-select * refactor: tree-select * refactor: tree-select * feat: add showLeafIcon * refactor: remove lod vc-tree-select * feat: tree-select add tag-render * refactor: cascader * refactor: cascader * refactor: cascader * refactor: cascader * fix: maxTagmaxTagPlaceholder not work
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { convertDataToEntities } from '../../vc-tree/utils/treeUtil';
|
|
import type { DataEntity } from '../../vc-tree/interface';
|
|
import type { DefaultOptionType, InternalFieldNames } from '../Cascader';
|
|
import { VALUE_SPLIT } from '../utils/commonUtil';
|
|
import type { Ref } from 'vue';
|
|
import { computed } from 'vue';
|
|
|
|
export interface OptionsInfo {
|
|
keyEntities: Record<string, DataEntity>;
|
|
pathKeyEntities: Record<string, DataEntity>;
|
|
}
|
|
|
|
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
|
|
export default (options: Ref<DefaultOptionType[]>, fieldNames: Ref<InternalFieldNames>) => {
|
|
const entities = computed(() => {
|
|
return (
|
|
convertDataToEntities(options.value as any, {
|
|
fieldNames: fieldNames.value,
|
|
initWrapper: wrapper => ({
|
|
...wrapper,
|
|
pathKeyEntities: {},
|
|
}),
|
|
processEntity: (entity, wrapper: any) => {
|
|
const pathKey = entity.nodes.map(node => node[fieldNames.value.value]).join(VALUE_SPLIT);
|
|
|
|
wrapper.pathKeyEntities[pathKey] = entity;
|
|
|
|
// Overwrite origin key.
|
|
// this is very hack but we need let conduct logic work with connect path
|
|
entity.key = pathKey;
|
|
},
|
|
}) as any
|
|
).pathKeyEntities;
|
|
});
|
|
return entities;
|
|
};
|