2021-08-17 14:03:49 +00:00
|
|
|
import type { ExtractPropTypes, PropType, VNode } from 'vue';
|
2021-06-26 01:35:40 +00:00
|
|
|
import { defineComponent, inject } from 'vue';
|
2019-01-12 03:33:27 +00:00
|
|
|
import omit from 'omit.js';
|
2020-09-02 14:44:16 +00:00
|
|
|
import debounce from 'lodash-es/debounce';
|
2020-03-28 07:50:01 +00:00
|
|
|
import FolderOpenOutlined from '@ant-design/icons-vue/FolderOpenOutlined';
|
2020-04-06 03:18:26 +00:00
|
|
|
import FolderOutlined from '@ant-design/icons-vue/FolderOutlined';
|
2020-03-28 07:50:01 +00:00
|
|
|
import FileOutlined from '@ant-design/icons-vue/FileOutlined';
|
2019-01-12 03:33:27 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-08-31 08:53:19 +00:00
|
|
|
import classNames from '../_util/classNames';
|
2021-08-17 14:03:49 +00:00
|
|
|
import { treeProps } from './Tree';
|
2021-06-26 01:35:40 +00:00
|
|
|
import Tree, { TreeProps } from './Tree';
|
2020-03-07 11:45:13 +00:00
|
|
|
import {
|
|
|
|
calcRangeKeys,
|
|
|
|
getFullKeyList,
|
|
|
|
convertDirectoryKeysToNodes,
|
|
|
|
getFullKeyListByTreeData,
|
|
|
|
} from './util';
|
2020-10-22 06:25:02 +00:00
|
|
|
import { getOptionProps, getComponent, getSlot } from '../_util/props-util';
|
|
|
|
import initDefaultProps from '../_util/props-util/initDefaultProps';
|
2020-09-30 02:47:18 +00:00
|
|
|
import { defaultConfigProvider } from '../config-provider';
|
2018-09-26 14:57:01 +00:00
|
|
|
|
2021-08-17 14:03:49 +00:00
|
|
|
export type ExpandAction = false | 'click' | 'doubleClick' | 'dblclick';
|
2020-10-22 06:25:02 +00:00
|
|
|
|
2020-11-18 09:37:15 +00:00
|
|
|
function getIcon(props: { isLeaf: boolean; expanded: boolean } & VNode) {
|
2019-01-12 03:33:27 +00:00
|
|
|
const { isLeaf, expanded } = props;
|
2018-09-26 14:57:01 +00:00
|
|
|
if (isLeaf) {
|
2020-03-28 07:50:01 +00:00
|
|
|
return <FileOutlined />;
|
2018-09-26 14:57:01 +00:00
|
|
|
}
|
2020-04-06 03:18:26 +00:00
|
|
|
return expanded ? <FolderOpenOutlined /> : <FolderOutlined />;
|
2018-09-26 14:57:01 +00:00
|
|
|
}
|
|
|
|
|
2021-08-17 14:03:49 +00:00
|
|
|
const directoryTreeProps = {
|
|
|
|
...treeProps(),
|
|
|
|
expandAction: { type: [Boolean, String] as PropType<ExpandAction> },
|
|
|
|
};
|
|
|
|
|
|
|
|
export type DirectoryTreeProps = Partial<ExtractPropTypes<typeof directoryTreeProps>>;
|
|
|
|
|
2020-10-22 06:25:02 +00:00
|
|
|
export default defineComponent({
|
2018-09-26 14:57:01 +00:00
|
|
|
name: 'ADirectoryTree',
|
2020-07-16 10:31:20 +00:00
|
|
|
inheritAttrs: false,
|
2021-08-17 14:03:49 +00:00
|
|
|
props: initDefaultProps(directoryTreeProps, {
|
|
|
|
showIcon: true,
|
|
|
|
expandAction: 'click',
|
|
|
|
}),
|
2020-07-16 10:31:20 +00:00
|
|
|
setup() {
|
2021-08-17 14:03:49 +00:00
|
|
|
return () => {
|
|
|
|
return null;
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-09-26 14:57:01 +00:00
|
|
|
},
|
2020-10-22 06:25:02 +00:00
|
|
|
});
|