vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
621 B
25 lines
621 B
import type { FunctionalComponent, PropType } from 'vue'; |
|
import { cloneVNode } from 'vue'; |
|
import { flattenChildren } from '../_util/props-util'; |
|
|
|
export interface ItemProps { |
|
setRef: (element: HTMLElement) => void; |
|
} |
|
|
|
const Item: FunctionalComponent<ItemProps> = ({ setRef }, { slots }) => { |
|
const children = flattenChildren(slots.default?.()); |
|
|
|
return children && children.length |
|
? cloneVNode(children[0], { |
|
ref: setRef as any, |
|
}) |
|
: children; |
|
}; |
|
Item.props = { |
|
setRef: { |
|
type: Function as PropType<(element: HTMLElement) => void>, |
|
default: () => {}, |
|
}, |
|
}; |
|
|
|
export default Item;
|
|
|