2021-06-26 09:35:40 +08:00
|
|
|
import type { FunctionalComponent, PropType } from 'vue';
|
|
|
|
import { cloneVNode } from 'vue';
|
2020-10-01 17:20:10 +08:00
|
|
|
|
|
|
|
export interface ItemProps {
|
|
|
|
setRef: (element: HTMLElement) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Item: FunctionalComponent<ItemProps> = ({ setRef }, { slots }) => {
|
|
|
|
const children = slots.default?.();
|
|
|
|
|
|
|
|
return children && children.length
|
|
|
|
? cloneVNode(children[0], {
|
2020-10-17 12:14:13 +08:00
|
|
|
ref: setRef as any,
|
2020-10-01 17:20:10 +08:00
|
|
|
})
|
|
|
|
: children;
|
|
|
|
};
|
2020-10-07 22:49:01 +08:00
|
|
|
Item.props = {
|
|
|
|
setRef: {
|
|
|
|
type: Function as PropType<(element: HTMLElement) => void>,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
};
|
2020-10-17 12:14:13 +08:00
|
|
|
|
2020-10-01 17:20:10 +08:00
|
|
|
export default Item;
|