From d676ca48974bad3008676a52bcc6dc09bbcae2db Mon Sep 17 00:00:00 2001 From: jiaxiang Date: Mon, 17 Feb 2025 09:10:47 +0800 Subject: [PATCH] chore: [tree] export types (#19846) * chore: [tree] export type and fix the type error of the docs * revert: revert * revert: revert --- packages/components/tree/index.ts | 3 +- packages/components/tree/src/tree.type.ts | 44 +++++++++++------------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/packages/components/tree/index.ts b/packages/components/tree/index.ts index 8da64a0eb8..3722cd179d 100644 --- a/packages/components/tree/index.ts +++ b/packages/components/tree/index.ts @@ -7,4 +7,5 @@ export const ElTree: SFCWithInstall = withInstall(Tree) export default ElTree -export type { TreeInstance } from './src/instance' +export * from './src/tree.type' +export * from './src/instance' diff --git a/packages/components/tree/src/tree.type.ts b/packages/components/tree/src/tree.type.ts index 657fca4836..70aff43d07 100644 --- a/packages/components/tree/src/tree.type.ts +++ b/packages/components/tree/src/tree.type.ts @@ -18,33 +18,31 @@ export interface RootTreeType { instance: ComponentInternalInstance } -export declare type hType = typeof h -export declare type TreeData = TreeNodeData[] -export declare type TreeKey = string | number -export declare interface FakeNode { +export type hType = typeof h +export type TreeData = TreeNodeData[] +export type TreeKey = string | number +export interface FakeNode { data: TreeNodeData } -export declare interface TreeNodeData { - [key: string]: any -} -export declare interface TreeNodeLoadedDefaultProps { +export type TreeNodeData = Record +export interface TreeNodeLoadedDefaultProps { checked?: boolean } -export declare interface TreeNodeChildState { +export interface TreeNodeChildState { all: boolean none: boolean allWithoutDisable: boolean half: boolean } -export declare interface TreeNodeOptions { +export interface TreeNodeOptions { data: TreeNodeData store: TreeStore parent?: Node } -export declare interface TreeStoreNodesMap { +export interface TreeStoreNodesMap { [key: string]: Node } -export declare interface TreeStoreOptions { +export interface TreeStoreOptions { key: TreeKey data: TreeData lazy: boolean @@ -59,7 +57,7 @@ export declare interface TreeStoreOptions { defaultExpandAll: boolean filterNodeMethod: FilterNodeMethodFunction } -export declare interface TreeOptionProps { +export interface TreeOptionProps { children?: string label?: string | ((data: TreeNodeData, node: Node) => string) disabled?: string | ((data: TreeNodeData, node: Node) => boolean) @@ -69,35 +67,35 @@ export declare interface TreeOptionProps { node: Node ) => string | { [key: string]: boolean } } -export declare type RenderContentFunction = ( +export type RenderContentFunction = ( h: hType, context: RenderContentContext ) => VNode | VNode[] -export declare interface RenderContentContext { +export interface RenderContentContext { _self: ComponentInternalInstance node: Node data: TreeNodeData store: TreeStore } -export declare type AllowDragFunction = (node: Node) => boolean -export declare type AllowDropType = 'inner' | 'prev' | 'next' -export declare type AllowDropFunction = ( +export type AllowDragFunction = (node: Node) => boolean +export type AllowDropType = 'inner' | 'prev' | 'next' +export type AllowDropFunction = ( draggingNode: Node, dropNode: Node, type: AllowDropType ) => boolean -export declare type LoadFunction = ( +export type LoadFunction = ( rootNode: Node, loadedCallback: (data: TreeData) => void, stopLoading: () => void ) => void -export declare type FilterValue = any -export declare type FilterNodeMethodFunction = ( +export type FilterValue = any +export type FilterNodeMethodFunction = ( value: FilterValue, data: TreeNodeData, child: Node ) => boolean -export declare interface TreeComponentProps { +export interface TreeComponentProps { data: TreeData emptyText: string renderAfterExpand: boolean @@ -126,4 +124,4 @@ export declare interface TreeComponentProps { icon: string | Component } -export declare type NodeDropType = 'before' | 'after' | 'inner' | 'none' +export type NodeDropType = 'before' | 'after' | 'inner' | 'none'