ant-design-vue/components/vc-cascader/hooks/useMissingValues.ts
tangjinzhou f0385d7c24
Refactor cascader (#5192)
* 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
2022-01-21 21:58:10 +08:00

27 lines
806 B
TypeScript

import type { Ref } from 'vue';
import { computed } from 'vue';
import type { SingleValueType, DefaultOptionType, InternalFieldNames } from '../Cascader';
import { toPathOptions } from '../utils/treeUtil';
export default (
options: Ref<DefaultOptionType[]>,
fieldNames: Ref<InternalFieldNames>,
rawValues: Ref<SingleValueType[]>,
) => {
return computed(() => {
const missingValues: SingleValueType[] = [];
const existsValues: SingleValueType[] = [];
rawValues.value.forEach(valueCell => {
const pathOptions = toPathOptions(valueCell, options.value, fieldNames.value);
if (pathOptions.every(opt => opt.option)) {
existsValues.push(valueCell);
} else {
missingValues.push(valueCell);
}
});
return [existsValues, missingValues];
});
};