From 2d9a3328c2cfb94b37f27e1b9da392bfa106ac09 Mon Sep 17 00:00:00 2001 From: Uyarn Date: Wed, 18 Oct 2023 15:08:01 +0800 Subject: [PATCH] chore: use old tree common before refactoring --- src/cascader/hooks.tsx | 6 ++++-- src/tree-select/useTreeSelectUtils.ts | 6 ++++-- src/tree/hooks/useStore.ts | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cascader/hooks.tsx b/src/cascader/hooks.tsx index 822849a797..3977da94f7 100644 --- a/src/cascader/hooks.tsx +++ b/src/cascader/hooks.tsx @@ -8,7 +8,7 @@ import { getTreeValue, getCascaderValue, isEmptyValues, isValueInvalid } from '. import { treeNodesEffect, treeStoreExpendEffect } from './core/effect'; import useControlled from '../hooks/useControlled'; -import { +import type { TreeNode, TreeNodeValue, TdCascaderProps, @@ -17,6 +17,8 @@ import { CascaderValue, } from './interface'; +import type { TypeTreeNodeData } from '../_common/js/tree/types'; + export const useCascaderContext = (props: TdCascaderProps) => { const [innerValue, setInnerValue] = useControlled(props, 'value', props.onChange); const [innerPopupVisible, setPopupVisible] = useControlled(props, 'popupVisible', props.onPopupVisibleChange); @@ -96,7 +98,7 @@ export const useCascaderContext = (props: TdCascaderProps) => { }); }, }); - store.append(options); + store.append(options as Array); setTreeStore(store); } else { treeStore.reload(options); diff --git a/src/tree-select/useTreeSelectUtils.ts b/src/tree-select/useTreeSelectUtils.ts index 850fed90d3..f00e4c9a60 100644 --- a/src/tree-select/useTreeSelectUtils.ts +++ b/src/tree-select/useTreeSelectUtils.ts @@ -3,9 +3,11 @@ import type { TreeSelectValue } from './type'; import Tree, { TreeNodeValue } from '../tree'; import TreeStore from '../_common/js/tree/tree-store'; import { usePersistFn } from '../_util/usePersistFn'; -import type { NodeOptions, TreeSelectProps } from './TreeSelect'; import { treeSelectDefaultProps } from './defaultProps'; +import type { NodeOptions, TreeSelectProps } from './TreeSelect'; +import type { TypeTreeNodeData } from '../_common/js/tree/types'; + export const useTreeSelectUtils = ( { data, treeProps, valueType }: TreeSelectProps, treeRef: MutableRefObject>, @@ -15,7 +17,7 @@ export const useTreeSelectUtils = ( ...treeSelectDefaultProps.treeProps, ...treeProps, }); - store.append(data); + store.append(data as Array); return store; }, [data, treeProps]); diff --git a/src/tree/hooks/useStore.ts b/src/tree/hooks/useStore.ts index 8d1d46a77c..f188ae97c3 100644 --- a/src/tree/hooks/useStore.ts +++ b/src/tree/hooks/useStore.ts @@ -4,8 +4,10 @@ import useUpdateEffect from '../../_util/useUpdateEffect'; import usePrevious from '../../hooks/usePrevious'; import TreeStore from '../../_common/js/tree/tree-store'; import { usePersistFn } from '../../_util/usePersistFn'; + import type { TdTreeProps } from '../type'; import type { TypeEventState } from '../interface'; +import type { TypeTreeNodeData } from '../../_common/js/tree/types'; export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { const storeRef = useRef(); @@ -122,7 +124,7 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { list = []; } - store.append(list); + store.append(list as Array); // 刷新节点,必须在配置选中之前执行 // 这样选中态联动判断才能找到父节点 @@ -161,7 +163,7 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { const checked = store.getChecked(); const actived = store.getActived(); store.removeAll(); - store.append(data); + store.append(data as Array); store.setChecked(checked); store.setActived(actived); store.setExpanded(expanded);