Skip to content

Commit b0678d7

Browse files
committed
refactor: tree-select
1 parent 15ca5f0 commit b0678d7

File tree

7 files changed

+249
-114
lines changed

7 files changed

+249
-114
lines changed

components/tree/Tree.tsx

Lines changed: 3 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const treeProps = () => {
123123
*/
124124
replaceFields: { type: Object as PropType<FieldNames> },
125125
blockNode: { type: Boolean, default: undefined },
126+
openAnimation: PropTypes.any,
126127
};
127128
};
128129

@@ -182,6 +183,7 @@ export default defineComponent({
182183
selectable,
183184
fieldNames,
184185
replaceFields,
186+
motion = props.openAnimation,
185187
} = props;
186188
const newProps = {
187189
...attrs,
@@ -197,6 +199,7 @@ export default defineComponent({
197199
itemHeight={20}
198200
virtual={virtual.value}
199201
{...newProps}
202+
motion={motion}
200203
ref={treeRef}
201204
prefixCls={prefixCls.value}
202205
class={classNames(
@@ -226,103 +229,4 @@ export default defineComponent({
226229
);
227230
};
228231
},
229-
// methods: {
230-
// renderSwitcherIcon(prefixCls: string, switcherIcon: VNode, { isLeaf, loading, expanded }) {
231-
// const { showLine } = this.$props;
232-
// if (loading) {
233-
// return <LoadingOutlined class={`${prefixCls}-switcher-loading-icon`} />;
234-
// }
235-
236-
// if (isLeaf) {
237-
// return showLine ? <FileOutlined class={`${prefixCls}-switcher-line-icon`} /> : null;
238-
// }
239-
// const switcherCls = `${prefixCls}-switcher-icon`;
240-
// if (switcherIcon) {
241-
// return cloneElement(switcherIcon, {
242-
// class: switcherCls,
243-
// });
244-
// }
245-
// return showLine ? (
246-
// expanded ? (
247-
// <MinusSquareOutlined class={`${prefixCls}-switcher-line-icon`} />
248-
// ) : (
249-
// <PlusSquareOutlined class={`${prefixCls}-switcher-line-icon`} />
250-
// )
251-
// ) : (
252-
// <CaretDownFilled class={switcherCls} />
253-
// );
254-
// },
255-
// updateTreeData(treeData: TreeDataItem[]) {
256-
// const { $slots } = this;
257-
// const defaultFields = { children: 'children', title: 'title', key: 'key' };
258-
// const replaceFields = { ...defaultFields, ...this.$props.replaceFields };
259-
// return treeData.map(item => {
260-
// const key = item[replaceFields.key];
261-
// const children = item[replaceFields.children];
262-
// const { slots = {}, class: cls, style, ...restProps } = item;
263-
// const treeNodeProps = {
264-
// ...restProps,
265-
// icon: $slots[slots.icon] || restProps.icon,
266-
// switcherIcon: $slots[slots.switcherIcon] || restProps.switcherIcon,
267-
// title: $slots[slots.title] || $slots.title || restProps[replaceFields.title],
268-
// dataRef: item,
269-
// key,
270-
// class: cls,
271-
// style,
272-
// };
273-
// if (children) {
274-
// return { ...treeNodeProps, children: this.updateTreeData(children) };
275-
// }
276-
// return treeNodeProps;
277-
// });
278-
// },
279-
// setTreeRef(node: VNode) {
280-
// this.tree = node;
281-
// },
282-
// handleCheck(checkedObj: (number | string)[], eventObj: CheckEvent) {
283-
// this.$emit('update:checkedKeys', checkedObj);
284-
// this.$emit('check', checkedObj, eventObj);
285-
// },
286-
// handleExpand(expandedKeys: (number | string)[], eventObj: ExpendEvent) {
287-
// this.$emit('update:expandedKeys', expandedKeys);
288-
// this.$emit('expand', expandedKeys, eventObj);
289-
// },
290-
// handleSelect(selectedKeys: (number | string)[], eventObj: SelectEvent) {
291-
// this.$emit('update:selectedKeys', selectedKeys);
292-
// this.$emit('select', selectedKeys, eventObj);
293-
// },
294-
// },
295-
// render() {
296-
// const props = getOptionProps(this);
297-
// const { prefixCls: customizePrefixCls, showIcon, treeNodes, blockNode } = props;
298-
// const getPrefixCls = this.configProvider.getPrefixCls;
299-
// const prefixCls = getPrefixCls('tree', customizePrefixCls);
300-
// const switcherIcon = getComponent(this, 'switcherIcon');
301-
// const checkable = props.checkable;
302-
// let treeData = props.treeData || treeNodes;
303-
// if (treeData) {
304-
// treeData = this.updateTreeData(treeData);
305-
// }
306-
// const { class: className, ...restAttrs } = this.$attrs;
307-
// const vcTreeProps = {
308-
// ...props,
309-
// prefixCls,
310-
// checkable: checkable ? <span class={`${prefixCls}-checkbox-inner`} /> : checkable,
311-
// children: getSlot(this),
312-
// switcherIcon: nodeProps => this.renderSwitcherIcon(prefixCls, switcherIcon, nodeProps),
313-
// ref: this.setTreeRef,
314-
// ...restAttrs,
315-
// class: classNames(className, {
316-
// [`${prefixCls}-icon-hide`]: !showIcon,
317-
// [`${prefixCls}-block-node`]: blockNode,
318-
// }),
319-
// onCheck: this.handleCheck,
320-
// onExpand: this.handleExpand,
321-
// onSelect: this.handleSelect,
322-
// } as Record<string, any>;
323-
// if (treeData) {
324-
// vcTreeProps.treeData = treeData;
325-
// }
326-
// return <VcTree {...vcTreeProps} />;
327-
// },
328232
});

components/vc-select/OptionList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import type { RawValueType, FlattenOptionsType } from './interface/generator';
1818
import useMemo from '../_util/hooks/useMemo';
1919

2020
export interface RefOptionListProps {
21-
onKeydown: KeyboardEvent;
22-
onKeyup: KeyboardEvent;
21+
onKeydown: (e?: KeyboardEvent) => void;
22+
onKeyup: (e?: KeyboardEvent) => void;
2323
scrollTo?: (index: number) => void;
2424
}
2525
export interface OptionListProps {

components/vc-tree-select/Context.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212

1313
interface ContextProps {
1414
checkable: boolean;
15+
customCheckable: () => any;
1516
checkedKeys: Key[];
1617
halfCheckedKeys: Key[];
1718
treeExpandedKeys: Key[];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy